Skip to content

Commit 1b9dfcc

Browse files
authored
fix: count TraversablePaginator (#6611)
1 parent 9edacab commit 1b9dfcc

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

src/State/Pagination/TraversablePaginator.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ public function count(): int
6868
return (int) ceil($this->totalItems);
6969
}
7070

71+
if ($this->totalItems === $this->itemsPerPage) {
72+
return (int) ceil($this->totalItems);
73+
}
74+
7175
return $this->totalItems % $this->itemsPerPage;
7276
}
7377

tests/State/Pagination/TraversablePaginatorTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ public static function initializeProvider(): array
5050
'Empty results' => [[], 1, 2, 0, 1, 0],
5151
'0 items per page' => [[0, 1, 2, 3], 1, 0, 4, 1, 4],
5252
'Total items less than items per page' => [[0, 1, 2], 1, 4, 3, 1, 3],
53+
'Only one result' => [[0], 1, 1, 1, 1, 1],
54+
'Same result number than total page' => [[0, 2, 3], 1, 3, 3, 1, 3],
5355
];
5456
}
5557
}

0 commit comments

Comments
 (0)