class ProxyServicesPassTest
Same name and namespace in other branches
- 11.x core/tests/Drupal/Tests/Core/DependencyInjection/Compiler/ProxyServicesPassTest.php \Drupal\Tests\Core\DependencyInjection\Compiler\ProxyServicesPassTest
- 10 core/tests/Drupal/Tests/Core/DependencyInjection/Compiler/ProxyServicesPassTest.php \Drupal\Tests\Core\DependencyInjection\Compiler\ProxyServicesPassTest
- 8.9.x core/tests/Drupal/Tests/Core/DependencyInjection/Compiler/ProxyServicesPassTest.php \Drupal\Tests\Core\DependencyInjection\Compiler\ProxyServicesPassTest
@coversDefaultClass \Drupal\Core\DependencyInjection\Compiler\ProxyServicesPass
@group DependencyInjection
Hierarchy
- class \Drupal\Tests\UnitTestCase uses \Drupal\Tests\Traits\PhpUnitWarnings, \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait extends \PHPUnit\Framework\TestCase
- class \Drupal\Tests\Core\DependencyInjection\Compiler\ProxyServicesPassTest extends \Drupal\Tests\UnitTestCase
Expanded class hierarchy of ProxyServicesPassTest
File
-
core/
tests/ Drupal/ Tests/ Core/ DependencyInjection/ Compiler/ ProxyServicesPassTest.php, line 15
Namespace
Drupal\Tests\Core\DependencyInjection\CompilerView source
class ProxyServicesPassTest extends UnitTestCase {
/**
* The tested proxy services pass.
*
* @var \Drupal\Core\DependencyInjection\Compiler\ProxyServicesPass
*/
protected $proxyServicesPass;
/**
* {@inheritdoc}
*/
protected function setUp() : void {
parent::setUp();
$this->proxyServicesPass = new ProxyServicesPass();
}
/**
* @covers ::process
*/
public function testContainerWithoutLazyServices() {
$container = new ContainerBuilder();
$container->register('plugin_cache_clearer', 'Drupal\\Core\\Plugin\\CachedDiscoveryClearer');
$this->proxyServicesPass
->process($container);
$this->assertCount(2, $container->getDefinitions());
$this->assertEquals('Drupal\\Core\\Plugin\\CachedDiscoveryClearer', $container->getDefinition('plugin_cache_clearer')
->getClass());
}
/**
* @covers ::process
*/
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());
}
/**
* @covers ::process
*/
public function testContainerWithLazyServicesWithoutProxyClass() {
$container = new ContainerBuilder();
$container->register('path.current', CurrentPathStack::class)
->setLazy(TRUE);
$this->expectException(InvalidArgumentException::class);
$this->proxyServicesPass
->process($container);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.