Fixing missing abstract attribute in XmlDumper

Caused mis-reporting of abstract key (always no) in debug:container
This commit is contained in:
Ryan Weaver 2017-05-24 21:00:11 -04:00
parent 49d6604ee4
commit 40f60ec60d
4 changed files with 30 additions and 0 deletions

View File

@ -191,6 +191,10 @@ class XmlDumper extends Dumper
$service->appendChild($factory);
}
if ($definition->isAbstract()) {
$service->setAttribute('abstract', 'true');
}
if ($callable = $definition->getConfigurator()) {
$configurator = $this->document->createElement('configurator');

View File

@ -184,4 +184,12 @@ class XmlDumperTest extends TestCase
$this->assertEquals(file_get_contents(self::$fixturesPath.'/xml/services21.xml'), $dumper->dump());
}
public function testDumpAbstractServices()
{
$container = include self::$fixturesPath.'/containers/container_abstract.php';
$dumper = new XmlDumper($container);
$this->assertEquals(file_get_contents(self::$fixturesPath.'/xml/services_abstract.xml'), $dumper->dump());
}
}

View File

@ -0,0 +1,12 @@
<?php
use Symfony\Component\DependencyInjection\ContainerBuilder;
$container = new ContainerBuilder();
$container
->register('foo', 'Foo')
->setAbstract(true)
;
return $container;

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<services>
<service id="foo" class="Foo" abstract="true"/>
</services>
</container>