Skip to content
Browse files

Merge pull request #317 from fzaninotto/fix_model_pager

Fix PropelModelPager::getLastPage() return type.
  • Loading branch information...
2 parents 14b9ac1 + 45f2924 commit 46c3f8616154519cd76ee2a10ba31cd9535b7269 @willdurand willdurand committed
Showing with 9 additions and 1 deletion.
  1. +1 −1 runtime/lib/util/PropelModelPager.php
  2. +8 −0 test/testsuite/runtime/util/PropelModelPagerTest.php
View
2 runtime/lib/util/PropelModelPager.php
@@ -71,7 +71,7 @@ public function init($con = null)
if (($this->getPage() == 0 || $this->getMaxPerPage() == 0)) {
$this->setLastPage(0);
} else {
- $this->setLastPage(ceil($this->getNbResults() / $this->getMaxPerPage()));
+ $this->setLastPage((int)ceil($this->getNbResults() / $this->getMaxPerPage()));
$offset = ($this->getPage() - 1) * $this->getMaxPerPage();
$q->offset($offset);
View
8 test/testsuite/runtime/util/PropelModelPagerTest.php
@@ -158,6 +158,14 @@ public function testIsLastPage()
$this->assertTrue($pager->isLastPage(), 'isLastPage() returns true on the last page');
}
+ public function testGetLastPage()
+ {
+ $this->createBooks(5);
+ $pager = $this->getPager(4, 1);
+ $this->assertEquals(2, $pager->getLastPage(), 'getLastPage() returns the last page number');
+ $this->assertInternalType('integer', $pager->getLastPage(), 'getLastPage() returns an integer');
+ }
+
public function testIsFirstOnFirstPage()
{
$this->createBooks(5);

0 comments on commit 46c3f86

Please sign in to comment.
Something went wrong with that request. Please try again.