mirror of
https://github.com/wiosna-dev/common-library.git
synced 2026-03-12 09:31:51 +01:00
[BaseCollection] Fix incorrectly working limit() method
This commit is contained in:
@@ -2,6 +2,10 @@
|
|||||||
|
|
||||||
Common and useful classes, methods, exceptions etc.
|
Common and useful classes, methods, exceptions etc.
|
||||||
|
|
||||||
|
# 1.1.4
|
||||||
|
|
||||||
|
1. [BaseCollection] Fix incorrectly working limit() method
|
||||||
|
|
||||||
# 1.1.3
|
# 1.1.3
|
||||||
|
|
||||||
1. Move `Renderable` class: `Meritoo\Common` -> `Meritoo\Common\Contract`
|
1. Move `Renderable` class: `Meritoo\Common` -> `Meritoo\Common\Contract`
|
||||||
|
|||||||
@@ -248,7 +248,7 @@ abstract class BaseCollection implements CollectionInterface
|
|||||||
foreach ($result as $index => $element) {
|
foreach ($result as $index => $element) {
|
||||||
$iteration++;
|
$iteration++;
|
||||||
|
|
||||||
if ($iteration < $offset || ($iteration >= $offset && $iteration < $max)) {
|
if ($iteration >= $offset && $iteration < $offset + $max) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -724,33 +724,24 @@ class BaseCollectionTest extends BaseTestCase
|
|||||||
2,
|
2,
|
||||||
];
|
];
|
||||||
|
|
||||||
yield 'Maximum set to 1 & offset smaller than size of collection' => [
|
yield 'Maximum set to 1 & offset set to 2' => [
|
||||||
[
|
[
|
||||||
'lorem',
|
123 => 'dolor',
|
||||||
'ipsum',
|
|
||||||
],
|
],
|
||||||
1,
|
1,
|
||||||
2,
|
2,
|
||||||
];
|
];
|
||||||
|
|
||||||
yield 'Maximum set to 1 & offset equal size of collection' => [
|
yield 'Maximum set to 1 & offset set to 3' => [
|
||||||
[
|
[
|
||||||
'lorem',
|
|
||||||
'ipsum',
|
|
||||||
123 => 'dolor',
|
|
||||||
345 => 'sit',
|
345 => 'sit',
|
||||||
],
|
],
|
||||||
1,
|
1,
|
||||||
4,
|
3,
|
||||||
];
|
];
|
||||||
|
|
||||||
yield 'Maximum set to 1 & offset greater than size of collection' => [
|
yield 'Maximum set to 1 & offset set to 10' => [
|
||||||
[
|
[],
|
||||||
'lorem',
|
|
||||||
'ipsum',
|
|
||||||
123 => 'dolor',
|
|
||||||
345 => 'sit',
|
|
||||||
],
|
|
||||||
1,
|
1,
|
||||||
10,
|
10,
|
||||||
];
|
];
|
||||||
|
|||||||
Reference in New Issue
Block a user