Skip to content
This repository
Browse code

Merge remote-tracking branch 'ceeram/2.2-hash' into 2.2-hash

  • Loading branch information...
commit eeec3627415635a5e11237bcf2cb049706086b53 2 parents 8378991 + 2b7fe21
Mark Story authored
12  lib/Cake/Model/Permission.php
@@ -105,7 +105,7 @@ public function check($aro, $aco, $action = "*") {
105 105
 		}
106 106
 
107 107
 		$inherited = array();
108  
-		$acoIDs = Set::extract($acoPath, '{n}.' . $this->Aco->alias . '.id');
  108
+		$acoIDs = Hash::extract($acoPath, '{n}.' . $this->Aco->alias . '.id');
109 109
 
110 110
 		$count = count($aroPath);
111 111
 		for ($i = 0 ; $i < $count; $i++) {
@@ -123,7 +123,7 @@ public function check($aro, $aco, $action = "*") {
123 123
 			if (empty($perms)) {
124 124
 				continue;
125 125
 			} else {
126  
-				$perms = Set::extract($perms, '{n}.' . $this->alias);
  126
+				$perms = Hash::extract($perms, '{n}.' . $this->alias);
127 127
 				foreach ($perms as $perm) {
128 128
 					if ($action == '*') {
129 129
 
@@ -225,11 +225,11 @@ public function getAclLink($aro, $aco) {
225 225
 		}
226 226
 
227 227
 		return array(
228  
-			'aro' => Set::extract($obj, 'Aro.0.' . $this->Aro->alias . '.id'),
229  
-			'aco' => Set::extract($obj, 'Aco.0.' . $this->Aco->alias . '.id'),
  228
+			'aro' => current(Hash::extract($obj, 'Aro.0.' . $this->Aro->alias . '.id')),
  229
+			'aco' => current(Hash::extract($obj, 'Aco.0.' . $this->Aco->alias . '.id')),
230 230
 			'link' => $this->find('all', array('conditions' => array(
231  
-				$this->alias . '.aro_id' => Set::extract($obj, 'Aro.0.' . $this->Aro->alias . '.id'),
232  
-				$this->alias . '.aco_id' => Set::extract($obj, 'Aco.0.' . $this->Aco->alias . '.id')
  231
+				$this->alias . '.aro_id' => current(Hash::extract($obj, 'Aro.0.' . $this->Aro->alias . '.id')),
  232
+				$this->alias . '.aco_id' => current(Hash::extract($obj, 'Aco.0.' . $this->Aco->alias . '.id'))
233 233
 			)))
234 234
 		);
235 235
 	}
8  lib/Cake/Test/Case/Controller/Component/PaginatorComponentTest.php
@@ -619,7 +619,7 @@ public function testPaginateOrderVirtualField() {
619 619
 
620 620
 		$Controller->request->params['named'] = array('sort' => 'offset_test', 'direction' => 'asc');
621 621
 		$result = $Controller->Paginator->paginate('PaginatorControllerPost');
622  
-		$this->assertEquals(array(2, 3, 4), Set::extract($result, '{n}.PaginatorControllerPost.offset_test'));
  622
+		$this->assertEquals(array(2, 3, 4), Hash::extract($result, '{n}.PaginatorControllerPost.offset_test'));
623 623
 	}
624 624
 
625 625
 /**
@@ -986,7 +986,7 @@ public function testPaginateCustomFind() {
986 986
 		$this->assertTrue(!empty($result));
987 987
 
988 988
 		$result = $Controller->paginate();
989  
-		$this->assertEquals(Set::extract($result, '{n}.PaginatorCustomPost.id'), array(1, 2, 3, 4));
  989
+		$this->assertEquals(array(1, 2, 3, 4), Hash::extract($result, '{n}.PaginatorCustomPost.id'));
990 990
 
991 991
 		$result = $Controller->params['paging']['PaginatorCustomPost'];
992 992
 		$this->assertEquals(4, $result['current']);
@@ -994,7 +994,7 @@ public function testPaginateCustomFind() {
994 994
 
995 995
 		$Controller->paginate = array('published');
996 996
 		$result = $Controller->paginate();
997  
-		$this->assertEquals(Set::extract($result, '{n}.PaginatorCustomPost.id'), array(1, 2, 3));
  997
+		$this->assertEquals(array(1, 2, 3), Hash::extract($result, '{n}.PaginatorCustomPost.id'));
998 998
 
999 999
 		$result = $Controller->params['paging']['PaginatorCustomPost'];
1000 1000
 		$this->assertEquals(3, $result['current']);
@@ -1002,7 +1002,7 @@ public function testPaginateCustomFind() {
1002 1002
 
1003 1003
 		$Controller->paginate = array('published', 'limit' => 2);
1004 1004
 		$result = $Controller->paginate();
1005  
-		$this->assertEquals(Set::extract($result, '{n}.PaginatorCustomPost.id'), array(1, 2));
  1005
+		$this->assertEquals(array(1, 2), Hash::extract($result, '{n}.PaginatorCustomPost.id'));
1006 1006
 
1007 1007
 		$result = $Controller->params['paging']['PaginatorCustomPost'];
1008 1008
 		$this->assertEquals(2, $result['current']);
20  lib/Cake/Test/Case/Model/Behavior/ContainableBehaviorTest.php
@@ -92,7 +92,7 @@ public function testContainments() {
92 92
 					'Category' => 'name'
93 93
 				)
94 94
 		)));
95  
-		$this->assertEquals(array('id'), Set::extract('/ArticleFeatured/keep/Featured/fields', $r));
  95
+		$this->assertEquals(array('id'), Hash::extract($r, 'ArticleFeatured.keep.Featured.fields'));
96 96
 
97 97
 		$r = $this->_containments($this->Article, array(
98 98
 			'Comment' => array(
@@ -109,29 +109,29 @@ public function testContainments() {
109 109
 		$this->assertTrue(Set::matches('/User', $r));
110 110
 		$this->assertTrue(Set::matches('/Article/keep/Comment', $r));
111 111
 		$this->assertTrue(Set::matches('/Article/keep/User', $r));
112  
-		$this->assertEquals(array('comment', 'published'), Set::extract('/Article/keep/Comment/fields', $r));
113  
-		$this->assertEquals(array('user'), Set::extract('/Article/keep/User/fields', $r));
  112
+		$this->assertEquals(array('comment', 'published'), Hash::extract($r, 'Article.keep.Comment.fields'));
  113
+		$this->assertEquals(array('user'), Hash::extract($r, 'Article.keep.User.fields'));
114 114
 		$this->assertTrue(Set::matches('/Comment/keep/Attachment', $r));
115  
-		$this->assertEquals(array('attachment'), Set::extract('/Comment/keep/Attachment/fields', $r));
  115
+		$this->assertEquals(array('attachment'), Hash::extract($r, 'Comment.keep.Attachment.fields'));
116 116
 
117 117
 		$r = $this->_containments($this->Article, array('Comment' => array('limit' => 1)));
118 118
 		$this->assertEquals(array('Comment', 'Article'), array_keys($r));
119  
-		$result = Set::extract('/Comment/keep', $r);
  119
+		$result = Hash::extract($r, 'Comment[keep]');
120 120
 		$this->assertEquals(array('keep' => array()), array_shift($result));
121 121
 		$this->assertTrue(Set::matches('/Article/keep/Comment', $r));
122  
-		$result = Set::extract('/Article/keep/Comment/.', $r);
  122
+		$result = Hash::extract($r, 'Article.keep');
123 123
 		$this->assertEquals(array('limit' => 1), array_shift($result));
124 124
 
125 125
 		$r = $this->_containments($this->Article, array('Comment.User'));
126 126
 		$this->assertEquals(array('User', 'Comment', 'Article'), array_keys($r));
127 127
 
128  
-		$result = Set::extract('/User/keep', $r);
  128
+		$result = Hash::extract($r, 'User[keep]');
129 129
 		$this->assertEquals(array('keep' => array()), array_shift($result));
130 130
 
131  
-		$result = Set::extract('/Comment/keep', $r);
  131
+		$result = Hash::extract($r, 'Comment[keep]');
132 132
 		$this->assertEquals(array('keep' => array('User' => array())), array_shift($result));
133 133
 
134  
-		$result = Set::extract('/Article/keep', $r);
  134
+		$result = Hash::extract($r, 'Article[keep]');
135 135
 		$this->assertEquals(array('keep' => array('Comment' => array())), array_shift($result));
136 136
 
137 137
 		$r = $this->_containments($this->Tag, array('Article' => array('User' => array('Comment' => array(
@@ -192,7 +192,7 @@ public function testBeforeFind() {
192 192
 		$this->assertFalse(Set::matches('/Comment[user_id!=2]', $r));
193 193
 
194 194
 		$r = $this->Article->find('all', array('contain' => 'Comment.id DESC'));
195  
-		$ids = $descIds = Set::extract('/Comment[1]/id', $r);
  195
+		$ids = $descIds = Hash::extract($r, 'Comment[1].id');
196 196
 		rsort($descIds);
197 197
 		$this->assertEquals($ids, $descIds);
198 198
 
8  lib/Cake/Test/Case/Model/Behavior/TreeBehaviorScopedTest.php
@@ -140,8 +140,8 @@ public function testMoveUpWithScope() {
140 140
 
141 141
 		$this->Ad->id = 4;
142 142
 		$result = $this->Ad->children();
143  
-		$this->assertEquals(array(6, 5), Set::extract('/Ad/id', $result));
144  
-		$this->assertEquals(array(2, 2), Set::extract('/Campaign/id', $result));
  143
+		$this->assertEquals(array(6, 5), Hash::extract($result, '{n}.Ad.id'));
  144
+		$this->assertEquals(array(2, 2), Hash::extract($result, '{n}.Campaign.id'));
145 145
 	}
146 146
 
147 147
 /**
@@ -156,8 +156,8 @@ public function testMoveDownWithScope() {
156 156
 
157 157
 		$this->Ad->id = 4;
158 158
 		$result = $this->Ad->children();
159  
-		$this->assertEquals(array(5, 6), Set::extract('/Ad/id', $result));
160  
-		$this->assertEquals(array(2, 2), Set::extract('/Campaign/id', $result));
  159
+		$this->assertEquals(array(5, 6), Hash::extract($result, '{n}.Ad.id'));
  160
+		$this->assertEquals(array(2, 2), Hash::extract($result, '{n}.Campaign.id'));
161 161
 	}
162 162
 
163 163
 /**
14  lib/Cake/Test/Case/Model/Datasource/DboSourceTest.php
@@ -617,7 +617,7 @@ public function testLog() {
617 617
 		$this->testDb->logQuery('Query 2');
618 618
 
619 619
 		$log = $this->testDb->getLog(false, false);
620  
-		$result = Set::extract($log['log'], '/query');
  620
+		$result = Hash::extract($log['log'], '{n}.query');
621 621
 		$expected = array('Query 1', 'Query 2');
622 622
 		$this->assertEquals($expected, $result);
623 623
 
@@ -836,10 +836,10 @@ public function testTransactionLogging() {
836 836
 		$log = $db->getLog();
837 837
 		$this->assertEquals($expected, $log['log'][0]);
838 838
 	}
839  
-	
  839
+
840 840
 /**
841  
- * Test build statement with some fields missing 
842  
- * 
  841
+ * Test build statement with some fields missing
  842
+ *
843 843
  * @return void
844 844
  */
845 845
 	public function testBuildStatementDefaults() {
@@ -850,13 +850,13 @@ public function testBuildStatementDefaults() {
850 850
 			array(
851 851
 				'fields' => array('DISTINCT(AssetsTag.asset_id)'),
852 852
 				'table' => "assets_tags",
853  
-				'alias'=>"AssetsTag",                                          
  853
+				'alias'=>"AssetsTag",
854 854
 				'conditions' => array("Tag.name"=>'foo bar'),
855  
-				'limit' => null,         
  855
+				'limit' => null,
856 856
 				'group' => "AssetsTag.asset_id"
857 857
 			),
858 858
 			$this->Model
859 859
 		);
860 860
 	}
861  
-	
  861
+
862 862
 }
9  lib/Cake/Test/Case/Model/ModelCrossSchemaHabtmTest.php
@@ -110,7 +110,7 @@ public function testHabtmFind() {
110 110
 			),
111 111
 		));
112 112
 		$this->assertEquals(4, count($players));
113  
-		$wizards = Set::extract('/Guild[name=Wizards]', $players);
  113
+		$wizards = Hash::extract($players, '{n}.Guild.{n}[name=Wizards]');
114 114
 		$this->assertEquals(1, count($wizards));
115 115
 
116 116
 		$players = $Player->find('all', array(
@@ -120,7 +120,7 @@ public function testHabtmFind() {
120 120
 			),
121 121
 		));
122 122
 		$this->assertEquals(1, count($players));
123  
-		$wizards = Set::extract('/Guild', $players);
  123
+		$wizards = Hash::extract($players, '{n}.Guild.{n}');
124 124
 		$this->assertEquals(2, count($wizards));
125 125
 	}
