Skip to content

Commit

Permalink
[DI] Fix dumping abstract with YamlDumper
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-grekas committed Aug 10, 2017
1 parent 5fad797 commit c396e8c
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 c396e8c

Please sign in to comment.