File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed
tests/WS/Utils/Collections Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -391,6 +391,15 @@ public function firstLastElementCases(): array
391391 ];
392392 }
393393
394+ public function firstFirstElementWithFilterCases (): array
395+ {
396+ return [
397+ [ [1 , 2 , 3 ], 2 , 2 ],
398+ [ [1 ], 2 , null ],
399+ [[], 2 , null ]
400+ ];
401+ }
402+
394403 /**
395404 * @dataProvider firstLastElementCases
396405 * @test
@@ -405,6 +414,23 @@ public function findFirstElement($input, $first): void
405414 $ this ->assertEquals ($ first , $ actual );
406415 }
407416
417+ /**
418+ * @dataProvider firstFirstElementWithFilterCases
419+ * @test
420+ * @param array $input
421+ * @param mixed $first
422+ * @param mixed $expected
423+ */
424+ public function findFirstElementWithFilter (array $ input , $ first , $ expected ): void
425+ {
426+ $ actual = $ this ->createCollection ($ input )
427+ ->stream ()
428+ ->findFirst (function ($ item ) use ($ first ) {
429+ return $ item === $ first ;
430+ });
431+ $ this ->assertEquals ($ expected , $ actual );
432+ }
433+
408434 /** @noinspection PhpUnusedParameterInspection */
409435 /**
410436 * @dataProvider firstLastElementCases
You can’t perform that action at this time.
0 commit comments