public function ContainerBuilderTest::testCompilesClassDefinitionsOfLazyServices

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

File

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

Class

ContainerBuilderTest

Namespace

Symfony\Component\DependencyInjection\Tests

Code

public function testCompilesClassDefinitionsOfLazyServices() {
  if (!class_exists('Symfony\\Component\\Config\\Resource\\FileResource')) {
    $this
      ->markTestSkipped('The "Config" component is not available');
  }
  $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);
}