Skip to content

Commit ec5343f

Browse files
authored
Merge pull request #20 from samsonasik/tset-last-generator
Add test for Finder::last() from Generator
2 parents a636081 + b765e20 commit ec5343f

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

tests/FinderTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,21 @@ public function testLastKeepCurrentOriginalData(): void
271271
$this->assertSame(DateTime::class, current($data)::class);
272272
}
273273

274+
private function getGenerator(): Generator
275+
{
276+
yield 1;
277+
yield 2;
278+
yield 3;
279+
}
280+
281+
public function testLastFromGenerator(): void
282+
{
283+
$generator = $this->getGenerator();
284+
$filter = static fn(int $datum): bool => $datum > 1;
285+
286+
$this->assertSame(3, Finder::last($generator, $filter));
287+
}
288+
274289
#[DataProvider('rowsDataProvider')]
275290
public function testRows(iterable $data, callable $filter, array $expected): void
276291
{

0 commit comments

Comments
 (0)