trait ExpectDeprecationTrait in Drupal 9
Same name and namespace in other branches
- 8 core/tests/Drupal/Tests/Traits/ExpectDeprecationTrait.php \Drupal\Tests\Traits\ExpectDeprecationTrait
Adds the ability to dynamically set expected deprecation messages in tests.
@internal
Hierarchy
- trait \Drupal\Tests\Traits\ExpectDeprecationTrait
Deprecated
in drupal:9.1.0 and is removed from drupal:10.0.0. Use \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait instead.
See also
https://www.drupal.org/node/3161901
2 files declare their use of ExpectDeprecationTrait
- ContextAwarePluginTraitTest.php in core/
tests/ Drupal/ KernelTests/ Core/ Plugin/ Context/ ContextAwarePluginTraitTest.php - ExpectDeprecationTest.php in core/
tests/ Drupal/ Tests/ ExpectDeprecationTest.php
File
- core/
tests/ Drupal/ Tests/ Traits/ ExpectDeprecationTrait.php, line 15
Namespace
Drupal\Tests\TraitsView source
trait ExpectDeprecationTrait {
/**
* Sets an expected deprecation message.
*
* @param string $message
* The expected deprecation message.
*/
protected function addExpectedDeprecationMessage($message) {
@trigger_error(__METHOD__ . '() is deprecated in drupal:9.1.0 and is removed from drupal:10.0.0. Use \\Symfony\\Bridge\\PhpUnit\\ExpectDeprecationTrait::expectDeprecation() instead. See https://www.drupal.org/node/3161901', E_USER_DEPRECATED);
$this
->expectDeprecation($message);
}
/**
* Sets expected deprecation messages.
*
* @param string[] $messages
* The expected deprecation messages.
*
* @see \Symfony\Bridge\PhpUnit\Legacy\ExpectDeprecationTraitForV8_4::expectDeprecation()
*/
public function expectedDeprecations(array $messages) {
@trigger_error(__METHOD__ . '() is deprecated in drupal:9.1.0 and is removed from drupal:10.0.0. Use \\Symfony\\Bridge\\PhpUnit\\ExpectDeprecationTrait::expectDeprecation() instead. See https://www.drupal.org/node/3161901', E_USER_DEPRECATED);
foreach ($messages as $message) {
$this
->expectDeprecation($message);
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ExpectDeprecationTrait:: |
protected | function | Sets an expected deprecation message. | |
ExpectDeprecationTrait:: |
public | function | Sets expected deprecation messages. |