126 126
 
@@ -163,8 +163,7 @@ public function testHabtmSave() {
163 163
 				),
164 164
 			),
165 165
 		));
166  
-
167  
-		$rangers = Set::extract('/Guild[name=Rangers]', $players);
  166
+		$rangers = Hash::extract($players, '{n}.Guild.{n}[name=Rangers]');
168 167
 		$this->assertEquals(2, count($rangers));
169 168
 	}
170 169
 
@@ -227,7 +226,7 @@ public function testHabtmWithThreeDatabases() {
227 226
 				'Player.id' => 10,
228 227
 			)
229 228
 		));
230  
-		$spongeBobsArmors = Set::extract('/Armor', $spongebob);
  229
+		$spongeBobsArmors = Hash::extract($spongebob, '{n}.Armor.{n}');
231 230
 		$this->assertEquals(4, count($spongeBobsArmors));
232 231
 	}
233 232
 }
21  lib/Cake/Test/Case/Model/ModelIntegrationTest.php
@@ -456,7 +456,7 @@ public function testCrossDatabaseJoins() {
456 456
 		$result = $TestModel->find('all');
457 457
 		$this->assertEquals($expected, $result);
458 458
 
459  
-		$result = Set::extract($TestModel->User->find('all'), '{n}.User.id');
  459
+		$result = Hash::extract($TestModel->User->find('all'), '{n}.User.id');
460 460
 		$this->assertEquals(array('1', '2', '3', '4'), $result);
461 461
 		$this->assertEquals($expected, $TestModel->find('all'));
462 462
 
@@ -836,14 +836,14 @@ public function testHABTMKeepExistingWithThreeDbs() {
836 836
 
837 837
 		$players = $Player->find('all');
838 838
 		$this->assertEquals(4 , count($players));
839  
-		$playersGuilds = Set::extract('/Guild/GuildsPlayer', $players);
  839
+		$playersGuilds = Hash::extract($players, '{n}.Guild.{n}.GuildsPlayer');
840 840
 		$this->assertEquals(3 , count($playersGuilds));
841  
-		$playersArmors = Set::extract('/Armor/ArmorsPlayer', $players);
  841
+		$playersArmors = Hash::extract($players, '{n}.Armor.{n}.ArmorsPlayer');
842 842
 		$this->assertEquals(3 , count($playersArmors));
843 843
 		unset($players);
844 844
 
845 845
 		$larry = $Player->findByName('larry');
846  
-		$larrysArmor = Set::extract('/Armor/ArmorsPlayer', $larry);
  846
+		$larrysArmor = Hash::extract($larry, 'Armor.{n}.ArmorsPlayer');
847 847
 		$this->assertEquals(1 , count($larrysArmor));
848 848
 
849 849
 		$larry['Guild']['Guild'] = array(1, 3); // larry joins another guild
@@ -852,21 +852,20 @@ public function testHABTMKeepExistingWithThreeDbs() {
852 852
 		unset($larry);
853 853
 
854 854
 		$larry = $Player->findByName('larry');
855  
-		$larrysGuild = Set::extract('/Guild/GuildsPlayer', $larry);
  855
+		$larrysGuild = Hash::extract($larry, 'Guild.{n}.GuildsPlayer');
856 856
 		$this->assertEquals(2 , count($larrysGuild));
857  
-		$larrysArmor = Set::extract('/Armor/ArmorsPlayer', $larry);
  857
+		$larrysArmor = Hash::extract($larry, 'Armor.{n}.ArmorsPlayer');
858 858
 		$this->assertEquals(2 , count($larrysArmor));
859 859
 
860  
-		$larrysArmorsPlayersIds = Set::extract('/Armor/ArmorsPlayer/id', $larry);
  860
+		$larrysArmorsPlayersIds = Hash::extract($larry, 'Armor.{n}.ArmorsPlayer.id');
861 861
 
862 862
 		$Player->ArmorsPlayer->id = 3;
863 863
 		$Player->ArmorsPlayer->saveField('broken', true); // larry's cloak broke
864 864
 
865 865
 		$larry = $Player->findByName('larry');
866  
-		$larrysArmor = Set::extract('/Armor/ArmorsPlayer', $larry);
867  
-		$larrysCloak = Set::extract('/ArmorsPlayer[armor_id=3]', $larrysArmor);
  866
+		$larrysCloak = Hash::extract($larry, 'Armor.{n}.ArmorsPlayer[armor_id=3]', $larry);
868 867
 		$this->assertNotEmpty($larrysCloak);
869  
-		$this->assertTrue($larrysCloak[0]['ArmorsPlayer']['broken']); // still broken
  868
+		$this->assertTrue($larrysCloak[0]['broken']); // still broken
870 869
 	}
871 870
 
872 871
 /**
@@ -898,7 +897,7 @@ public function testSchema() {
898 897
 		$this->assertEquals($columns, array_keys($result));
899 898
 
900 899
 		$types = array('integer', 'integer', 'string', 'text', 'string', 'datetime', 'datetime');
901  
-		$this->assertEquals(Set::extract(array_values($result), '{n}.type'), $types);
  900
+		$this->assertEquals(Hash::extract(array_values($result), '{n}.type'), $types);
902 901
 
903 902
 		$result = $Post->schema('body');
904 903
 		$this->assertEquals('text', $result['type']);
10  lib/Cake/Test/Case/Model/ModelReadTest.php
@@ -80,7 +80,7 @@ public function testFetchingNonUniqueFKJoinTableRecords() {
80 80
 
81 81
 		$this->assertEquals(2, count($result['SomethingElse']));
82 82
 
83  
-		$doomed = Set::extract('/JoinThing/doomed', $result['SomethingElse']);
  83
+		$doomed = Hash::extract($result['SomethingElse'], '{n}.JoinThing.doomed');
84 84
 		$this->assertTrue(in_array(true, $doomed));
85 85
 		$this->assertTrue(in_array(false, $doomed));
86 86
 	}
@@ -5028,19 +5028,19 @@ public function testCallbackDisabling() {
5028 5028
 		$this->loadFixtures('Author');
5029 5029
 		$TestModel = new ModifiedAuthor();
5030 5030
 
5031  
-		$result = Set::extract($TestModel->find('all'), '/Author/user');
  5031
+		$result = Hash::extract($TestModel->find('all'), '{n}.Author.user');
5032 5032
 		$expected = array('mariano (CakePHP)', 'nate (CakePHP)', 'larry (CakePHP)', 'garrett (CakePHP)');
5033 5033
 		$this->assertEquals($expected, $result);
5034 5034
 
5035  
-		$result = Set::extract($TestModel->find('all', array('callbacks' => 'after')), '/Author/user');
  5035
+		$result = Hash::extract($TestModel->find('all', array('callbacks' => 'after')), '{n}.Author.user');
5036 5036
 		$expected = array('mariano (CakePHP)', 'nate (CakePHP)', 'larry (CakePHP)', 'garrett (CakePHP)');
5037 5037
 		$this->assertEquals($expected, $result);
5038 5038
 
5039  
-		$result = Set::extract($TestModel->find('all', array('callbacks' => 'before')), '/Author/user');
  5039
+		$result = Hash::extract($TestModel->find('all', array('callbacks' => 'before')), '{n}.Author.user');
5040 5040
 		$expected = array('mariano', 'nate', 'larry', 'garrett');
5041 5041
 		$this->assertEquals($expected, $result);
5042 5042
 
5043  
-		$result = Set::extract($TestModel->find('all', array('callbacks' => false)), '/Author/user');
  5043
+		$result = Hash::extract($TestModel->find('all', array('callbacks' => false)), '{n}.Author.user');
5044 5044
 		$expected = array('mariano', 'nate', 'larry', 'garrett');
5045 5045
 		$this->assertEquals($expected, $result);
5046 5046
 	}
27  lib/Cake/Test/Case/Model/ModelWriteTest.php
@@ -632,11 +632,11 @@ public function testSaveField() {
632 632
 		$Node = new Node();
633 633
 		$Node->set('id', 1);
634 634
 		$result = $Node->read();
635  
-		$this->assertEquals(array('Second'), Set::extract('/ParentNode/name', $result));
  635
+		$this->assertEquals(array('Second'), Hash::extract($result, 'ParentNode.{n}.name'));
636 636
 
637 637
 		$Node->saveField('state', 10);
638 638
 		$result = $Node->read();
639  
-		$this->assertEquals(array('Second'), Set::extract('/ParentNode/name', $result));
  639
+		$this->assertEquals(array('Second'), Hash::extract($result, 'ParentNode.{n}.name'));
640 640
 	}
641 641
 
642 642
 /**
@@ -1570,9 +1570,9 @@ public function testSaveHabtm() {
1570 1570
 		$TestModel->save($data);
1571 1571
 		$result = $TestModel->read(null, 1);
1572 1572
 		$expected = array(4, 5);
1573  
-		$this->assertEquals($expected, Set::extract('/JoinC/JoinAsJoinC/id', $result));
  1573
+		$this->assertEquals($expected, Hash::extract($result, 'JoinC.{n}.JoinAsJoinC.id'));
1574 1574
 		$expected = array('new record', 'new record');
1575  
-		$this->assertEquals($expected, Set::extract('/JoinC/JoinAsJoinC/other', $result));
  1575
+		$this->assertEquals($expected, Hash::extract($result, 'JoinC.{n}.JoinAsJoinC.other'));
1576 1576
 	}
1577 1577
 
1578 1578
 /**
@@ -4492,7 +4492,7 @@ public function testSaveAllValidationOnly() {
4492 4492
  * @return void
4493 4493
  */
4494 4494
 	public function testSaveAllValidateFirst() {
4495  
-		$this->loadFixtures('Article', 'Comment', 'Attachment');
  4495
+		$this->loadFixtures('Article', 'Comment', 'Attachment', 'User', 'ArticlesTag', 'Tag');
4496 4496
 		$model = new Article();
4497 4497
 		$model->deleteAll(true);
4498 4498
 
@@ -4539,7 +4539,7 @@ public function testSaveAllValidateFirst() {
4539 4539
 
4540 4540
 		$result = $model->Comment->find('all');
4541 4541
 		$this->assertSame(count($result), 1);
4542  
-		$result = Set::extract('/Comment/article_id', $result);
  4542
+		$result = Hash::extract($result, '{n}.Comment.article_id');
4543 4543
 		$this->assertEquals(4, $result[0]);
4544 4544
 
4545 4545
 		$model->deleteAll(true);
@@ -4570,6 +4570,7 @@ public function testSaveAllValidateFirst() {
4570 4570
  * @return void
4571 4571
  */
4572 4572
 	public function testSaveAllValidateFirstAtomicFalse() {
  4573
+		$this->loadFixtures('Something');
4573 4574
 		$Something = new Something();
4574 4575
 		$invalidData = array(
4575 4576
 			array(
@@ -5177,7 +5178,7 @@ public function testSaveAssociatedHasMany() {
5177 5178
 			'First new comment',
5178 5179
 			'Second new comment'
5179 5180
 		);
5180  
-		$this->assertEquals($expected, Set::extract($result['Comment'], '{n}.comment'));
  5181
+		$this->assertEquals($expected, Hash::extract($result['Comment'], '{n}.comment'));
5181 5182
 
5182 5183
 		$result = $TestModel->saveAssociated(
5183 5184
 			array(
@@ -5200,7 +5201,7 @@ public function testSaveAssociatedHasMany() {
5200 5201
 			'Second new comment',
5201 5202
 			'Third new comment'
5202 5203
 		);
5203  
-		$this->assertEquals($expected, Set::extract($result['Comment'], '{n}.comment'));
  5204
+		$this->assertEquals($expected, Hash::extract($result['Comment'], '{n}.comment'));
5204 5205
 
5205 5206
 		$TestModel->beforeSaveReturn = false;
5206 5207
 		$result = $TestModel->saveAssociated(
@@ -5224,7 +5225,7 @@ public function testSaveAssociatedHasMany() {
5224 5225
 			'Second new comment',
5225 5226
 			'Third new comment'
5226 5227
 		);
5227  
-		$this->assertEquals($expected, Set::extract($result['Comment'], '{n}.comment'));
  5228
+		$this->assertEquals($expected, Hash::extract($result['Comment'], '{n}.comment'));
5228 5229
 	}
5229 5230
 
5230 5231
 /**
@@ -5840,7 +5841,7 @@ public function testSaveAssociatedValidateFirst() {
5840 5841
 
5841 5842
 		$result = $model->Comment->find('all');
5842 5843
 		$this->assertSame(count($result), 1);
5843  
-		$result = Set::extract('/Comment/article_id', $result);
  5844
+		$result = Hash::extract($result, '{n}.Comment.article_id');
5844 5845
 		$this->assertEquals(4, $result[0]);
5845 5846
 
5846 5847
 		$model->deleteAll(true);
@@ -6066,15 +6067,15 @@ public function testUpdateWithCalculation() {
6066 6067
 		));
6067 6068
 		$this->assertFalse(empty($result));
6068 6069
 
6069  
-		$result = Set::extract('/DataTest/count', $model->find('all', array('fields' => 'count')));
  6070
+		$result = Hash::extract($model->find('all', array('fields' => 'count')), '{n}.DataTest.count');
6070 6071
 		$this->assertEquals(array(5, 3, 4, 1), $result);
6071 6072
 
6072 6073
 		$this->assertTrue($model->updateAll(array('count' => 'count + 2')));
6073  
-		$result = Set::extract('/DataTest/count', $model->find('all', array('fields' => 'count')));
  6074
+		$result = Hash::extract($model->find('all', array('fields' => 'count')), '{n}.DataTest.count');
6074 6075
 		$this->assertEquals(array(7, 5, 6, 3), $result);
6075 6076
 
6076 6077
 		$this->assertTrue($model->updateAll(array('DataTest.count' => 'DataTest.count - 1')));
6077  
-		$result = Set::extract('/DataTest/count', $model->find('all', array('fields' => 'count')));
  6078
+		$result = Hash::extract($model->find('all', array('fields' => 'count')), '{n}.DataTest.count');
6078 6079
 		$this->assertEquals(array(6, 4, 5, 2), $result);
6079 6080
 	}
6080 6081
 
3  lib/Cake/Test/Case/Utility/HashTest.php
@@ -1043,6 +1043,9 @@ public function testSortNumeric() {
1043 1043
  * @return void
1044 1044
  */
1045 1045
 	public function testSortNatural() {
  1046
+		if (version_compare(PHP_VERSION, '5.4.0', '<')) {
  1047
+            $this->markTestSkipped('SORT_NATURAL is available since PHP 5.4.');
  1048
+        }
1046 1049
 		$items = array(
1047 1050
 			array('Item' => array('image' => 'img1.jpg')),
1048 1051
 			array('Item' => array('image' => 'img99.jpg')),
7  lib/Cake/Utility/Hash.php
@@ -379,7 +379,7 @@ public static function combine(array $data, $keyPath, $valuePath = null, $groupP
379 379
 /**
380 380
  * Returns a formated series of values extracted from `$data`, using
381 381
  * `$format` as the format and `$paths` as the values to extract.
382  
- * 
  382
+ *
383 383
  * Usage:
384 384
  *
385 385
  * {{{
@@ -486,7 +486,7 @@ public static function check(array $data, $path) {
486 486
  * Recursively filters a data set.
487 487
  *
488 488
  * @param array $data Either an array to filter, or value when in callback
489  
- * @param callable $callback A function to filter the data with.  Defaults to 
  489
+ * @param callable $callback A function to filter the data with.  Defaults to
490 490
  *   `self::_filter()` Which strips out all non-zero empty values.
491 491
  * @return array Filtered array
492 492
  * @link http://book.cakephp.org/2.0/en/core-utility-libraries/hash.html#Hash::filter
@@ -757,6 +757,9 @@ public static function sort(array $data, $path, $dir, $type = 'regular') {
757 757
 
758 758
 		$dir = strtolower($dir);
759 759
 		$type = strtolower($type);
  760
+		if ($type == 'natural' && version_compare(PHP_VERSION, '5.4.0', '<')) {
  761
+			$type == 'regular';
  762
+		}
760 763
 		if ($dir === 'asc') {
761 764
 			$dir = SORT_ASC;
762 765
 		} else {

0 notes on commit eeec362

Please sign in to comment.
Something went wrong with that request. Please try again.