-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
df454e4
commit 84f8533
Showing
8 changed files
with
114 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Kcs\ClassFinder\Fixtures\Recursive; | ||
|
||
class Bar | ||
{ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Kcs\ClassFinder\Fixtures\Recursive; | ||
|
||
class Foo | ||
{ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Kcs\ClassFinder\Fixtures\Recursive; | ||
|
||
class FooBar | ||
{ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Kcs\ClassFinder\Tests\Iterator; | ||
|
||
use Kcs\ClassFinder\Fixtures\Recursive\Bar; | ||
use Kcs\ClassFinder\Fixtures\Recursive\Foo; | ||
use Kcs\ClassFinder\Fixtures\Recursive\FooBar; | ||
use Kcs\ClassFinder\Iterator\RecursiveIterator; | ||
use PHPUnit\Framework\TestCase; | ||
use ReflectionClass; | ||
use SplFileInfo; | ||
use function iterator_to_array; | ||
|
||
class RecursiveIteratorTest extends TestCase | ||
{ | ||
public function testRecursiveIteratorShouldSearchInDirectory(): void | ||
{ | ||
$iterator = new RecursiveIterator(__DIR__ . '/../../data/Recursive'); | ||
|
||
self::assertEquals([ | ||
Bar::class => new ReflectionClass(Bar::class), | ||
FooBar::class => new ReflectionClass(FooBar::class), | ||
Foo::class => new ReflectionClass(Foo::class), | ||
], iterator_to_array($iterator)); | ||
} | ||
|
||
public function testRecursiveIteratorShouldSkipFilesThatDoNotMatchFilter(): void | ||
{ | ||
$iterator = new RecursiveIterator( | ||
__DIR__ . '/../../data/Recursive', | ||
0, | ||
static function ( string $path, SplFileInfo $info ): bool { | ||
return str_starts_with( $info->getFilename(), 'class-' ); | ||
}); | ||
|
||
self::assertEquals([ | ||
FooBar::class => new ReflectionClass(FooBar::class), | ||
], iterator_to_array($iterator)); | ||
} | ||
} |