FactoryTest.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. }