Unexpected behavior og paginate()->onEachSide()->links() #40998
Unanswered
ReneBechKorsgaard
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
So I have been experiencing strange behaviour of the paginator links() function where the expected number of elements returned in the links object does not match the parameter sent to onEachSide. To describe and test the problem I have written the following test:
This test fails with:
Failed asserting that 10 matches expected 3 - /var/www/tests/Unit/Support/PaginatorTest.php:20
and
Failed asserting that 2 matches expected 3 - /var/www/tests/Unit/Support/PaginatorTest.php:22
At first glance it looks as though onEachSide is not being respected, but if you change the parameter passed to the function it actually does change the returned elements, but not in the way you would expect. Let me provide you with a few exampels:
3: dd($users->onEachSide(-1)->links()->elements):
So onEachSide actually changes the first element og the elements array, but not in the expected manner, and it does not change the last element of the elements array.
I have run this test in several different projects all with the same result.
Am I right in this not being this expected behaviour, and if so can anyone else replicate the same issue? If so, then I think this might be a bug in the framework.
Beta Was this translation helpful? Give feedback.
All reactions