FactoryTest.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. /*
  3. * This file is part of php-file-iterator.
  4. *
  5. * (c) Sebastian Bergmann <sebastian@phpunit.de>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace SebastianBergmann\FileIterator;
  11. use PHPUnit\Framework\TestCase;
  12. /**
  13. * @covers \SebastianBergmann\FileIterator\Factory
  14. */
  15. class FactoryTest extends TestCase
  16. {
  17. /**
  18. * @var string
  19. */
  20. private $root;
  21. /**
  22. * @var Factory
  23. */
  24. private $factory;
  25. protected function setUp(): void
  26. {
  27. $this->root = __DIR__;
  28. $this->factory = new Factory;
  29. }
  30. public function testFindFilesInTestDirectory(): void
  31. {
  32. $iterator = $this->factory->getFileIterator($this->root, 'Test.php');
  33. $files = \iterator_to_array($iterator);
  34. $this->assertGreaterThanOrEqual(1, \count($files));
  35. }
  36. public function testFindFilesWithExcludedNonExistingSubdirectory(): void
  37. {
  38. $iterator = $this->factory->getFileIterator($this->root, 'Test.php', '', [$this->root . '/nonExistingDir']);
  39. $files = \iterator_to_array($iterator);
  40. $this->assertGreaterThanOrEqual(1, \count($files));
  41. }
  42. }