Skip to content

Commit 29e90e1

Browse files
test: Add comprehensive test for LazyCollection::after method
This commit adds a test for the LazyCollection after() method covering three key scenarios: - Finding the next item with non-strict comparison - Finding the next item with strict comparison - Finding the next item using a callback function
1 parent e6753fc commit 29e90e1

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

tests/Support/SupportLazyCollectionTest.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,4 +286,30 @@ public function testUniqueDoubleEnumeration()
286286

287287
$this->assertSame([1, 2], $data->all());
288288
}
289+
290+
public function testAfter()
291+
{
292+
$data = new LazyCollection([1, '2', 3, 4]);
293+
294+
// Test finding item after value with non-strict comparison
295+
$result = $data->after(1);
296+
$this->assertSame('2', $result);
297+
298+
// Test with strict comparison
299+
$result = $data->after('2', true);
300+
$this->assertSame(3, $result);
301+
302+
$users = new LazyCollection([
303+
['name' => 'Taylor', 'age' => 35],
304+
['name' => 'Jeffrey', 'age' => 45],
305+
['name' => 'Mohamed', 'age' => 35],
306+
]);
307+
308+
// Test finding item after the one that matches a condition
309+
$result = $users->after(function ($user) {
310+
return $user['name'] === 'Jeffrey';
311+
});
312+
313+
$this->assertSame(['name' => 'Mohamed', 'age' => 35], $result);
314+
}
289315
}

0 commit comments

Comments
 (0)