Skip to content

Commit

Permalink
Add test for max page count value
Browse files Browse the repository at this point in the history
  • Loading branch information
dereuromark committed Aug 17, 2017
1 parent 4886b36 commit 009cf4e
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions tests/TestCase/Controller/Component/PaginatorComponentTest.php
Expand Up @@ -634,6 +634,37 @@ public function testValidateSortInvalidDirection()
$this->assertEquals('asc', $result['order']['model.something']);
}

/**
* Test empty pagination result.
*
* @return void
*/
public function testEmptyPaginationResult()
{
$this->loadFixtures('Posts');

$table = TableRegistry::get('PaginatorPosts');
$table->deleteAll('1=1');

$this->Paginator->paginate($table);

$this->assertEquals(
0,
$this->request->params['paging']['PaginatorPosts']['count'],
'Count should be 0'
);
$this->assertEquals(
1,
$this->request->params['paging']['PaginatorPosts']['page'],
'Page number should not be 0'
);
$this->assertEquals(
1,
$this->request->params['paging']['PaginatorPosts']['pageCount'],
'Page count number should not be 0'
);
}

/**
* Test that a really large page number gets clamped to the max page size.
*
Expand Down

0 comments on commit 009cf4e

Please sign in to comment.