Skip to content

Commit

Permalink
Paginator tests
Browse files Browse the repository at this point in the history
  • Loading branch information
timopruesse committed Jun 15, 2017
1 parent 0bbbf05 commit 3dacb73
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/Models/DataComponents/Paginator.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ private function _getEndPage() : int
*/
public function pageCount() : int
{
if ($this->_perPage === 0)
if (empty($this->_perPage))
{
return 1;
}
Expand Down Expand Up @@ -248,7 +248,7 @@ private function _getLastPageUrl() : ? string
*/
protected function _shapeData() : Builder
{
if ($this->_perPage === 0)
if (empty($this->_perPage))
{
return $this->_dataTable->query();
}
Expand Down
4 changes: 3 additions & 1 deletion tests/PaginationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,11 @@ public function has_only_one_page_when_per_page_is_zero()
/** @var Paginator $paginator */
$paginator = new Paginator(0);

DataTable::model(TestModel::class, ['id', 'created_at', 'name'])
$dataTable = DataTable::model(TestModel::class, ['id', 'created_at', 'name'])
->addComponent($paginator);

$dataTable->render();

$this->assertEquals(1, $paginator->pageCount());
}

Expand Down

0 comments on commit 3dacb73

Please sign in to comment.