mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
FIX LastPage method returns true if TotalPages equals 0
This commit is contained in:
parent
5303e08d34
commit
ad9df97626
@ -416,7 +416,7 @@ class PaginatedList extends ListDecorator
|
||||
*/
|
||||
public function LastPage()
|
||||
{
|
||||
return $this->CurrentPage() == $this->TotalPages();
|
||||
return $this->CurrentPage() >= $this->TotalPages();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user