You are here

public function AnalyzeServiceReferencesPassTest::testProcess in Service Container 7

Same name and namespace in other branches
  1. 7.2 modules/providers/service_container_symfony/lib/Symfony/Component/DependencyInjection/Tests/Compiler/AnalyzeServiceReferencesPassTest.php \Symfony\Component\DependencyInjection\Tests\Compiler\AnalyzeServiceReferencesPassTest::testProcess()

File

modules/providers/service_container_symfony/lib/Symfony/Component/DependencyInjection/Tests/Compiler/AnalyzeServiceReferencesPassTest.php, line 22

Class

AnalyzeServiceReferencesPassTest

Namespace

Symfony\Component\DependencyInjection\Tests\Compiler

Code

public function testProcess() {
  $container = new ContainerBuilder();
  $a = $container
    ->register('a')
    ->addArgument($ref1 = new Reference('b'));
  $b = $container
    ->register('b')
    ->addMethodCall('setA', array(
    $ref2 = new Reference('a'),
  ));
  $c = $container
    ->register('c')
    ->addArgument($ref3 = new Reference('a'))
    ->addArgument($ref4 = new Reference('b'));
  $d = $container
    ->register('d')
    ->setProperty('foo', $ref5 = new Reference('b'));
  $e = $container
    ->register('e')
    ->setConfigurator(array(
    $ref6 = new Reference('b'),
    'methodName',
  ));
  $graph = $this
    ->process($container);
  $this
    ->assertCount(4, $edges = $graph
    ->getNode('b')
    ->getInEdges());
  $this
    ->assertSame($ref1, $edges[0]
    ->getValue());
  $this
    ->assertSame($ref4, $edges[1]
    ->getValue());
  $this
    ->assertSame($ref5, $edges[2]
    ->getValue());
  $this
    ->assertSame($ref6, $edges[3]
    ->getValue());
}