IntegrationTest.php in Service Container 7.2
File
modules/providers/service_container_symfony/lib/Symfony/Component/DependencyInjection/Tests/Compiler/IntegrationTest.php
View source
<?php
namespace Symfony\Component\DependencyInjection\Tests\Compiler;
use Symfony\Component\DependencyInjection\Alias;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\DependencyInjection\ContainerBuilder;
class IntegrationTest extends \PHPUnit_Framework_TestCase {
public function testProcessRemovesAndInlinesRecursively() {
$container = new ContainerBuilder();
$container
->setResourceTracking(false);
$a = $container
->register('a', '\\stdClass')
->addArgument(new Reference('c'));
$b = $container
->register('b', '\\stdClass')
->addArgument(new Reference('c'))
->setPublic(false);
$c = $container
->register('c', '\\stdClass')
->setPublic(false);
$container
->compile();
$this
->assertTrue($container
->hasDefinition('a'));
$arguments = $a
->getArguments();
$this
->assertSame($c, $arguments[0]);
$this
->assertFalse($container
->hasDefinition('b'));
$this
->assertFalse($container
->hasDefinition('c'));
}
public function testProcessInlinesReferencesToAliases() {
$container = new ContainerBuilder();
$container
->setResourceTracking(false);
$a = $container
->register('a', '\\stdClass')
->addArgument(new Reference('b'));
$container
->setAlias('b', new Alias('c', false));
$c = $container
->register('c', '\\stdClass')
->setPublic(false);
$container
->compile();
$this
->assertTrue($container
->hasDefinition('a'));
$arguments = $a
->getArguments();
$this
->assertSame($c, $arguments[0]);
$this
->assertFalse($container
->hasAlias('b'));
$this
->assertFalse($container
->hasDefinition('c'));
}
public function testProcessInlinesWhenThereAreMultipleReferencesButFromTheSameDefinition() {
$container = new ContainerBuilder();
$container
->setResourceTracking(false);
$container
->register('a', '\\stdClass')
->addArgument(new Reference('b'))
->addMethodCall('setC', array(
new Reference('c'),
));
$container
->register('b', '\\stdClass')
->addArgument(new Reference('c'))
->setPublic(false);
$container
->register('c', '\\stdClass')
->setPublic(false);
$container
->compile();
$this
->assertTrue($container
->hasDefinition('a'));
$this
->assertFalse($container
->hasDefinition('b'));
$this
->assertFalse($container
->hasDefinition('c'), 'Service C was not inlined.');
}
}
Classes
Name |
Description |
IntegrationTest |
This class tests the integration of the different compiler passes. |