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.

87 calls to ExpectDeprecationTrait::expectDeprecation()
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
ConfigSchemaDeprecationTest::testConfigSchemaDeprecation in core/tests/Drupal/KernelTests/Core/Config/ConfigSchemaDeprecationTest.php
Tests config schema deprecation.
DeprecatedAssetsTest::testDeprecatedLibraries in core/tests/Drupal/KernelTests/Core/Asset/DeprecatedAssetsTest.php
Confirms the status and definition contents of deprecated libraries.
DeprecatedTemplateTest::testDeprecatedTemplate in core/modules/system/tests/src/Functional/Module/DeprecatedTemplateTest.php
Tests that the deprecated template is marked as deprecated.

... See full list

File

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

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.