public function ContainerBuilderTest::testLazyLoadedService in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/symfony/dependency-injection/Tests/ContainerBuilderTest.php \Symfony\Component\DependencyInjection\Tests\ContainerBuilderTest::testLazyLoadedService()
File
- vendor/
symfony/ dependency-injection/ Tests/ ContainerBuilderTest.php, line 814
Class
Namespace
Symfony\Component\DependencyInjection\TestsCode
public function testLazyLoadedService() {
$loader = new ClosureLoader($container = new ContainerBuilder());
$loader
->load(function (ContainerBuilder $container) {
$container
->set('a', new \BazClass());
$definition = new Definition('BazClass');
$definition
->setLazy(true);
$container
->setDefinition('a', $definition);
});
$container
->setResourceTracking(true);
$container
->compile();
$class = new \BazClass();
$reflectionClass = new \ReflectionClass($class);
$r = new \ReflectionProperty($container, 'resources');
$r
->setAccessible(true);
$resources = $r
->getValue($container);
$classInList = false;
foreach ($resources as $resource) {
if ($resource
->getResource() === $reflectionClass
->getFileName()) {
$classInList = true;
break;
}
}
$this
->assertTrue($classInList);
}