PhpUnitWarnings.php in Drupal 10
File
core/tests/Drupal/Tests/Traits/PhpUnitWarnings.php
View source
<?php
namespace Drupal\Tests\Traits;
trait PhpUnitWarnings {
private static $deprecationWarnings = [
'Test warning for \\Drupal\\Tests\\PhpUnitWarningsTest::testAddWarning()',
'assertFileNotExists() is deprecated and will be removed in PHPUnit 10. Refactor your code to use assertFileDoesNotExist() instead.',
'assertRegExp() is deprecated and will be removed in PHPUnit 10. Refactor your code to use assertMatchesRegularExpression() instead.',
'assertNotRegExp() is deprecated and will be removed in PHPUnit 10. Refactor your code to use assertDoesNotMatchRegularExpression() instead.',
'assertDirectoryNotExists() is deprecated and will be removed in PHPUnit 10. Refactor your code to use assertDirectoryDoesNotExist() instead.',
'Support for using expectException() with PHPUnit\\Framework\\Error\\Warning is deprecated and will be removed in PHPUnit 10. Use expectWarning() instead.',
'Support for using expectException() with PHPUnit\\Framework\\Error\\Error is deprecated and will be removed in PHPUnit 10. Use expectError() instead.',
'assertDirectoryNotIsWritable() is deprecated and will be removed in PHPUnit 10. Refactor your code to use assertDirectoryIsNotWritable() instead.',
'assertFileNotIsWritable() is deprecated and will be removed in PHPUnit 10. Refactor your code to use assertFileIsNotWritable() instead.',
'The at() matcher has been deprecated. It will be removed in PHPUnit 10. Please refactor your test to not rely on the order in which methods are invoked.',
];
public function addWarning(string $warning) : void {
if (in_array($warning, self::$deprecationWarnings, TRUE)) {
@trigger_error($warning, E_USER_DEPRECATED);
return;
}
parent::addWarning($warning);
}
}
Traits
Name |
Description |
PhpUnitWarnings |
Converts deprecation warnings added by PHPUnit to silenced deprecations. |