Skip to content

Commit

Permalink
Add a test for Hash::sort()
Browse files Browse the repository at this point in the history
Closes #3956
  • Loading branch information
markstory committed Aug 17, 2013
1 parent 005699e commit a140b30
Showing 1 changed file with 33 additions and 2 deletions.
35 changes: 33 additions & 2 deletions lib/Cake/Test/Case/Utility/HashTest.php
Expand Up @@ -1042,7 +1042,7 @@ public function testSort() {
1 => array('Person' => array('name' => 'Jeff')),
);
$a = Hash::sort($a, '{n}.Person.name', 'ASC', 'STRING');
$this->assertEquals($a, $b);
$this->assertSame($a, $b);

$names = array(
array('employees' => array(
Expand All @@ -1065,7 +1065,38 @@ public function testSort() {
array('employees' => array(array('name' => array()))),
array('employees' => array(array('name' => array())))
);
$this->assertEquals($expected, $result);
$this->assertSame($expected, $result);

$a = array(
'SU' => array(
'total_fulfillable' => (int) 2
),
'AA' => array(
'total_fulfillable' => (int) 1
),
'LX' => array(
'total_fulfillable' => (int) 0
),
'BL' => array(
'total_fulfillable' => (int) 3
),
);
$expected = array(
'LX' => array(
'total_fulfillable' => (int) 0
),
'AA' => array(
'total_fulfillable' => (int) 1
),
'SU' => array(
'total_fulfillable' => (int) 2
),
'BL' => array(
'total_fulfillable' => (int) 3
),
);
$result = Hash::sort($a, '{s}.total_fulfillable', 'asc');
$this->assertSame($expected, $result);
}

/**
Expand Down

0 comments on commit a140b30

Please sign in to comment.