Skip to content

Commit

Permalink
bug #23856 [DI] Fix dumping abstract with YamlDumper (nicolas-grekas)
Browse files Browse the repository at this point in the history
This PR was merged into the 2.7 branch.

Discussion
----------

[DI] Fix dumping abstract with YamlDumper

| Q             | A
| ------------- | ---
| Branch?       | 2.7
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

Commits
-------

c396e8c [DI] Fix dumping abstract with YamlDumper
  • Loading branch information
nicolas-grekas committed Aug 10, 2017
2 parents c951ca6 + c396e8c commit 1b9619c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
Expand Up @@ -104,6 +104,10 @@ private function addService($id, $definition)
$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";
}
Expand Down
Expand Up @@ -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
Expand Down Expand Up @@ -77,6 +79,16 @@ public function testAddService()
}
}

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);
Expand Down
@@ -0,0 +1,4 @@

services:
foo:
abstract: true

0 comments on commit 1b9619c

Please sign in to comment.