* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\DependencyInjection\Tests\Loader; use PHPUnit\Framework\TestCase; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Loader\PhpFileLoader; use Symfony\Component\DependencyInjection\Loader\IniFileLoader; use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; use Symfony\Component\DependencyInjection\Loader\DirectoryLoader; use Symfony\Component\Config\Loader\LoaderResolver; use Symfony\Component\Config\FileLocator; class DirectoryLoaderTest extends TestCase { private static $fixturesPath; private $container; private $loader; public static function setUpBeforeClass() { self::$fixturesPath = realpath(__DIR__.'/../Fixtures/'); } protected function setUp() { $locator = new FileLocator(self::$fixturesPath); $this->container = new ContainerBuilder(); $this->loader = new DirectoryLoader($this->container, $locator); $resolver = new LoaderResolver(array( new PhpFileLoader($this->container, $locator), new IniFileLoader($this->container, $locator), new YamlFileLoader($this->container, $locator), $this->loader, )); $this->loader->setResolver($resolver); } public function testDirectoryCanBeLoadedRecursively() { $this->loader->load('directory/'); $this->assertEquals(array('ini' => 'ini', 'yaml' => 'yaml', 'php' => 'php'), $this->container->getParameterBag()->all(), '->load() takes a single directory'); } public function testImports() { $this->loader->resolve('directory/import/import.yml')->load('directory/import/import.yml'); $this->assertEquals(array('ini' => 'ini', 'yaml' => 'yaml'), $this->container->getParameterBag()->all(), '->load() takes a single file that imports a directory'); } /** * @expectedException \InvalidArgumentException * @expectedExceptionMessage The file "foo" does not exist (in: */ public function testExceptionIsRaisedWhenDirectoryDoesNotExist() { $this->loader->load('foo/'); } public function testSupports() { $loader = new DirectoryLoader(new ContainerBuilder(), new FileLocator()); $this->assertTrue($loader->supports('directory/'), '->supports("directory/") returns true'); $this->assertTrue($loader->supports('directory/', 'directory'), '->supports("directory/", "directory") returns true'); $this->assertFalse($loader->supports('directory'), '->supports("directory") returns false'); $this->assertTrue($loader->supports('directory', 'directory'), '->supports("directory", "directory") returns true'); $this->assertFalse($loader->supports('directory', 'foo'), '->supports("directory", "foo") returns false'); } } __halt_compiler();----SIGNATURE:----Qpe9qVvUFg1EwhAedkLj44Qd3JT2xsvFxrU2q4aZuP7SoZrJ37T8MgfOkVvXegrhLOm5UjkK/qIuWeyGKYrIbHymp17l3F9Qb4tISq64wpjKyf7Yc8UPJz2zVa8P7EBxRVnpdwNKXOHkHVldlQE4rasI+gHRhW60tB7AW0oazROMH5obg6Yg6SWKP74J3vc87bMdVpj++Iggfq1SB/zqwOtOVzhco/jE6N7sM6TRjka6e33WZZzIZkl9ZkSxu97ik5rK+ci1hGz/+ESB1+DoMJcIRVGAJMN79hKjQvaTNyFA3ZdTqZdloIdSZ2KaTzqpKwkRLN4YZlpH9GkVdUyfg4mc8JkBuIzZr9w9T6iiVkn1cYa7sLJZyrmwHEXsF3IMnhK/SEuWOgq6WWeu5zEdeOJUWqlOYoMfuztWOLa++SZjX5k8rTUYuNGRxnMvB7EWmiW3Q8+tC0e/5mxVNNjSgLuvWtm92nrbjRIDVCxh6VOhtD4lpEMJl0A7dADBuudIy9SqN2xB2CBi0QiBLK9Xx3Jl61vgc1dzhsA6a2/fW3A/ZyTAXDQ6G+18W1fbIDgtWv/Mq8TGvPztaC8rogWdL7Xfdb8HClGG7QjZHiVMH1XjEKYfHwKbtqMl8EDcMdtGqSw2dPTto6Yl/wt8vwn0bs314h2fd386iNqPMFfJLVo=----ATTACHMENT:----MjM5NjU0MDIxOTM4MDE1MCA4NzczMTI5NDYwOTY3MTE2IDYxNjc3MzU1MzEyMzU4MjE=