function PhpUnitWarnings::addWarning

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Traits/PhpUnitWarnings.php \Drupal\Tests\Traits\PhpUnitWarnings::addWarning()
  2. 10 core/tests/Drupal/Tests/Traits/PhpUnitWarnings.php \Drupal\Tests\Traits\PhpUnitWarnings::addWarning()

Converts PHPUnit deprecation warnings to E_USER_DEPRECATED.

@internal

Parameters

string $warning: The warning message raised in tests.

See also

\PHPUnit\Framework\TestCase::addWarning()

File

core/tests/Drupal/Tests/Traits/PhpUnitWarnings.php, line 56

Class

PhpUnitWarnings
Converts deprecation warnings added by PHPUnit to silenced deprecations.

Namespace

Drupal\Tests\Traits

Code

public function addWarning(string $warning) : void {
    if (in_array($warning, self::$deprecationWarnings, TRUE)) {
        // Convert listed PHPUnit deprecations into E_USER_DEPRECATED and prevent
        // each from being raised as a test warning.
        @trigger_error($warning, E_USER_DEPRECATED);
        return;
    }
    // Otherwise, let the parent raise any warning not specifically listed.
    parent::addWarning($warning);
}

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