diff --git a/core/phpstan-baseline.neon b/core/phpstan-baseline.neon
index 93168f109e6b2fd3af36944ca4e640e18dc58fc7..4b1e5fd61f468d35fe5473852a5392b6a3e1153e 100644
--- a/core/phpstan-baseline.neon
+++ b/core/phpstan-baseline.neon
@@ -3346,11 +3346,6 @@ parameters:
 			count: 1
 			path: tests/Drupal/Tests/Core/Plugin/CategorizingPluginManagerTraitTest.php
 
-		-
-			message: "#^Call to deprecated method withConsecutive\\(\\) of class PHPUnit\\\\Framework\\\\MockObject\\\\Builder\\\\InvocationMocker\\.$#"
-			count: 1
-			path: tests/Drupal/Tests/Core/Plugin/Discovery/DerivativeDiscoveryDecoratorTest.php
-
 		-
 			message: "#^Constructor of class Drupal\\\\Tests\\\\Core\\\\Plugin\\\\Discovery\\\\TestContainerDerivativeDiscovery has an unused parameter \\$example_service\\.$#"
 			count: 1
diff --git a/core/tests/Drupal/Tests/Core/Plugin/Discovery/DerivativeDiscoveryDecoratorTest.php b/core/tests/Drupal/Tests/Core/Plugin/Discovery/DerivativeDiscoveryDecoratorTest.php
index d7a2c5b8256d025c96c32982137e482321db6c2a..2e3fd33f05a06ef2a0bb8c6e56710ab1458bd01b 100644
--- a/core/tests/Drupal/Tests/Core/Plugin/Discovery/DerivativeDiscoveryDecoratorTest.php
+++ b/core/tests/Drupal/Tests/Core/Plugin/Discovery/DerivativeDiscoveryDecoratorTest.php
@@ -243,12 +243,15 @@ public function testSingleExistingDerivative() {
       'null_value' => NULL,
     ];
 
-    $this->discoveryMain->expects($this->exactly(2))
+    $ids = [
+      $derivative_definition['id'],
+      $base_definition['id'],
+    ];
+    $this->discoveryMain->expects($this->exactly(count($ids)))
       ->method('getDefinition')
-      ->withConsecutive(
-        ['non_container_aware_discovery:test_discovery_1'],
-        ['non_container_aware_discovery'],
-      )
+      ->with($this->callback(function (string $id) use (&$ids): bool {
+        return array_shift($ids) === $id;
+      }))
       ->willReturnOnConsecutiveCalls(
         $derivative_definition,
         $base_definition,