public function YamlFileLoaderTest::testExtensions in Service Container 7
Same name and namespace in other branches
- 7.2 modules/providers/service_container_symfony/lib/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php \Symfony\Component\DependencyInjection\Tests\Loader\YamlFileLoaderTest::testExtensions()
File
- modules/
providers/ service_container_symfony/ lib/ Symfony/ Component/ DependencyInjection/ Tests/ Loader/ YamlFileLoaderTest.php, line 190
Class
Namespace
Symfony\Component\DependencyInjection\Tests\LoaderCode
public function testExtensions() {
$container = new ContainerBuilder();
$container
->registerExtension(new \ProjectExtension());
$loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath . '/yaml'));
$loader
->load('services10.yml');
$container
->compile();
$services = $container
->getDefinitions();
$parameters = $container
->getParameterBag()
->all();
$this
->assertTrue(isset($services['project.service.bar']), '->load() parses extension elements');
$this
->assertTrue(isset($parameters['project.parameter.bar']), '->load() parses extension elements');
$this
->assertEquals('BAR', $services['project.service.foo']
->getClass(), '->load() parses extension elements');
$this
->assertEquals('BAR', $parameters['project.parameter.foo'], '->load() parses extension elements');
try {
$loader
->load('services11.yml');
$this
->fail('->load() throws an InvalidArgumentException if the tag is not valid');
} catch (\Exception $e) {
$this
->assertInstanceOf('\\InvalidArgumentException', $e, '->load() throws an InvalidArgumentException if the tag is not valid');
$this
->assertStringStartsWith('There is no extension able to load the configuration for "foobarfoobar" (in', $e
->getMessage(), '->load() throws an InvalidArgumentException if the tag is not valid');
}
}