From a140b30435990cd6d2d018726d57e03d60da09f0 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 17 Aug 2013 17:16:33 -0400 Subject: [PATCH] Add a test for Hash::sort() Closes #3956 --- lib/Cake/Test/Case/Utility/HashTest.php | 35 +++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/lib/Cake/Test/Case/Utility/HashTest.php b/lib/Cake/Test/Case/Utility/HashTest.php index fb1b6fc90d0..2c7d56fcbd9 100644 --- a/lib/Cake/Test/Case/Utility/HashTest.php +++ b/lib/Cake/Test/Case/Utility/HashTest.php @@ -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( @@ -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); } /**