From c2df1fb71aa06e0daa484561d21f5f34f80d670e Mon Sep 17 00:00:00 2001 From: mscherer Date: Sat, 10 Nov 2018 22:55:25 +0100 Subject: [PATCH] Add test case. --- tests/TestCase/Datasource/PaginatorTest.php | 37 +++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/tests/TestCase/Datasource/PaginatorTest.php b/tests/TestCase/Datasource/PaginatorTest.php index 3d50d1a85d6..7311be357aa 100644 --- a/tests/TestCase/Datasource/PaginatorTest.php +++ b/tests/TestCase/Datasource/PaginatorTest.php @@ -247,6 +247,43 @@ public function testDefaultPaginateParams() $this->Paginator->paginate($table, [], $settings); } + /** + * Tests that flat default pagination parameters work for multi order. + * + * @return void + */ + public function testDefaultPaginateParamsMultiOrder() + { + $settings = [ + 'order' => ['PaginatorPosts.id' => 'DESC', 'PaginatorPosts.title' => 'ASC'], + ]; + + $table = $this->_getMockPosts(['query']); + $query = $this->_getMockFindQuery(); + + $table->expects($this->once()) + ->method('query') + ->will($this->returnValue($query)); + + $query->expects($this->once()) + ->method('applyOptions') + ->with([ + 'limit' => 20, + 'page' => 1, + 'order' => $settings['order'], + 'whitelist' => ['limit', 'sort', 'page', 'direction'], + 'scope' => null, + 'sort' => null, + ]); + + $this->Paginator->paginate($table, [], $settings); + + $pagingParams = $this->Paginator->getPagingParams(); + $this->assertNull($pagingParams['PaginatorPosts']['direction']); + $this->assertFalse($pagingParams['PaginatorPosts']['sortDefault']); + $this->assertFalse($pagingParams['PaginatorPosts']['directionDefault']); + } + /** * test that default sort and default direction are injected into request *