[DI] Fix dumping abstract with YamlDumper

This commit is contained in:
Nicolas Grekas 2017-08-10 16:37:13 +02:00
parent 5fad797f6b
commit c396e8cb9c
3 changed files with 20 additions and 0 deletions

View File

@ -104,6 +104,10 @@ class YamlDumper extends Dumper
$code .= sprintf(" factory_class: %s\n", $this->dumper->dump($definition->getFactoryClass(false)));
}
if ($definition->isAbstract()) {
$code .= " abstract: true\n";
}
if ($definition->isLazy()) {
$code .= " lazy: true\n";
}

View File

@ -12,8 +12,10 @@
namespace Symfony\Component\DependencyInjection\Tests\Dumper;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Dumper\YamlDumper;
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
use Symfony\Component\Yaml\Yaml;
class YamlDumperTest extends TestCase
@ -77,6 +79,16 @@ class YamlDumperTest extends TestCase
}
}
public function testDumpLoad()
{
$container = new ContainerBuilder();
$loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml'));
$loader->load('services_dump_load.yml');
$dumper = new YamlDumper($container);
$this->assertStringEqualsFile(self::$fixturesPath.'/yaml/services_dump_load.yml', $dumper->dump());
}
private function assertEqualYamlStructure($yaml, $expected, $message = '')
{
$this->assertEquals(Yaml::parse($expected), Yaml::parse($yaml), $message);

View File

@ -0,0 +1,4 @@
services:
foo:
abstract: true