diff --git a/src/Datagrid/SimplePager.php b/src/Datagrid/SimplePager.php index 890d6626a09..8eeb0464ebc 100644 --- a/src/Datagrid/SimplePager.php +++ b/src/Datagrid/SimplePager.php @@ -119,7 +119,7 @@ public function init() $this->initializeIterator(); $t = (int) ceil($this->thresholdCount / $this->getMaxPerPage()) + $this->getPage() - 1; - $this->setLastPage($t); + $this->setLastPage(\max(1, $t)); } } diff --git a/tests/Datagrid/SimplePagerTest.php b/tests/Datagrid/SimplePagerTest.php index 708ed17da03..95efb60cb41 100644 --- a/tests/Datagrid/SimplePagerTest.php +++ b/tests/Datagrid/SimplePagerTest.php @@ -112,7 +112,8 @@ public function testNoPagesForNoResults() $this->pager->setQuery($this->proxyQuery); $this->pager->init(); - $this->AssertEquals(0, $this->pager->getLastPage()); + $this->assertEquals(1, $this->pager->getLastPage()); + $this->assertEquals(0, $this->pager->getNbResults()); } public function testInitNoQuery()