GlobFileLoaderTest.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  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 Symfony\Component\Routing\Tests\Loader;
  11. use PHPUnit\Framework\TestCase;
  12. use Symfony\Component\Config\FileLocator;
  13. use Symfony\Component\Config\Resource\GlobResource;
  14. use Symfony\Component\Routing\Loader\GlobFileLoader;
  15. use Symfony\Component\Routing\RouteCollection;
  16. class GlobFileLoaderTest extends TestCase
  17. {
  18. public function testSupports()
  19. {
  20. $loader = new GlobFileLoader(new FileLocator());
  21. $this->assertTrue($loader->supports('any-path', 'glob'), '->supports() returns true if the resource has the glob type');
  22. $this->assertFalse($loader->supports('any-path'), '->supports() returns false if the resource is not of glob type');
  23. }
  24. public function testLoadAddsTheGlobResourceToTheContainer()
  25. {
  26. $loader = new GlobFileLoaderWithoutImport(new FileLocator());
  27. $collection = $loader->load(__DIR__.'/../Fixtures/directory/*.yml');
  28. $this->assertEquals(new GlobResource(__DIR__.'/../Fixtures/directory', '/*.yml', false), $collection->getResources()[0]);
  29. }
  30. }
  31. class GlobFileLoaderWithoutImport extends GlobFileLoader
  32. {
  33. public function import($resource, $type = null, $ignoreErrors = false, $sourceResource = null)
  34. {
  35. return new RouteCollection();
  36. }
  37. }