You are here

public function AutoAliasServicePassTest::testProcessWithExistingAlias in Service Container 7.2

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

File

modules/providers/service_container_symfony/lib/Symfony/Component/DependencyInjection/Tests/Compiler/AutoAliasServicePassTest.php, line 54

Class

AutoAliasServicePassTest

Namespace

Symfony\Component\DependencyInjection\Tests\Compiler

Code

public function testProcessWithExistingAlias() {
  $container = new ContainerBuilder();
  $container
    ->register('example', 'Symfony\\Component\\DependencyInjection\\Tests\\Compiler\\ServiceClassDefault')
    ->addTag('auto_alias', array(
    'format' => '%existing%.example',
  ));
  $container
    ->register('mysql.example', 'Symfony\\Component\\DependencyInjection\\Tests\\Compiler\\ServiceClassMysql');
  $container
    ->setParameter('existing', 'mysql');
  $pass = new AutoAliasServicePass();
  $pass
    ->process($container);
  $this
    ->assertTrue($container
    ->hasAlias('example'));
  $this
    ->assertEquals('mysql.example', $container
    ->getAlias('example'));
  $this
    ->assertInstanceOf('Symfony\\Component\\DependencyInjection\\Tests\\Compiler\\ServiceClassMysql', $container
    ->get('example'));
}