diff --git a/core/phpstan-baseline.neon b/core/phpstan-baseline.neon
index eba9f5a22ebe9e57c9bcf106687615330d65b302..04e8de9b634b7ce58d9b26cfb04cedc7718d7869 100644
--- a/core/phpstan-baseline.neon
+++ b/core/phpstan-baseline.neon
@@ -3360,11 +3360,6 @@ parameters:
 			count: 1
 			path: tests/Drupal/Tests/Core/Entity/EntityUrlTest.php
 
-		-
-			message: "#^Call to deprecated method withConsecutive\\(\\) of class PHPUnit\\\\Framework\\\\MockObject\\\\Builder\\\\InvocationMocker\\.$#"
-			count: 6
-			path: tests/Drupal/Tests/Core/Entity/KeyValueStore/KeyValueEntityStorageTest.php
-
 		-
 			message: "#^Call to deprecated method withConsecutive\\(\\) of class PHPUnit\\\\Framework\\\\MockObject\\\\Builder\\\\InvocationMocker\\.$#"
 			count: 1
diff --git a/core/tests/Drupal/Tests/Core/Entity/KeyValueStore/KeyValueEntityStorageTest.php b/core/tests/Drupal/Tests/Core/Entity/KeyValueStore/KeyValueEntityStorageTest.php
index 208f3cddd351a6995fbb234e2d13f7234eafc03b..613bbddb43bd95f127d53132ee50fee592339330 100644
--- a/core/tests/Drupal/Tests/Core/Entity/KeyValueStore/KeyValueEntityStorageTest.php
+++ b/core/tests/Drupal/Tests/Core/Entity/KeyValueStore/KeyValueEntityStorageTest.php
@@ -158,9 +158,12 @@ public function testCreateWithPredefinedUuid() {
       ->willReturn(get_class($this->getMockEntity()));
     $this->setUpKeyValueEntityStorage();
 
-    $this->moduleHandler->expects($this->exactly(2))
+    $hooks = ['test_entity_type_create', 'entity_create'];
+    $this->moduleHandler->expects($this->exactly(count($hooks)))
       ->method('invokeAll')
-      ->withConsecutive(['test_entity_type_create'], ['entity_create']);
+      ->with($this->callback(function (string $hook) use (&$hooks): bool {
+        return array_shift($hooks) === $hook;
+      }));
     $this->uuidService->expects($this->never())
       ->method('generate');
 
@@ -181,9 +184,12 @@ public function testCreateWithoutUuidKey() {
       ->willReturn(get_class($this->getMockEntity()));
     $this->setUpKeyValueEntityStorage(NULL);
 
-    $this->moduleHandler->expects($this->exactly(2))
+    $hooks = ['test_entity_type_create', 'entity_create'];
+    $this->moduleHandler->expects($this->exactly(count($hooks)))
       ->method('invokeAll')
-      ->withConsecutive(['test_entity_type_create'], ['entity_create']);
+      ->with($this->callback(function (string $hook) use (&$hooks): bool {
+        return array_shift($hooks) === $hook;
+      }));
     $this->uuidService->expects($this->never())
       ->method('generate');
 
@@ -206,9 +212,12 @@ public function testCreate() {
       ->willReturn(get_class($entity));
     $this->setUpKeyValueEntityStorage();
 
-    $this->moduleHandler->expects($this->exactly(2))
+    $hooks = ['test_entity_type_create', 'entity_create'];
+    $this->moduleHandler->expects($this->exactly(count($hooks)))
       ->method('invokeAll')
-      ->withConsecutive(['test_entity_type_create'], ['entity_create']);
+      ->with($this->callback(function (string $hook) use (&$hooks): bool {
+        return array_shift($hooks) === $hook;
+      }));
     $this->uuidService->expects($this->once())
       ->method('generate')
       ->willReturn('bar');
@@ -248,14 +257,13 @@ public function testSaveInsert(EntityInterface $entity) {
       ->method('toArray')
       ->willReturn($expected);
 
-    $this->moduleHandler->expects($this->exactly(4))
+    $hooks = ['test_entity_type_presave', 'entity_presave', 'test_entity_type_insert', 'entity_insert'];
+    $this->moduleHandler->expects($this->exactly(count($hooks)))
       ->method('invokeAll')
-      ->withConsecutive(
-        ['test_entity_type_presave'],
-        ['entity_presave'],
-        ['test_entity_type_insert'],
-        ['entity_insert'],
-      );
+      ->with($this->callback(function (string $hook) use (&$hooks): bool {
+        return array_shift($hooks) === $hook;
+      }));
+
     $this->keyValueStore->expects($this->once())
       ->method('set')
       ->with('foo', $expected);
@@ -292,14 +300,14 @@ public function testSaveUpdate(EntityInterface $entity) {
       ->willReturn([['id' => 'foo']]);
     $this->keyValueStore->expects($this->never())
       ->method('delete');
-    $this->moduleHandler->expects($this->exactly(4))
+
+    $hooks = ['test_entity_type_presave', 'entity_presave', 'test_entity_type_update', 'entity_update'];
+    $this->moduleHandler->expects($this->exactly(count($hooks)))
       ->method('invokeAll')
-      ->withConsecutive(
-        ['test_entity_type_presave'],
-        ['entity_presave'],
-        ['test_entity_type_update'],
-        ['entity_update'],
-      );
+      ->with($this->callback(function (string $hook) use (&$hooks): bool {
+        return array_shift($hooks) === $hook;
+      }));
+
     $this->keyValueStore->expects($this->once())
       ->method('set')
       ->with('foo', $expected);
@@ -574,12 +582,21 @@ public function testDelete() {
     $entities['bar'] = $this->getMockEntity(EntityBaseTest::class, [['id' => 'bar']]);
     $this->setUpKeyValueEntityStorage();
 
-    $this->moduleHandler->expects($this->exactly(8))
+    $hooks = [
+      'test_entity_type_predelete',
+      'entity_predelete',
+      'test_entity_type_predelete',
+      'entity_predelete',
+      'test_entity_type_delete',
+      'entity_delete',
+      'test_entity_type_delete',
+      'entity_delete',
+    ];
+    $this->moduleHandler->expects($this->exactly(count($hooks)))
       ->method('invokeAll')
-      ->withConsecutive(
-        ['test_entity_type_predelete'],
-        ['entity_predelete'],
-      );
+      ->with($this->callback(function (string $hook) use (&$hooks): bool {
+        return array_shift($hooks) === $hook;
+      }));
 
     $this->keyValueStore->expects($this->once())
       ->method('deleteMultiple')