8000 [DI] Fix dumping abstract with YamlDumper · symfony/symfony@c396e8c · GitHub
[go: up one dir, main page]

Skip to content

Commit c396e8c

Browse files
[DI] Fix dumping abstract with YamlDumper
1 parent 5fad797 commit c396e8c

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

src/Symfony/Component/DependencyInjection/Dumper/YamlDumper.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,10 @@ private function addService($id, $definition)
104104
$code .= sprintf(" factory_class: %s\n", $this->dumper->dump($definition->getFactoryClass(false)));
105105
}
106106

107+
if ($definition->isAbstract()) {
108+
$code .= " abstract: true\n";
109+
}
110+
107111
if ($definition->isLazy()) {
108112
$code .= " lazy: true\n";
109113
}

src/Symfony/Component/DependencyInjection/Tests/Dumper/YamlDumperTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@
1212
namespace Symfony\Component\DependencyInjection\Tests\Dumper;
1313

1414
use PHPUnit\Framework\TestCase;
15+
use Symfony\Component\Config\FileLocator;
1516
use Symfony\Component\DependencyInjection\ContainerBuilder;
1617
use Symfony\Component\DependencyInjection\Dumper\YamlDumper;
18+
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
1719
use Symfony\Component\Yaml\Yaml;
1820

1921
class YamlDumperTest extends TestCase
@@ -77,6 +79,16 @@ public function testAddService()
7779
}
7880
}
7981

82+
public function testDumpLoad()
83+
{
84+
$container = new ContainerBuilder();
85+
$loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml'));
86+
$loader->load('services_dump_load.yml');
87+
88+
$dumper = new YamlDumper($container);
89+
$this->assertStringEqualsFile(self::$fixturesPath.'/yaml/services_dump_load.yml', $dumper->dump());
90+
}
91+
8092
private function assertEqualYamlStructure($yaml, $expected, $message = '')
8193
{
8294
$this->assertEquals(Yaml::parse($expected), Yaml::parse($yaml), $message);
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
services:
3+
foo:
4+
abstract: true

0 commit comments

Comments
 (0)
0