mirror of
https://github.com/rectorphp/rector.git
synced 2025-02-25 12:14:02 +01:00
42 lines
1.1 KiB
PHP
42 lines
1.1 KiB
PHP
|
<?php declare(strict_types=1);
|
||
|
|
||
|
namespace Rector\Tests\FileSystem\FilesFinder;
|
||
|
|
||
|
use Iterator;
|
||
|
use Rector\FileSystem\FilesFinder;
|
||
|
use Rector\Tests\AbstractContainerAwareTestCase;
|
||
|
|
||
|
final class FilesFinderTest extends AbstractContainerAwareTestCase
|
||
|
{
|
||
|
/**
|
||
|
* @var FilesFinder
|
||
|
*/
|
||
|
private $filesFinder;
|
||
|
|
||
|
protected function setUp(): void
|
||
|
{
|
||
|
$this->filesFinder = $this->container->get(FilesFinder::class);
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @param string[] $suffixes
|
||
|
* @dataProvider provideData()
|
||
|
*/
|
||
|
public function test(array $suffixes, int $count, string $fileName): void
|
||
|
{
|
||
|
$foundFiles = $this->filesFinder->findInDirectoriesAndFiles([__DIR__ . '/FilesFinderSource'], $suffixes);
|
||
|
$this->assertCount($count, $foundFiles);
|
||
|
|
||
|
$foundFile = array_pop($foundFiles);
|
||
|
$this->assertSame($fileName, $foundFile->getBasename());
|
||
|
}
|
||
|
|
||
|
public function provideData(): Iterator
|
||
|
{
|
||
|
yield [['*.php'], 1, 'SomeFile.php'];
|
||
|
yield [['*.yml'], 1, 'some_config.yml'];
|
||
|
yield [['php'], 1, 'SomeFile.php'];
|
||
|
yield [['yml'], 1, 'some_config.yml'];
|
||
|
}
|
||
|
}
|