mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge pull request #10829 from creative-commoners/pulls/4.13/fix-last-page
FIX LastPage method returns true if TotalPages equals 0
This commit is contained in:
commit
ab4802caaf
@ -416,7 +416,7 @@ class PaginatedList extends ListDecorator
|
|||||||
*/
|
*/
|
||||||
public function LastPage()
|
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 = new PaginatedList(new ArrayList());
|
||||||
$list->setTotalItems(50);
|
$list->setTotalItems(50);
|
||||||
|
|
||||||
|
$this->assertFalse($list->LastPage());
|
||||||
|
$list->setCurrentPage(4);
|
||||||
$this->assertFalse($list->LastPage());
|
$this->assertFalse($list->LastPage());
|
||||||
$list->setCurrentPage(5);
|
$list->setCurrentPage(5);
|
||||||
$this->assertTrue($list->LastPage());
|
$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()
|
public function testNotLastPage()
|
||||||
|
Loading…
Reference in New Issue
Block a user