function 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()
1 call to PhpUnitWarnings::addWarning()
- PhpUnitWarningsTest::testAddWarning in core/
tests/ Drupal/ Tests/ PhpUnitWarningsTest.php  - Tests that selected PHPUnit warning is converted to deprecation.
 
File
- 
              core/
tests/ Drupal/ Tests/ Traits/ PhpUnitWarnings.php, line 63  
Class
- PhpUnitWarnings
 - Converts deprecation warnings added by PHPUnit to silenced deprecations.
 
Namespace
Drupal\Tests\TraitsCode
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;
  }
  // assertInternalType() has many similar deprecation warnings.
  if (preg_match('/^assertInternalType\\(\\) is deprecated and will be removed in PHPUnit 9. Refactor your test to use assert.*\\(\\) instead.$/', $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.