Skip to content

Commit daa0251

Browse files
Merge branch '2.7' into 2.8
* 2.7: [DI] Fix dumping abstract with YamlDumper
2 parents 18e5e70 + 1b9619c commit daa0251

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
@@ -120,6 +120,10 @@ private function addService($id, $definition)
120120
$code .= sprintf(" factory_class: %s\n", $this->dumper->dump($definition->getFactoryClass(false)));
121121
}
122122

123+
if ($definition->isAbstract()) {
124+
$code .= " abstract: true\n";
125+
}
126+
123127
if ($definition->isLazy()) {
124128
$code .= " lazy: true\n";
125129
}

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
@@ -84,6 +86,16 @@ public function testDumpAutowireData()
8486
$this->assertStringEqualsFile(self::$fixturesPath.'/yaml/services24.yml', $dumper->dump());
8587
}
8688

89+
public function testDumpLoad()
90+
{
91+
$container = new ContainerBuilder();
92+
$loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml'));
93+
$loader->load('services_dump_load.yml');
94+
95+
$dumper = new YamlDumper($container);
96+
$this->assertStringEqualsFile(self::$fixturesPath.'/yaml/services_dump_load.yml', $dumper->dump());
97+
}
98+
8799
private function assertEqualYamlStructure($yaml, $expected, $message = '')
88100
{
89101
$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)