Skip to content

Commit a140b30

Browse files
committed
Add a test for Hash::sort()
Closes #3956
1 parent 005699e commit a140b30

File tree

1 file changed

+33
-2
lines changed

1 file changed

+33
-2
lines changed

lib/Cake/Test/Case/Utility/HashTest.php

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1042,7 +1042,7 @@ public function testSort() {
10421042
1 => array('Person' => array('name' => 'Jeff')),
10431043
);
10441044
$a = Hash::sort($a, '{n}.Person.name', 'ASC', 'STRING');
1045-
$this->assertEquals($a, $b);
1045+
$this->assertSame($a, $b);
10461046

10471047
$names = array(
10481048
array('employees' => array(
@@ -1065,7 +1065,38 @@ public function testSort() {
10651065
array('employees' => array(array('name' => array()))),
10661066
array('employees' => array(array('name' => array())))
10671067
);
1068-
$this->assertEquals($expected, $result);
1068+
$this->assertSame($expected, $result);
1069+
1070+
$a = array(
1071+
'SU' => array(
1072+
'total_fulfillable' => (int) 2
1073+
),
1074+
'AA' => array(
1075+
'total_fulfillable' => (int) 1
1076+
),
1077+
'LX' => array(
1078+
'total_fulfillable' => (int) 0
1079+
),
1080+
'BL' => array(
1081+
'total_fulfillable' => (int) 3
1082+
),
1083+
);
1084+
$expected = array(
1085+
'LX' => array(
1086+
'total_fulfillable' => (int) 0
1087+
),
1088+
'AA' => array(
1089+
'total_fulfillable' => (int) 1
1090+
),
1091+
'SU' => array(
1092+
'total_fulfillable' => (int) 2
1093+
),
1094+
'BL' => array(
1095+
'total_fulfillable' => (int) 3
1096+
),
1097+
);
1098+
$result = Hash::sort($a, '{s}.total_fulfillable', 'asc');
1099+
$this->assertSame($expected, $result);
10691100
}
10701101

10711102
/**

0 commit comments

Comments
 (0)