Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ public function __construct()

$this->removingPasses = array(
new RemovePrivateAliasesPass(),
new RemoveAbstractDefinitionsPass(),
new ReplaceAliasByActualDefinitionPass(),
new RemoveAbstractDefinitionsPass(),
new RepeatedPass(array(
new AnalyzeServiceReferencesPass(),
new InlineServiceDefinitionsPass(),
Expand Down Expand Up @@ -103,8 +103,7 @@ public function addPass(CompilerPassInterface $pass, $type = self::TYPE_BEFORE_O
throw new InvalidArgumentException(sprintf('Invalid type "%s".', $type));
}

$passes = &$this->$property;
$passes[] = $pass;
$this->{$property}[] = $pass;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -707,6 +707,21 @@ public function testExtensionConfig()
$this->assertEquals(array($second, $first), $configs);
}

public function testAbstractAlias()
{
$container = new ContainerBuilder();

$abstract = new Definition('AbstractClass');
$abstract->setAbstract(true);

$container->setDefinition('abstract_service', $abstract);
$container->setAlias('abstract_alias', 'abstract_service');

$container->compile();

$this->assertSame('abstract_service', (string) $container->getAlias('abstract_alias'));
}

public function testLazyLoadedService()
{
$loader = new ClosureLoader($container = new ContainerBuilder());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,12 @@
</service>
</argument>
<property name="p" type="service">
<service class="BazClass" />
<service class="BuzClass" />
</property>
</service>
<service id="bar" parent="foo" />
<service class="BizClass">
<tag name="biz_tag" />
</service>
</services>
</container>
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public function testLoadAnonymousServices()
$loader = new XmlFileLoader($container, new FileLocator(self::$fixturesPath.'/xml'));
$loader->load('services5.xml');
$services = $container->getDefinitions();
$this->assertCount(4, $services, '->load() attributes unique ids to anonymous services');
$this->assertCount(6, $services, '->load() attributes unique ids to anonymous services');

// anonymous service as an argument
$args = $services['foo']->getArguments();
Expand All @@ -130,6 +130,7 @@ public function testLoadAnonymousServices()
$this->assertTrue(isset($services[(string) $args[0]]), '->load() makes a reference to the created ones');
$inner = $services[(string) $args[0]];
$this->assertEquals('BarClass', $inner->getClass(), '->load() uses the same configuration as for the anonymous ones');
$this->assertFalse($inner->isPublic());

// inner anonymous services
$args = $inner->getArguments();
Expand All @@ -138,14 +139,33 @@ public function testLoadAnonymousServices()
$this->assertTrue(isset($services[(string) $args[0]]), '->load() makes a reference to the created ones');
$inner = $services[(string) $args[0]];
$this->assertEquals('BazClass', $inner->getClass(), '->load() uses the same configuration as for the anonymous ones');
$this->assertFalse($inner->isPublic());

// anonymous service as a property
$properties = $services['foo']->getProperties();
$property = $properties['p'];
$this->assertInstanceOf('Symfony\\Component\\DependencyInjection\\Reference', $property, '->load() converts anonymous services to references to "normal" services');
$this->assertTrue(isset($services[(string) $property]), '->load() makes a reference to the created ones');
$inner = $services[(string) $property];
$this->assertEquals('BazClass', $inner->getClass(), '->load() uses the same configuration as for the anonymous ones');
$this->assertEquals('BuzClass', $inner->getClass(), '->load() uses the same configuration as for the anonymous ones');
$this->assertFalse($inner->isPublic());

// "wild" service
$service = $container->findTaggedServiceIds('biz_tag');
$this->assertCount(1, $service);

foreach ($service as $id => $tag) {
$service = $container->getDefinition($id);
}
$this->assertEquals('BizClass', $service->getClass(), '->load() uses the same configuration as for the anonymous ones');
$this->assertFalse($service->isPublic());

// anonymous services are shared when using decoration definitions
$container->compile();
$services = $container->getDefinitions();
$fooArgs = $services['foo']->getArguments();
$barArgs = $services['bar']->getArguments();
$this->assertSame($fooArgs[0], $barArgs[0]);
}

public function testLoadServices()
Expand Down