diff --git a/core/modules/simpletest/src/WebTestBase.php b/core/modules/simpletest/src/WebTestBase.php index 14ce832ae5..aa5a25f7ee 100644 --- a/core/modules/simpletest/src/WebTestBase.php +++ b/core/modules/simpletest/src/WebTestBase.php @@ -211,11 +211,10 @@ * * If the test is using code that causes a warning via a silently triggered * E_USER_DEPRECATED error then this can be used to skip this error for a - * particular test. Note, that this is means there is technical debt that - * needs to be addressed. This should not be used for testing expected - * deprecations. To test for expected deprecations change the test to a - * PHPUnit based test and use the @expectedDeprecation annotation and add - * @group legacy. + * particular test. Note, that this means there is technical debt that needs + * to be addressed. This should not be used for testing expected deprecations. + * To test for expected deprecations change the test to a PHPUnit based test + * and use the @expectedDeprecation annotation and add @group legacy. * * @see \Drupal\Tests\Listeners\DeprecationListener::getSkippedDeprecations() * diff --git a/core/tests/Drupal/KernelTests/KernelTestBase.php b/core/tests/Drupal/KernelTests/KernelTestBase.php index c489c44a02..206717852f 100644 --- a/core/tests/Drupal/KernelTests/KernelTestBase.php +++ b/core/tests/Drupal/KernelTests/KernelTestBase.php @@ -226,10 +226,10 @@ * * If the test is using code that causes a warning via a silently triggered * E_USER_DEPRECATED error then this can be used to skip this error for a - * particular test. Note, that this is means there is technical debt that - * needs to be addressed. This should not be used for testing expected - * deprecations. To test for expected deprecations use the - * @expectedDeprecation annotation and add @group legacy. + * particular test. Note, that this means there is technical debt that needs + * to be addressed. This should not be used for testing expected deprecations. + * To test for expected deprecations use the @expectedDeprecation annotation + * and add @group legacy. * * @see \Drupal\Tests\Listeners\DeprecationListener::getSkippedDeprecations() * diff --git a/core/tests/Drupal/Tests/BrowserTestBase.php b/core/tests/Drupal/Tests/BrowserTestBase.php index ce9524e9f3..1f4cd5488e 100644 --- a/core/tests/Drupal/Tests/BrowserTestBase.php +++ b/core/tests/Drupal/Tests/BrowserTestBase.php @@ -279,10 +279,10 @@ * * If the test is using code that causes a warning via a silently triggered * E_USER_DEPRECATED error then this can be used to skip this error for a - * particular test. Note, that this is means there is technical debt that - * needs to be addressed. This should not be used for testing expected - * deprecations. To test for expected deprecations use the - * @expectedDeprecation annotation and add @group legacy. + * particular test. Note, that this means there is technical debt that needs + * to be addressed. This should not be used for testing expected deprecations. + * To test for expected deprecations use the @expectedDeprecation annotation + * and add @group legacy. * * @see \Drupal\Tests\Listeners\DeprecationListener::getSkippedDeprecations() * diff --git a/core/tests/Drupal/Tests/Core/Test/SkippedDeprecationsInheritanceTest.php b/core/tests/Drupal/Tests/Core/Test/SkippedDeprecationsInheritanceTest.php new file mode 100644 index 0000000000..f19619a4b1 --- /dev/null +++ b/core/tests/Drupal/Tests/Core/Test/SkippedDeprecationsInheritanceTest.php @@ -0,0 +1,31 @@ +addToAssertionCount(1); + } + +} diff --git a/core/tests/Drupal/Tests/Listeners/DeprecationListener.php b/core/tests/Drupal/Tests/Listeners/DeprecationListener.php index 279e0145ad..1a0229a3b8 100644 --- a/core/tests/Drupal/Tests/Listeners/DeprecationListener.php +++ b/core/tests/Drupal/Tests/Listeners/DeprecationListener.php @@ -45,8 +45,16 @@ public function endTest(\PHPUnit_Framework_Test $test, $time) { */ public static function getSkippedDeprecations($test_class) { $skipped_deprecations = []; - if (isset($test_class::$skippedDeprecations) && is_array($test_class::$skippedDeprecations)) { - $skipped_deprecations = $test_class::$skippedDeprecations; + while ($test_class) { + if (property_exists($test_class, 'skippedDeprecations')) { + // Only add the skipped deprecations, if the $skippedDeprecations + // property was not inherited. + $rp = new \ReflectionProperty($test_class, 'skippedDeprecations'); + if ($rp->class == $test_class) { + $skipped_deprecations = array_merge($test_class::$skippedDeprecations, $skipped_deprecations); + } + } + $test_class = get_parent_class($test_class); } return array_merge($skipped_deprecations, [ 'As of 3.1 an Symfony\Component\HttpKernel\Controller\ArgumentResolverInterface is used to resolve arguments. In 4.0 the $argumentResolver becomes the Symfony\Component\HttpKernel\Controller\ArgumentResolver if no other is provided instead of using the $resolver argument.',