diff --git a/core/phpstan-baseline.neon b/core/phpstan-baseline.neon
index aa7ade41ee6de65651cee308abab77320491d3d9..54219d5f9bce530ae74109ddfbf1e95881b966f8 100644
--- a/core/phpstan-baseline.neon
+++ b/core/phpstan-baseline.neon
@@ -3353,11 +3353,6 @@ parameters:
 			count: 1
 			path: tests/Drupal/Tests/Core/EventSubscriber/SpecialAttributesRouteSubscriberTest.php
 
-		-
-			message: "#^Call to deprecated method withConsecutive\\(\\) of class PHPUnit\\\\Framework\\\\MockObject\\\\Builder\\\\InvocationMocker\\.$#"
-			count: 1
-			path: tests/Drupal/Tests/Core/Extension/ModuleHandlerTest.php
-
 		-
 			message: "#^Call to deprecated method withConsecutive\\(\\) of class PHPUnit\\\\Framework\\\\MockObject\\\\Builder\\\\InvocationMocker\\.$#"
 			count: 1
diff --git a/core/tests/Drupal/Tests/Core/Extension/ModuleHandlerTest.php b/core/tests/Drupal/Tests/Core/Extension/ModuleHandlerTest.php
index 4f093a736c3e9fdecabf157c150f0ac99cc7eeeb..0fcad71f6357c074cd645d0aebe426b662ac9217 100644
--- a/core/tests/Drupal/Tests/Core/Extension/ModuleHandlerTest.php
+++ b/core/tests/Drupal/Tests/Core/Extension/ModuleHandlerTest.php
@@ -115,15 +115,18 @@ public function testModuleReloading() {
       ])
       ->onlyMethods(['load'])
       ->getMock();
-    $module_handler->expects($this->exactly(3))
+    $calls = [
+      // First reload.
+      'module_handler_test',
+      // Second reload.
+      'module_handler_test',
+      'module_handler_test_added',
+    ];
+    $module_handler->expects($this->exactly(count($calls)))
       ->method('load')
-      ->withConsecutive(
-        // First reload.
-        ['module_handler_test'],
-        // Second reload.
-        ['module_handler_test'],
-        ['module_handler_test_added'],
-      );
+      ->with($this->callback(function (string $module) use (&$calls): bool {
+        return $module === array_shift($calls);
+      }));
     $module_handler->reload();
     $module_handler->addModule('module_handler_test_added', 'core/tests/Drupal/Tests/Core/Extension/modules/module_handler_test_added');
     $module_handler->reload();