08d806a8a4af67bf453d52b1aece91eba123d56d
[yaffs-website] / vendor / symfony / routing / Tests / Loader / GlobFileLoaderTest.php
1 <?php
2
3 /*
4  * This file is part of the Symfony package.
5  *
6  * (c) Fabien Potencier <fabien@symfony.com>
7  *
8  * For the full copyright and license information, please view the LICENSE
9  * file that was distributed with this source code.
10  */
11
12 namespace Symfony\Component\Routing\Tests\Loader;
13
14 use PHPUnit\Framework\TestCase;
15 use Symfony\Component\Config\Resource\GlobResource;
16 use Symfony\Component\Config\FileLocator;
17 use Symfony\Component\Routing\Loader\GlobFileLoader;
18 use Symfony\Component\Routing\RouteCollection;
19
20 class GlobFileLoaderTest extends TestCase
21 {
22     public function testSupports()
23     {
24         $loader = new GlobFileLoader(new FileLocator());
25
26         $this->assertTrue($loader->supports('any-path', 'glob'), '->supports() returns true if the resource has the glob type');
27         $this->assertFalse($loader->supports('any-path'), '->supports() returns false if the resource is not of glob type');
28     }
29
30     public function testLoadAddsTheGlobResourceToTheContainer()
31     {
32         $loader = new GlobFileLoaderWithoutImport(new FileLocator());
33         $collection = $loader->load(__DIR__.'/../Fixtures/directory/*.yml');
34
35         $this->assertEquals(new GlobResource(__DIR__.'/../Fixtures/directory', '/*.yml', false), $collection->getResources()[0]);
36     }
37 }
38
39 class GlobFileLoaderWithoutImport extends GlobFileLoader
40 {
41     public function import($resource, $type = null, $ignoreErrors = false, $sourceResource = null)
42     {
43         return new RouteCollection();
44     }
45 }