From 8314d60995c2b599e68a3fcf883cfe4721d93baf Mon Sep 17 00:00:00 2001 From: Logan Bailey Date: Tue, 4 Aug 2015 09:07:52 -0700 Subject: [PATCH] Adds Unit Test For Multi Column Sort --- .../Collections/ArrayCollectionTest.php | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tests/Doctrine/Tests/Common/Collections/ArrayCollectionTest.php b/tests/Doctrine/Tests/Common/Collections/ArrayCollectionTest.php index 1b8a906fd..e935418bd 100644 --- a/tests/Doctrine/Tests/Common/Collections/ArrayCollectionTest.php +++ b/tests/Doctrine/Tests/Common/Collections/ArrayCollectionTest.php @@ -293,4 +293,26 @@ public function testMatchingWithSortingPreservesyKeys() ->toArray() ); } + + public function testMultiColumnSortAppliesAllSorts() + { + $collection = new ArrayCollection(array( + array('foo' => 1, 'bar' => 2), + array('foo' => 2, 'bar' => 4), + array('foo' => 2, 'bar' => 3) + )); + + $expected = array( + 1 => array('foo' => 2, 'bar' => 4), + 2 => array('foo' => 2, 'bar' => 3), + 0 => array('foo' => 1, 'bar' => 2) + ); + + $this->assertSame( + $expected, + $collection + ->matching(new Criteria(null, array('foo' => Criteria::DESC, 'bar' => Criteria::DESC))) + ->toArray() + ); + } }