| Total Complexity | 5 |
| Total Lines | 60 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 11 | class LocateFilesByGlobPatternTest extends TestCase |
||
| 12 | { |
||
| 13 | |||
| 14 | /** |
||
| 15 | * @var LocateFilesByGlobPattern |
||
| 16 | */ |
||
| 17 | private $locator; |
||
| 18 | |||
| 19 | /** |
||
| 20 | * @var vfsStreamDirectory |
||
| 21 | */ |
||
| 22 | private $root; |
||
| 23 | |||
| 24 | public function setUp() |
||
| 25 | { |
||
| 26 | $this->locator = new LocateFilesByGlobPattern(); |
||
| 27 | $this->root = vfsStream::setup(); |
||
| 28 | } |
||
| 29 | |||
| 30 | public function testSimpleGlobPattern() |
||
| 31 | { |
||
| 32 | vfsStream::create([ |
||
| 33 | 'bin' => [ |
||
| 34 | 'console' => '', |
||
| 35 | 'not-console' => '', |
||
| 36 | ], |
||
| 37 | ]); |
||
| 38 | |||
| 39 | $files = $this->files(['bin/console'], $this->root->url()); |
||
| 40 | self::assertCount(1, $files); |
||
| 41 | self::assertContains($this->root->getChild('bin/console')->url(), $files); |
||
| 42 | } |
||
| 43 | |||
| 44 | public function testGlobPattern() |
||
| 45 | { |
||
| 46 | vfsStream::create([ |
||
| 47 | 'bin' => [ |
||
| 48 | 'console.php' => '', |
||
| 49 | 'console123.php' => '', |
||
| 50 | 'not-console' => '', |
||
| 51 | ], |
||
| 52 | ]); |
||
| 53 | |||
| 54 | $files = $this->files(['bin/console*.php'], $this->root->url()); |
||
| 55 | self::assertCount(2, $files); |
||
| 56 | self::assertContains($this->root->getChild('bin/console.php')->url(), $files); |
||
| 57 | self::assertContains($this->root->getChild('bin/console123.php')->url(), $files); |
||
| 58 | } |
||
| 59 | |||
| 60 | /** |
||
| 61 | * @return string[] |
||
| 62 | */ |
||
| 63 | private function files(array $globPatterns, $dir): array |
||
| 71 | } |
||
| 72 | |||
| 73 | } |
||
| 74 |