You are here

public function ContainerBuilderTest::testCompilesClassDefinitionsOfLazyServices 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::testCompilesClassDefinitionsOfLazyServices()

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

File

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

Class

ContainerBuilderTest

Namespace

Symfony\Component\DependencyInjection\Tests

Code

public function testCompilesClassDefinitionsOfLazyServices() {
  $container = new ContainerBuilder();
  $this
    ->assertEmpty($container
    ->getResources(), 'No resources get registered without resource tracking');
  $container
    ->register('foo', 'BarClass');
  $container
    ->getDefinition('foo')
    ->setLazy(true);
  $container
    ->compile();
  $classesPath = realpath(__DIR__ . '/Fixtures/includes/classes.php');
  $matchingResources = array_filter($container
    ->getResources(), function (ResourceInterface $resource) use ($classesPath) {
    return $resource instanceof FileResource && $classesPath === realpath($resource
      ->getResource());
  });
  $this
    ->assertNotEmpty($matchingResources);
}