Skip to content

Commit a5be36f

Browse files
committed
Add tests for glob loaders
1 parent ef4328a commit a5be36f

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

Tests/Loader/GlobFileLoaderTest.php

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
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\DependencyInjection\Tests\Loader;
13+
14+
use PHPUnit\Framework\TestCase;
15+
use Symfony\Component\Config\Resource\GlobResource;
16+
use Symfony\Component\DependencyInjection\ContainerBuilder;
17+
use Symfony\Component\DependencyInjection\Loader\GlobFileLoader;
18+
use Symfony\Component\Config\FileLocator;
19+
20+
class GlobFileLoaderTest extends TestCase
21+
{
22+
public function testSupports()
23+
{
24+
$loader = new GlobFileLoader(new ContainerBuilder(), 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($container = new ContainerBuilder(), new FileLocator());
33+
$loader->load(__DIR__.'/../Fixtures/config/*');
34+
35+
$this->assertEquals(new GlobResource(__DIR__.'/../Fixtures/config', '/*', false), $container->getResources()[1]);
36+
}
37+
}
38+
39+
class GlobFileLoaderWithoutImport extends GlobFileLoader
40+
{
41+
public function import($resource, $type = null, $ignoreErrors = false, $sourceResource = null)
42+
{
43+
}
44+
}

0 commit comments

Comments
 (0)