public function ContainerBuilderTest::testGetAliases

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

File

drupal/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php, line 158

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');
}