function ProxyServicesPassTest::testContainerWithLazyServices

Same name and namespace in other branches
  1. 8.9.x core/tests/Drupal/Tests/Core/DependencyInjection/Compiler/ProxyServicesPassTest.php \Drupal\Tests\Core\DependencyInjection\Compiler\ProxyServicesPassTest::testContainerWithLazyServices()
  2. 10 core/tests/Drupal/Tests/Core/DependencyInjection/Compiler/ProxyServicesPassTest.php \Drupal\Tests\Core\DependencyInjection\Compiler\ProxyServicesPassTest::testContainerWithLazyServices()
  3. 11.x core/tests/Drupal/Tests/Core/DependencyInjection/Compiler/ProxyServicesPassTest.php \Drupal\Tests\Core\DependencyInjection\Compiler\ProxyServicesPassTest::testContainerWithLazyServices()

@covers ::process

File

core/tests/Drupal/Tests/Core/DependencyInjection/Compiler/ProxyServicesPassTest.php, line 49

Class

ProxyServicesPassTest
@coversDefaultClass <a href="/api/drupal/core%21lib%21Drupal%21Core%21DependencyInjection%21Compiler%21ProxyServicesPass.php/class/ProxyServicesPass/9" title="Replaces all services with a lazy flag." class="local">\Drupal\Core\DependencyInjection\Compiler\ProxyServicesPass</a> @group DependencyInjection

Namespace

Drupal\Tests\Core\DependencyInjection\Compiler

Code

public function testContainerWithLazyServices() {
    $container = new ContainerBuilder();
    $container->register('plugin_cache_clearer', 'Drupal\\Core\\Plugin\\CachedDiscoveryClearer')
        ->setLazy(TRUE);
    $this->proxyServicesPass
        ->process($container);
    $this->assertCount(3, $container->getDefinitions());
    $non_proxy_definition = $container->getDefinition('drupal.proxy_original_service.plugin_cache_clearer');
    $this->assertEquals('Drupal\\Core\\Plugin\\CachedDiscoveryClearer', $non_proxy_definition->getClass());
    $this->assertFalse($non_proxy_definition->isLazy());
    $this->assertTrue($non_proxy_definition->isPublic());
    $this->assertEquals('Drupal\\Core\\ProxyClass\\Plugin\\CachedDiscoveryClearer', $container->getDefinition('plugin_cache_clearer')
        ->getClass());
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.