From 267f1252bfeb898d7af3fa49a66c9467d2e7dba0 Mon Sep 17 00:00:00 2001
From: catch <catch@35733.no-reply.drupal.org>
Date: Wed, 31 Jan 2024 23:42:36 +0000
Subject: [PATCH] Issue #3418451 by longwave: Remove withConsecutive() in
 ModuleHandlerTest

---
 core/phpstan-baseline.neon                    |  5 -----
 .../Core/Extension/ModuleHandlerTest.php      | 19 +++++++++++--------
 2 files changed, 11 insertions(+), 13 deletions(-)

diff --git a/core/phpstan-baseline.neon b/core/phpstan-baseline.neon
index aa7ade41ee6d..54219d5f9bce 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 4f093a736c3e..0fcad71f6357 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();
-- 
GitLab