Skip to content

Commit

Permalink
Merge branch '3.3' into 3.4
Browse files Browse the repository at this point in the history
  • Loading branch information
soyuka committed Sep 18, 2024
2 parents 31f7ec2 + 0273d23 commit 70e9b9a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
4 changes: 4 additions & 0 deletions src/State/Pagination/TraversablePaginator.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ public function count(): int
return (int) ceil($this->totalItems);
}

if ($this->totalItems === $this->itemsPerPage) {
return (int) ceil($this->totalItems);
}

return $this->totalItems % $this->itemsPerPage;
}

Expand Down
12 changes: 7 additions & 5 deletions tests/State/Pagination/TraversablePaginatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,13 @@ public function testInitialize(
public static function initializeProvider(): array
{
return [
'First of three pages of 3 items each' => [[0, 1, 2, 3, 4, 5, 6], 1, 3, 7, 3, 3, true],
'Second of two pages of 3 items for the first page and 2 for the second' => [[0, 1, 2, 3, 4], 2, 3, 5, 2, 2, false],
'Empty results' => [[], 1, 2, 0, 1, 0, false],
'0 items per page' => [[0, 1, 2, 3], 1, 0, 4, 1, 4, false],
'Total items less than items per page' => [[0, 1, 2], 1, 4, 3, 1, 3, false],
'First of three pages of 3 items each' => [[0, 1, 2, 3, 4, 5, 6], 1, 3, 7, 3, 3],
'Second of two pages of 3 items for the first page and 2 for the second' => [[0, 1, 2, 3, 4], 2, 3, 5, 2, 2],
'Empty results' => [[], 1, 2, 0, 1, 0],
'0 items per page' => [[0, 1, 2, 3], 1, 0, 4, 1, 4],
'Total items less than items per page' => [[0, 1, 2], 1, 4, 3, 1, 3],
'Only one result' => [[0], 1, 1, 1, 1, 1],
'Same result number than total page' => [[0, 2, 3], 1, 3, 3, 1, 3],
];
}
}

0 comments on commit 70e9b9a

Please sign in to comment.