diff --git a/core/tests/Drupal/Tests/PhpUnit8WarningsTest.php b/core/tests/Drupal/Tests/PhpUnit8WarningsTest.php
new file mode 100644
index 0000000000..0f5af99399
--- /dev/null
+++ b/core/tests/Drupal/Tests/PhpUnit8WarningsTest.php
@@ -0,0 +1,83 @@
+<?php
+
+namespace Drupal\Tests;
+
+/**
+ * @group legacy
+ */
+class PhpUnit8WarningsTest extends UnitTestCase {
+
+  /**
+   * @expectedDeprecation Using assertContains() with string haystacks is deprecated and will not be supported in PHPUnit 9. Refactor your test to use assertStringContainsString() or assertStringContainsStringIgnoringCase() instead.
+   * @expectedDeprecation The optional $ignoreCase parameter of assertContains() is deprecated and will be removed in PHPUnit 9.
+   */
+  public function testAssertContains() {
+    $this->assertContains('string', 'aaaastringaaa');
+    $this->assertContains('STRING', 'aaaastringaaa', '', TRUE);
+  }
+
+  /**
+   * @expectedDeprecation Using assertNotContains() with string haystacks is deprecated and will not be supported in PHPUnit 9. Refactor your test to use assertStringNotContainsString() or assertStringNotContainsStringIgnoringCase() instead.
+   * @expectedDeprecation The optional $ignoreCase parameter of assertNotContains() is deprecated and will be removed in PHPUnit 9.
+   */
+  public function testAssertNotContains() {
+    $this->assertNotContains('foo', 'bar');
+    $this->assertNotContains('FOO', 'bar', '', TRUE);
+  }
+
+  /**
+   * @expectedDeprecation assertArraySubset() is deprecated and will be removed in PHPUnit 9.
+   */
+  public function testAssertArraySubset() {
+    $this->assertArraySubset(['a'], ['a', 'b']);
+  }
+
+  /**
+   * @expectedDeprecation assertInternalType() is deprecated and will be removed in PHPUnit 9. Refactor your test to use assertIsArray(), assertIsBool(), assertIsFloat(), assertIsInt(), assertIsNumeric(), assertIsObject(), assertIsResource(), assertIsString(), assertIsScalar(), assertIsCallable(), or assertIsIterable() instead.
+   */
+  public function testAssertInternalType() {
+    $this->assertInternalType('string', 'string');
+  }
+
+  /**
+   * @expectedDeprecation assertAttributeEquals() is deprecated and will be removed in PHPUnit 9.
+   * @expectedDeprecation readAttribute() is deprecated and will be removed in PHPUnit 9.
+   * @expectedDeprecation getObjectAttribute() is deprecated and will be removed in PHPUnit 9.
+   * @expectedDeprecation assertAttributeSame() is deprecated and will be removed in PHPUnit 9.
+   * @expectedDeprecation assertAttributeInstanceOf() is deprecated and will be removed in PHPUnit 9.
+   * @expectedDeprecation assertAttributeEmpty() is deprecated and will be removed in PHPUnit 9.
+   */
+  public function testAssertAttribute() {
+    $obj = new class() {
+      protected $attribute = 'value';
+      protected $class;
+      protected $empty;
+
+      public function __construct() {
+        $this->class = new \stdClass();
+      }
+
+    };
+    $this->assertAttributeEquals('value', 'attribute', $obj);
+    $this->assertAttributeSame('value', 'attribute', $obj);
+    $this->assertAttributeInstanceOf(\stdClass::class, 'class', $obj);
+    $this->assertAttributeEmpty('empty', $obj);
+  }
+
+  /**
+   * @expectedDeprecation The optional $canonicalize parameter of assertEquals() is deprecated and will be removed in PHPUnit 9. Refactor your test to use assertEqualsCanonicalizing() instead.
+   */
+  public function testAssertEquals() {
+    $this->assertEquals(['a', 'b'], ['b', 'a'], '', 0.0, 10, TRUE);
+  }
+
+  /**
+   * @expectedDeprecation expectExceptionMessageRegExp() is deprecated in PHPUnit 8 and will be removed in PHPUnit 9.
+   */
+  public function testExpectExceptionMessageRegExp() {
+    $this->expectException(\Exception::class);
+    $this->expectExceptionMessageRegExp('/An exception .*/');
+    throw new \Exception('An exception has been triggered');
+  }
+
+}
diff --git a/core/tests/Drupal/Tests/Traits/PHPUnit8Warnings.php b/core/tests/Drupal/Tests/Traits/PHPUnit8Warnings.php
index 5b80264681..55a6b60504 100644
--- a/core/tests/Drupal/Tests/Traits/PHPUnit8Warnings.php
+++ b/core/tests/Drupal/Tests/Traits/PHPUnit8Warnings.php
@@ -18,25 +18,49 @@
 trait PHPUnit8Warnings {
 
   /**
-   * The list of warnings to ignore.
+   * Deprecation warnings from PHPUnit to raise with @trigger_error().
+   *
+   * Add any PHPUnit deprecations that should be handled as deprecation warnings
+   * (rather than unconditional failures) for core and contrib.
    *
    * @var string[]
    */
-  private static $ignoredWarnings = [
+  private static $deprecationWarnings = [
+    'Using assertContains() with string haystacks is deprecated and will not be supported in PHPUnit 9. Refactor your test to use assertStringContainsString() or assertStringContainsStringIgnoringCase() instead.',
+    'Using assertNotContains() with string haystacks is deprecated and will not be supported in PHPUnit 9. Refactor your test to use assertStringNotContainsString() or assertStringNotContainsStringIgnoringCase() instead.',
+    'assertArraySubset() is deprecated and will be removed in PHPUnit 9.',
+    'assertInternalType() is deprecated and will be removed in PHPUnit 9. Refactor your test to use assertIsArray(), assertIsBool(), assertIsFloat(), assertIsInt(), assertIsNumeric(), assertIsObject(), assertIsResource(), assertIsString(), assertIsScalar(), assertIsCallable(), or assertIsIterable() instead.',
+    'readAttribute() is deprecated and will be removed in PHPUnit 9.',
+    'getObjectAttribute() is deprecated and will be removed in PHPUnit 9.',
+    'The optional $canonicalize parameter of assertEquals() is deprecated and will be removed in PHPUnit 9. Refactor your test to use assertEqualsCanonicalizing() instead.',
+    'assertAttributeEquals() is deprecated and will be removed in PHPUnit 9.',
+    'assertAttributeSame() is deprecated and will be removed in PHPUnit 9.',
+    'assertAttributeInstanceOf() is deprecated and will be removed in PHPUnit 9.',
+    'assertAttributeEmpty() is deprecated and will be removed in PHPUnit 9.',
+    'The optional $ignoreCase parameter of assertContains() is deprecated and will be removed in PHPUnit 9.',
+    'The optional $ignoreCase parameter of assertNotContains() is deprecated and will be removed in PHPUnit 9.',
     'expectExceptionMessageRegExp() is deprecated in PHPUnit 8 and will be removed in PHPUnit 9.',
   ];
 
   /**
-   * Ignores specific PHPUnit 8 warnings.
+   * Converts PHPUnit 8 deprecation warnings to E_USER_DEPRECATED.
+   *
+   * @param string $warning
+   *   The warning message raised in tests.
    *
    * @see \PHPUnit\Framework\TestCase::addWarning()
    *
    * @internal
    */
   public function addWarning(string $warning): void {
-    if (in_array($warning, self::$ignoredWarnings, TRUE)) {
+    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);
   }
 
