$arguments =
$container->
getDefinition('FooClass'
)->
getArguments();
$this->
assertInstanceOf(Reference::
class,
array_shift($arguments));
} public function testLoadServices() { $container =
new ContainerBuilder();
$loader =
new XmlFileLoader($container,
new FileLocator(self::
$fixturesPath.'/xml'
));
$loader->
load('services6.xml'
);
$services =
$container->
getDefinitions();
$this->
assertArrayHasKey('foo',
$services, '->load() parses <service> elements'
);
$this->
assertFalse($services['not_shared'
]->
isShared(), '->load() parses shared flag'
);
$this->
assertInstanceOf(Definition::
class,
$services['foo'
], '->load() converts <service> element to Definition instances'
);
$this->
assertEquals('FooClass',
$services['foo'
]->
getClass(), '->load() parses the class attribute'
);
$this->
assertEquals('%path%/foo.php',
$services['file'
]->
getFile(), '->load() parses the file tag'
);
$this->
assertEquals(['foo',
new Reference('foo'
),
[true, false
]],
$services['arguments'
]->
getArguments(), '->load() parses the argument tags'
);
$this->
assertEquals('sc_configure',
$services['configurator1'
]->
getConfigurator(), '->load() parses the configurator tag'
);
$this->
assertEquals([new Reference('baz'
), 'configure'
],
$services['configurator2'
]->
getConfigurator(), '->load() parses the configurator tag'
);
$this->
assertEquals(['BazClass', 'configureStatic'
],
$services['configurator3'
]->
getConfigurator(), '->load() parses the configurator tag'
);
$this->
assertEquals([['setBar',
[]],
['setBar',
[new Expression('service("foo").foo() ~ (container.hasParameter("foo") ? parameter("foo") : "default")'
)]]],
$services['method_call1'
]->
getMethodCalls(), '->load() parses the method_call tag'
);
$this->
assertEquals([['setBar',
['foo',
new Reference('foo'
),
[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([new Reference('baz'
), 'getClass'
],
$services['new_factory2'
]->
getFactory(), '->load() parses the factory tag'
);