public function XmlFileLoaderTest::testNoNamingConflictsForAnonymousServices

File

drupal/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php, line 310

Class

XmlFileLoaderTest

Namespace

Symfony\Component\DependencyInjection\Tests\Loader

Code

public function testNoNamingConflictsForAnonymousServices() {
  $container = new ContainerBuilder();
  $loader1 = new XmlFileLoader($container, new FileLocator(self::$fixturesPath . '/xml/extension1'));
  $loader1
    ->load('services.xml');
  $services = $container
    ->getDefinitions();
  $this
    ->assertEquals(2, count($services), '->load() attributes unique ids to anonymous services');
  $loader2 = new XmlFileLoader($container, new FileLocator(self::$fixturesPath . '/xml/extension2'));
  $loader2
    ->load('services.xml');
  $services = $container
    ->getDefinitions();
  $this
    ->assertEquals(4, count($services), '->load() attributes unique ids to anonymous services');
  $services = $container
    ->getDefinitions();
  $args1 = $services['extension1.foo']
    ->getArguments();
  $inner1 = $services[(string) $args1[0]];
  $this
    ->assertEquals('BarClass1', $inner1
    ->getClass(), '->load() uses the same configuration as for the anonymous ones');
  $args2 = $services['extension2.foo']
    ->getArguments();
  $inner2 = $services[(string) $args2[0]];
  $this
    ->assertEquals('BarClass2', $inner2
    ->getClass(), '->load() uses the same configuration as for the anonymous ones');
}