Skip to content

Commit

Permalink
Add test case.
Browse files Browse the repository at this point in the history
  • Loading branch information
dereuromark committed Nov 10, 2018
1 parent 756cf7e commit c2df1fb
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions tests/TestCase/Datasource/PaginatorTest.php
Expand Up @@ -247,6 +247,43 @@ public function testDefaultPaginateParams()
$this->Paginator->paginate($table, [], $settings); $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 * test that default sort and default direction are injected into request
* *
Expand Down

0 comments on commit c2df1fb

Please sign in to comment.