public function YamlFileLoaderTest::testLoadServices in Service Container 7.2
Same name and namespace in other branches
- 7 modules/providers/service_container_symfony/lib/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php \Symfony\Component\DependencyInjection\Tests\Loader\YamlFileLoaderTest::testLoadServices()
File
- modules/
providers/ service_container_symfony/ lib/ Symfony/ Component/ DependencyInjection/ Tests/ Loader/ YamlFileLoaderTest.php, line 144
Class
Namespace
Symfony\Component\DependencyInjection\Tests\LoaderCode
public function testLoadServices() {
$container = new ContainerBuilder();
$loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath . '/yaml'));
$loader
->load('services6.yml');
$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'),
'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(),
),
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'),
'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 aliases');
$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());
}