diff --git a/core/modules/link/tests/src/Unit/Plugin/migrate/cckfield/LinkCckTest.php b/core/modules/link/tests/src/Unit/Plugin/migrate/cckfield/LinkCckTest.php index dc3fe7731e..b908bbe902 100644 --- a/core/modules/link/tests/src/Unit/Plugin/migrate/cckfield/LinkCckTest.php +++ b/core/modules/link/tests/src/Unit/Plugin/migrate/cckfield/LinkCckTest.php @@ -11,6 +11,8 @@ * @coversDefaultClass \Drupal\link\Plugin\migrate\cckfield\LinkField * @group link * @group legacy + * @arunInSeparateProcess + * @apreserveGlobalState disabled */ class LinkCckTest extends UnitTestCase { @@ -46,8 +48,7 @@ protected function setUp() { /** * @covers ::processCckFieldValues - * @expectedDeprecation CckFieldPluginBase is deprecated in Drupal 8.3.x and will be be removed before Drupal 9.0.x. Use \Drupal\migrate_drupal\Plugin\migrate\field\FieldPluginBase instead. - * @expectedDeprecation MigrateCckFieldInterface is deprecated in Drupal 8.3.x and will be removed before Drupal 9.0.x. Use \Drupal\migrate_drupal\Annotation\MigrateField instead. + * @expectedDeprecation LinkField is deprecated in Drupal 8.3.x and will be be removed before Drupal 9.0.x. Use \Drupal\link\Plugin\migrate\field\d6\LinkField instead. */ public function testProcessCckFieldValues() { $this->plugin->processCckFieldValues($this->migration, 'somefieldname', []); diff --git a/core/tests/Drupal/Tests/Core/Listeners/DrupalStandardsListenerDeprecationTest.php b/core/tests/Drupal/Tests/Core/Listeners/DrupalStandardsListenerDeprecationTest.php index 048dfe1079..7c60d6825e 100644 --- a/core/tests/Drupal/Tests/Core/Listeners/DrupalStandardsListenerDeprecationTest.php +++ b/core/tests/Drupal/Tests/Core/Listeners/DrupalStandardsListenerDeprecationTest.php @@ -21,7 +21,6 @@ * would trigger another deprecation error. * * @group Listeners - * @group legacy * * @coversDefaultClass \Drupal\deprecation_test\Deprecation\DrupalStandardsListenerDeprecatedClass */ @@ -30,8 +29,6 @@ class DrupalStandardsListenerDeprecationTest extends UnitTestCase { /** * Exercise DrupalStandardsListener's coverage validation. * - * @expectedDeprecation Drupal\deprecation_test\Deprecation\DrupalStandardsListenerDeprecatedClass is deprecated. - * * @covers ::testFunction */ public function testDeprecation() { diff --git a/core/tests/Drupal/Tests/Listeners/DrupalStandardsListenerTrait.php b/core/tests/Drupal/Tests/Listeners/DrupalStandardsListenerTrait.php index 2676c46a4f..0ad0e1e239 100644 --- a/core/tests/Drupal/Tests/Listeners/DrupalStandardsListenerTrait.php +++ b/core/tests/Drupal/Tests/Listeners/DrupalStandardsListenerTrait.php @@ -143,6 +143,28 @@ private function checkValidCoversForTest(TestCase $test) { } } + /** + * Handles errors to ensure deprecation messages are not triggered. + * + * @param int $type + * The severity level of the error. + * @param string $msg + * The error message. + * @param $file + * The file that caused the error. + * @param $line + * The line number that caused the error. + * @param array $context + * The error context. + */ + public static function errorHandler($type, $msg, $file, $line, $context = array()) { + if ($type === E_USER_DEPRECATED) { + return; + } + $error_handler = class_exists('PHPUnit_Util_ErrorHandler') ? 'PHPUnit_Util_ErrorHandler' : 'PHPUnit\Util\ErrorHandler'; + return $error_handler::handleError($type, $msg, $file, $line, $context); + } + /** * Reacts to the end of a test. * @@ -166,7 +188,11 @@ private function doEndTest($test, $time) { // our purpose, so we have to distinguish between the different known // subclasses. if ($test instanceof TestCase) { + // Change the error handler to ensure deprecation messages are not + // triggered. + set_error_handler([$this, 'errorHandler']); $this->checkValidCoversForTest($test); + restore_error_handler(); } elseif ($this->isTestSuite($test)) { foreach ($test->getGroupDetails() as $tests) {