class DecoratedServiceTest in Drupal 10
Test handling of decorated services in DependencySerializationTraitPass.
@group system
Hierarchy
- class \Drupal\KernelTests\KernelTestBase extends \PHPUnit\Framework\TestCase implements ServiceProviderInterface uses \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait, AssertContentTrait, ConfigTestTrait, ExtensionListTestTrait, RandomGeneratorTrait, TestRequirementsTrait, PhpUnitWarnings
- class \Drupal\Tests\system\Kernel\DecoratedServiceTest
Expanded class hierarchy of DecoratedServiceTest
File
- core/
modules/ system/ tests/ src/ Kernel/ DecoratedServiceTest.php, line 13
Namespace
Drupal\Tests\system\KernelView source
class DecoratedServiceTest extends KernelTestBase {
protected static $modules = [
'decorated_service_test',
];
/**
* Check that decorated services keep their original service ID.
*/
public function testDecoratedServiceId() {
// Service decorated once.
$test_service = $this->container
->get('test_service');
$this
->assertEquals('test_service', $test_service->_serviceId);
$this
->assertInstanceOf(TestServiceDecorator::class, $test_service);
// Service decorated twice.
$test_service2 = $this->container
->get('test_service2');
$this
->assertEquals('test_service2', $test_service2->_serviceId);
$this
->assertInstanceOf(TestServiceDecorator::class, $test_service2);
}
}