Skip to content
Permalink
Browse files

Add test case.

  • Loading branch information...
dereuromark committed Nov 10, 2018
1 parent 756cf7e commit c2df1fb71aa06e0daa484561d21f5f34f80d670e
Showing with 37 additions and 0 deletions.
  1. +37 −0 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
*

0 comments on commit c2df1fb

Please sign in to comment.
You can’t perform that action at this time.