FIX LastPage method returns true if TotalPages equals 0

This commit is contained in:
Sabina Talipova 2023-06-22 08:42:49 +12:00
parent 5303e08d34
commit ad9df97626
2 changed files with 12 additions and 1 deletions

View File

@ -416,7 +416,7 @@ class PaginatedList extends ListDecorator
*/
public function LastPage()
{
return $this->CurrentPage() == $this->TotalPages();
return $this->CurrentPage() >= $this->TotalPages();
}
/**

View File

@ -303,9 +303,20 @@ class PaginatedListTest extends SapphireTest
$list = new PaginatedList(new ArrayList());
$list->setTotalItems(50);
$this->assertFalse($list->LastPage());
$list->setCurrentPage(4);
$this->assertFalse($list->LastPage());
$list->setCurrentPage(5);
$this->assertTrue($list->LastPage());
$list->setCurrentPage(6);
$this->assertTrue($list->LastPage());
$emptyList = new PaginatedList(new ArrayList());
$emptyList->setTotalItems(0);
$this->assertTrue($emptyList->LastPage());
$emptyList->setCurrentPage(1);
$this->assertTrue($emptyList->LastPage());
}
public function testNotLastPage()