[DependencyInjection] XmlFileLoader should allow "factory-service" attribute without "class" for <service>

This commit is contained in:
Jeremy Mikola 2010-10-19 14:55:44 -04:00 committed by Fabien Potencier
parent f810723092
commit 0aba8ef720
2 changed files with 4 additions and 2 deletions

View File

@ -105,9 +105,9 @@ class XmlFileLoader extends FileLoader
return;
}
$definition = new Definition((string) $service['class']);
$definition = new Definition();
foreach (array('shared', 'factory-method', 'factory-service', 'factory-class') as $key) {
foreach (array('class', 'shared', 'factory-method', 'factory-service') as $key) {
if (isset($service[$key])) {
$method = 'set'.str_replace('-', '', $key);
$definition->$method((string) $service->getAttributeAsPhp($key));

View File

@ -139,6 +139,8 @@ class XmlFileLoaderTest extends \PHPUnit_Framework_TestCase
$this->assertEquals(array('BazClass', 'configureStatic'), $services['configurator3']->getConfigurator(), '->load() parses the configurator tag');
$this->assertEquals(array(array('setBar', array())), $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->assertNull($services['factory_service']->getClass());
$this->assertEquals('getInstance', $services['factory_service']->getFactoryMethod());
$this->assertEquals('baz_factory', $services['factory_service']->getFactoryService());
$aliases = $container->getAliases();