File tree Expand file tree Collapse file tree 1 file changed +50
-0
lines changed
Expand file tree Collapse file tree 1 file changed +50
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ namespace ArrayLookup \Tests ;
6+
7+ use ArrayLookup \Collector ;
8+ use PHPUnit \Framework \TestCase ;
9+ use stdClass ;
10+
11+ use function is_string ;
12+ use function trim ;
13+
14+ final class CollectorTest extends TestCase
15+ {
16+ public function testWithoutLimit (): void
17+ {
18+ $ data = [
19+ ' a ' ,
20+ ' b ' ,
21+ ' c ' ,
22+ new stdClass (),
23+ ];
24+
25+ $ results = Collector::setUp ($ data )
26+ ->when (fn (mixed $ datum ): bool => is_string ($ datum ))
27+ ->withTransform (fn (string $ datum ): string => trim ($ datum ))
28+ ->getResults ();
29+
30+ $ this ->assertSame (['a ' , 'b ' , 'c ' ], $ results );
31+ }
32+
33+ public function testWithLimit (): void
34+ {
35+ $ data = [
36+ ' a ' ,
37+ ' b ' ,
38+ ' c ' ,
39+ new stdClass (),
40+ ];
41+
42+ $ results = Collector::setUp ($ data )
43+ ->when (fn (mixed $ datum ): bool => is_string ($ datum ))
44+ ->withTransform (fn (string $ datum ): string => trim ($ datum ))
45+ ->withLimit (1 )
46+ ->getResults ();
47+
48+ $ this ->assertSame (['a ' ], $ results );
49+ }
50+ }
You can’t perform that action at this time.
0 commit comments