Finder.errors.phpt 873 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. /**
  3. * Test: Nette\Utils\Finder errors.
  4. */
  5. declare(strict_types=1);
  6. use Nette\Utils\Finder;
  7. use Tester\Assert;
  8. require __DIR__ . '/../bootstrap.php';
  9. test('missing folder', function () {
  10. Assert::exception(
  11. fn() => iterator_to_array(Finder::findFiles('*')->in('unknown')),
  12. Nette\InvalidStateException::class,
  13. "Directory 'unknown' does not exist.",
  14. );
  15. });
  16. test('absolute mask', function () {
  17. Assert::exception(
  18. fn() => iterator_to_array(Finder::findFiles('/*')->in('.')),
  19. Nette\InvalidStateException::class,
  20. "You cannot combine the absolute path in the mask '/*' and the directory to search '.'.",
  21. );
  22. });
  23. test('globing', function () {
  24. Assert::exception(
  25. fn() => iterator_to_array(Finder::findFiles('fixtures.finder/*/unknown/*')),
  26. Nette\InvalidStateException::class,
  27. "Directory './fixtures.finder/*/unknown' does not exist.",
  28. );
  29. });