function ServiceDeprecationTest::testGetDeprecated

Same name in other branches
  1. 9 core/tests/Drupal/FunctionalTests/Core/Container/ServiceDeprecationTest.php \Drupal\FunctionalTests\Core\Container\ServiceDeprecationTest::testGetDeprecated()
  2. 11.x core/tests/Drupal/FunctionalTests/Core/Container/ServiceDeprecationTest.php \Drupal\FunctionalTests\Core\Container\ServiceDeprecationTest::testGetDeprecated()

@covers ::get

File

core/tests/Drupal/FunctionalTests/Core/Container/ServiceDeprecationTest.php, line 36

Class

ServiceDeprecationTest
Test whether deprecation notices are triggered via \Drupal::service().

Namespace

Drupal\FunctionalTests\Core\Container

Code

public function testGetDeprecated() : void {
    $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.');
    // @phpstan-ignore-next-line
    \Drupal::service('deprecation_test.service');
    // @phpstan-ignore-next-line
    \Drupal::service('deprecation_test.alias');
}

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