diff --git a/core/phpstan-baseline.neon b/core/phpstan-baseline.neon
index 15db53472cb005e1f759c340f9789ed0c3ccf257..83cd841eac933162d20d0e945e489c71e7065844 100644
--- a/core/phpstan-baseline.neon
+++ b/core/phpstan-baseline.neon
@@ -2172,14 +2172,6 @@ parameters:
 			count: 1
 			path: tests/Drupal/KernelTests/Core/Config/ConfigInstallTest.php
 
-		-
-			message: """
-				#^Call to deprecated method expectError\\(\\) of class PHPUnit\\\\Framework\\\\TestCase\\:
-				https\\://github\\.com/sebastianbergmann/phpunit/issues/5062$#
-			"""
-			count: 2
-			path: tests/Drupal/KernelTests/Core/Database/ConnectionTest.php
-
 		-
 			message: "#^Variable \\$expected_driver might not be defined\\.$#"
 			count: 2
diff --git a/core/tests/Drupal/KernelTests/Core/Database/ConnectionTest.php b/core/tests/Drupal/KernelTests/Core/Database/ConnectionTest.php
index 11423f0b891009c9a0c8bfbf487ffb6e824c433d..742c400d0785f23fb2aa40888938fc71b2a05dbe 100644
--- a/core/tests/Drupal/KernelTests/Core/Database/ConnectionTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Database/ConnectionTest.php
@@ -125,7 +125,7 @@ public function testPerTablePrefixOption() {
       'test_table' => $connection_info['default']['prefix'] . '_bar',
     ];
     Database::addConnectionInfo('default', 'foo', $new_connection_info);
-    $this->expectError();
+    $this->expectException(\AssertionError::class);
     $foo_connection = Database::getConnection('foo', 'default');
   }
 
@@ -139,7 +139,7 @@ public function testPrefixArrayOption() {
       'default' => $connection_info['default']['prefix'],
     ];
     Database::addConnectionInfo('default', 'foo', $new_connection_info);
-    $this->expectError();
+    $this->expectException(\AssertionError::class);
     $foo_connection = Database::getConnection('foo', 'default');
   }