function ExpectDeprecationTrait::expectDeprecation

Adds an expected deprecation.

Parameters

string $message: The expected deprecation message.

106 calls to ExpectDeprecationTrait::expectDeprecation()
BackwardsCompatibilityClassLoaderTest::testDoctrineException in core/tests/Drupal/KernelTests/Core/ClassLoader/BackwardsCompatibilityClassLoaderTest.php
Tests that the BC layer for Doctrine's AnnotationException works.
BackwardsCompatibilityClassLoaderTest::testModuleMovedClass in core/tests/Drupal/KernelTests/Core/ClassLoader/BackwardsCompatibilityClassLoaderTest.php
Tests that a moved class from a module works.
BlockValidationTest::testWeightCannotBeNull in core/modules/block/tests/src/Kernel/BlockValidationTest.php
Tests weight cannot be null.
CKEditor5PluginManagerTest::testDeprecatedIcons in core/modules/ckeditor5/tests/src/Kernel/CKEditor5PluginManagerTest.php
Tests deprecation and backwards compatibility of icon names.
CKEditor5PluginManagerTest::testDerivedPluginDefinitions in core/modules/ckeditor5/tests/src/Kernel/CKEditor5PluginManagerTest.php
Tests derived plugin definitions.

... See full list

File

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

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.