You are here

public function ContainerBuilderTest::testGetAliases in Service Container 7

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

@covers Symfony\Component\DependencyInjection\ContainerBuilder::getAliases

File

modules/providers/service_container_symfony/lib/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php, line 211

Class

ContainerBuilderTest

Namespace

Symfony\Component\DependencyInjection\Tests

Code

public function testGetAliases() {
  $builder = new ContainerBuilder();
  $builder
    ->setAlias('bar', 'foo');
  $builder
    ->setAlias('foobar', 'foo');
  $builder
    ->setAlias('moo', new Alias('foo', false));
  $aliases = $builder
    ->getAliases();
  $this
    ->assertEquals('foo', (string) $aliases['bar']);
  $this
    ->assertTrue($aliases['bar']
    ->isPublic());
  $this
    ->assertEquals('foo', (string) $aliases['foobar']);
  $this
    ->assertEquals('foo', (string) $aliases['moo']);
  $this
    ->assertFalse($aliases['moo']
    ->isPublic());
  $builder
    ->register('bar', 'stdClass');
  $this
    ->assertFalse($builder
    ->hasAlias('bar'));
  $builder
    ->set('foobar', 'stdClass');
  $builder
    ->set('moo', 'stdClass');
  $this
    ->assertCount(0, $builder
    ->getAliases(), '->getAliases() does not return aliased services that have been overridden');
}