function ExpectDeprecationTrait::expectDeprecation

Same name in other branches
  1. 8.9.x core/tests/Drupal/Tests/Traits/ExpectDeprecationTrait.php \Drupal\Tests\Traits\ExpectDeprecationTrait::expectDeprecation()

Adds an expected deprecation.

Parameters

string $message: The expected deprecation message.

126 calls to ExpectDeprecationTrait::expectDeprecation()
BackwardsCompatibilityClassLoaderTest::testModuleMovedClass in core/tests/Drupal/KernelTests/Core/ClassLoader/BackwardsCompatibilityClassLoaderTest.php
Tests that a moved class from a module works.
BlockThemeDeprecationTest::testConstructorDeprecation in core/modules/block/tests/src/Unit/Plugin/migrate/process/BlockThemeDeprecationTest.php
Tests the deprecation in the constructor.
BlockValidationTest::testWeightCannotBeNull in core/modules/block/tests/src/Kernel/BlockValidationTest.php
@group legacy
CKEditor5PluginManagerTest::testDerivedPluginDefinitions in core/modules/ckeditor5/tests/src/Kernel/CKEditor5PluginManagerTest.php
@covers \Drupal\ckeditor5\Plugin\CKEditor5PluginManager::getDiscovery @dataProvider providerTestDerivedPluginDefinitions @group legacy
ConfigSchemaDeprecationTest::testConfigSchemaDeprecation in core/tests/Drupal/KernelTests/Core/Config/ConfigSchemaDeprecationTest.php
Tests config schema deprecation.

... See full list

File

core/tests/Drupal/TestTools/Extension/DeprecationBridge/ExpectDeprecationTrait.php, line 85

Class

ExpectDeprecationTrait
A trait to include in Drupal tests to manage expected deprecations.

Namespace

Drupal\TestTools\Extension\DeprecationBridge

Code

public function expectDeprecation(string $message) : void {
    if (!DeprecationHandler::isDeprecationTest($this)) {
        throw new \RuntimeException('expectDeprecation() can only be called from tests marked with #[IgnoreDeprecations] or \'@group legacy\'');
    }
    if (!DeprecationHandler::isEnabled()) {
        return;
    }
    DeprecationHandler::expectDeprecation($message);
}

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