public function XmlFileLoaderTest::testLoadServices in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/symfony/dependency-injection/Tests/Loader/XmlFileLoaderTest.php \Symfony\Component\DependencyInjection\Tests\Loader\XmlFileLoaderTest::testLoadServices()
File
- vendor/
symfony/ dependency-injection/ Tests/ Loader/ XmlFileLoaderTest.php, line 213
Class
Namespace
Symfony\Component\DependencyInjection\Tests\LoaderCode
public function testLoadServices() {
$container = new ContainerBuilder();
$loader = new XmlFileLoader($container, new FileLocator(self::$fixturesPath . '/xml'));
$loader
->load('services6.xml');
$services = $container
->getDefinitions();
$this
->assertTrue(isset($services['foo']), '->load() parses <service> elements');
$this
->assertInstanceOf('Symfony\\Component\\DependencyInjection\\Definition', $services['foo'], '->load() converts <service> element to Definition instances');
$this
->assertEquals('FooClass', $services['foo']
->getClass(), '->load() parses the class attribute');
$this
->assertEquals('container', $services['scope.container']
->getScope());
$this
->assertEquals('custom', $services['scope.custom']
->getScope());
$this
->assertEquals('prototype', $services['scope.prototype']
->getScope());
$this
->assertEquals('%path%/foo.php', $services['file']
->getFile(), '->load() parses the file tag');
$this
->assertEquals(array(
'foo',
new Reference('foo'),
array(
true,
false,
),
), $services['arguments']
->getArguments(), '->load() parses the argument tags');
$this
->assertEquals('sc_configure', $services['configurator1']
->getConfigurator(), '->load() parses the configurator tag');
$this
->assertEquals(array(
new Reference('baz', ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE, false),
'configure',
), $services['configurator2']
->getConfigurator(), '->load() parses the configurator tag');
$this
->assertEquals(array(
'BazClass',
'configureStatic',
), $services['configurator3']
->getConfigurator(), '->load() parses the configurator tag');
$this
->assertEquals(array(
array(
'setBar',
array(),
),
array(
'setBar',
array(
new Expression('service("foo").foo() ~ (container.hasparameter("foo") ? parameter("foo") : "default")'),
),
),
), $services['method_call1']
->getMethodCalls(), '->load() parses the method_call tag');
$this
->assertEquals(array(
array(
'setBar',
array(
'foo',
new Reference('foo'),
array(
true,
false,
),
),
),
), $services['method_call2']
->getMethodCalls(), '->load() parses the method_call tag');
$this
->assertEquals('factory', $services['new_factory1']
->getFactory(), '->load() parses the factory tag');
$this
->assertEquals(array(
new Reference('baz', ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE, false),
'getClass',
), $services['new_factory2']
->getFactory(), '->load() parses the factory tag');
$this
->assertEquals(array(
'BazClass',
'getInstance',
), $services['new_factory3']
->getFactory(), '->load() parses the factory tag');
$aliases = $container
->getAliases();
$this
->assertTrue(isset($aliases['alias_for_foo']), '->load() parses <service> elements');
$this
->assertEquals('foo', (string) $aliases['alias_for_foo'], '->load() parses aliases');
$this
->assertTrue($aliases['alias_for_foo']
->isPublic());
$this
->assertTrue(isset($aliases['another_alias_for_foo']));
$this
->assertEquals('foo', (string) $aliases['another_alias_for_foo']);
$this
->assertFalse($aliases['another_alias_for_foo']
->isPublic());
$this
->assertEquals(array(
'decorated',
null,
), $services['decorator_service']
->getDecoratedService());
$this
->assertEquals(array(
'decorated',
'decorated.pif-pouf',
), $services['decorator_service_with_name']
->getDecoratedService());
}