class ServiceDeprecationTest
Same name and namespace in other branches
- 11.x core/tests/Drupal/FunctionalTests/Core/Container/ServiceDeprecationTest.php \Drupal\FunctionalTests\Core\Container\ServiceDeprecationTest
- 10 core/tests/Drupal/FunctionalTests/Core/Container/ServiceDeprecationTest.php \Drupal\FunctionalTests\Core\Container\ServiceDeprecationTest
Test whether deprecation notices are triggered via \Drupal::service().
Note: this test must be a BrowserTestBase so the container is properly compiled. The container in KernelTestBase tests is always an instance of \Drupal\Core\DependencyInjection\ContainerBuilder.
@group Container @group legacy
@coversDefaultClass \Drupal\Component\DependencyInjection\Container
Hierarchy
- class \Drupal\Tests\BrowserTestBase uses \Drupal\Core\Test\FunctionalTestSetupTrait, \Drupal\Tests\UiHelperTrait, \Drupal\Core\Test\TestSetupTrait, \Drupal\Tests\block\Traits\BlockCreationTrait, \Drupal\FunctionalTests\AssertLegacyTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\node\Traits\NodeCreationTrait, \Drupal\Tests\node\Traits\ContentTypeCreationTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\user\Traits\UserCreationTrait, \Drupal\Tests\XdebugRequestTrait, \Drupal\Tests\Traits\PhpUnitWarnings, \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait, \Drupal\Tests\ExtensionListTestTrait implements \PHPUnit\Framework\TestCase
- class \Drupal\FunctionalTests\Core\Container\ServiceDeprecationTest implements \Drupal\Tests\BrowserTestBase
Expanded class hierarchy of ServiceDeprecationTest
File
-
core/
tests/ Drupal/ FunctionalTests/ Core/ Container/ ServiceDeprecationTest.php, line 19
Namespace
Drupal\FunctionalTests\Core\ContainerView source
class ServiceDeprecationTest extends BrowserTestBase {
/**
* {@inheritdoc}
*/
protected static $modules = [
'deprecation_test',
];
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
/**
* @covers ::get
*/
public function testGetDeprecated() {
$this->expectDeprecation('The "deprecation_test.service" service is deprecated in drupal:9.0.0 and is removed from drupal:20.0.0. This is a test.');
$this->expectDeprecation('The "deprecation_test.alias" alias is deprecated in drupal:9.0.0 and is removed from drupal:20.0.0. This is a test.');
\Drupal::service('deprecation_test.service');
\Drupal::service('deprecation_test.alias');
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.