diff --git a/core/modules/inline_form_errors/tests/src/Unit/FormErrorHandlerTest.php b/core/modules/inline_form_errors/tests/src/Unit/FormErrorHandlerTest.php
index 4cb8a8537d40dc424e900a10fa59a9dab9551b0c..962f1079559e24384f13df8fe2f0a22facc76ac9 100644
--- a/core/modules/inline_form_errors/tests/src/Unit/FormErrorHandlerTest.php
+++ b/core/modules/inline_form_errors/tests/src/Unit/FormErrorHandlerTest.php
@@ -120,7 +120,7 @@ protected function setUp(): void {
   public function testErrorMessagesInline() {
     $this->messenger->expects($this->exactly(4))
       ->method('addError')
-      ->willReturnOnConsecutiveCalls(
+      ->withConsecutive(
         ['no title given', FALSE],
         ['element is invisible', FALSE],
         ['this missing element is invalid', FALSE],
@@ -164,7 +164,7 @@ public function testErrorMessagesNotInline() {
     // Asserts all messages are summarized.
     $this->messenger->expects($this->exactly(7))
       ->method('addMessage')
-      ->willReturnOnConsecutiveCalls(
+      ->withConsecutive(
         ['invalid', 'error', FALSE],
         ['invalid', 'error', FALSE],
         ['invalid', 'error', FALSE],
diff --git a/core/modules/migrate/tests/src/Unit/MigrateSqlIdMapEnsureTablesTest.php b/core/modules/migrate/tests/src/Unit/MigrateSqlIdMapEnsureTablesTest.php
index 606d3e61afef2e2cae4ea21a06ff949272054826..cdcbc4468e43e64201adbaaefae5de84738e466e 100644
--- a/core/modules/migrate/tests/src/Unit/MigrateSqlIdMapEnsureTablesTest.php
+++ b/core/modules/migrate/tests/src/Unit/MigrateSqlIdMapEnsureTablesTest.php
@@ -125,7 +125,7 @@ public function testEnsureTablesNotExist() {
       ]);
     $schema->expects($this->exactly(2))
       ->method('createTable')
-      ->willReturnOnConsecutiveCalls(
+      ->withConsecutive(
         ['migrate_map_sql_idmap_test', $map_table_schema],
         ['migrate_message_sql_idmap_test', $table_schema],
       );
@@ -153,7 +153,7 @@ public function testEnsureTablesExist() {
       ]);
     $schema->expects($this->exactly(3))
       ->method('addField')
-      ->willReturnOnConsecutiveCalls(
+      ->withConsecutive(
         [
           'migrate_map_sql_idmap_test', 'rollback_action', [
             'type' => 'int',
diff --git a/core/modules/pgsql/tests/src/Unit/SchemaTest.php b/core/modules/pgsql/tests/src/Unit/SchemaTest.php
index 3beb61a09980db6588a6d7025f2b73ac70a317c3..3b9192fdea4e6a1f6d90e82d0f64c401993a665c 100644
--- a/core/modules/pgsql/tests/src/Unit/SchemaTest.php
+++ b/core/modules/pgsql/tests/src/Unit/SchemaTest.php
@@ -55,7 +55,7 @@ public function testComputedConstraintName($table_name, $name, $expected) {
 
     $this->connection->expects($this->exactly(2))
       ->method('query')
-      ->willReturnOnConsecutiveCalls(
+      ->withConsecutive(
         [$this->anything()],
         ["SELECT 1 FROM pg_constraint WHERE conname = '$expected'"],
       )
diff --git a/core/modules/serialization/tests/src/Unit/Normalizer/EntityNormalizerTest.php b/core/modules/serialization/tests/src/Unit/Normalizer/EntityNormalizerTest.php
index ccb7ec11a6d436673d1a3afa54ec3f1cce2563c7..453f527579c2387a21772c796de6b5b21cc0a3cf 100644
--- a/core/modules/serialization/tests/src/Unit/Normalizer/EntityNormalizerTest.php
+++ b/core/modules/serialization/tests/src/Unit/Normalizer/EntityNormalizerTest.php
@@ -95,7 +95,7 @@ public function testNormalize() {
       ->getMock();
     $serializer->expects($this->exactly(2))
       ->method('normalize')
-      ->willReturnOnConsecutiveCalls(
+      ->withConsecutive(
         [$list_item_1, 'test_format'],
         [$list_item_2, 'test_format'],
       );
@@ -221,7 +221,7 @@ public function testDenormalizeWithValidBundle() {
       ->getMock();
     $serializer->expects($this->exactly(2))
       ->method('denormalize')
-      ->willReturnOnConsecutiveCalls(
+      ->withConsecutive(
         ['value_1', get_class($key_1), NULL, ['target_instance' => $key_1, 'entity_type' => 'test']],
         ['value_2', get_class($key_2), NULL, ['target_instance' => $key_2, 'entity_type' => 'test']],
       );
@@ -370,7 +370,7 @@ public function testDenormalizeWithNoBundle() {
       ->getMock();
     $serializer->expects($this->exactly(2))
       ->method('denormalize')
-      ->willReturnOnConsecutiveCalls(
+      ->withConsecutive(
         ['value_1', get_class($key_1), NULL, ['target_instance' => $key_1, 'entity_type' => 'test']],
         ['value_2', get_class($key_2), NULL, ['target_instance' => $key_2, 'entity_type' => 'test']],
       );
diff --git a/core/modules/views/tests/src/Unit/ViewsDataTest.php b/core/modules/views/tests/src/Unit/ViewsDataTest.php
index cd9b88108bc3968101997685145cc484ddc41ad3..0177af2b7ab2ebd2124daef59014da6d53e62aaf 100644
--- a/core/modules/views/tests/src/Unit/ViewsDataTest.php
+++ b/core/modules/views/tests/src/Unit/ViewsDataTest.php
@@ -369,7 +369,7 @@ public function testCacheCallsWithSameTableMultipleTimes() {
       );
     $this->cacheBackend->expects($this->exactly(2))
       ->method('set')
-      ->willReturnOnConsecutiveCalls(
+      ->withConsecutive(
         ['views_data:en', $expected_views_data],
         ['views_data:views_test_data:en', $expected_views_data['views_test_data']],
       );
@@ -600,7 +600,7 @@ public function testCacheCallsWithoutWarmCacheAndGetMultipleTables() {
       );
     $this->cacheBackend->expects($this->exactly(2))
       ->method('set')
-      ->willReturnOnConsecutiveCalls(
+      ->withConsecutive(
         ["views_data:$table_name:en", $expected_views_data[$table_name]],
         ["views_data:$table_name_2:en", $expected_views_data[$table_name_2]],
       );
diff --git a/core/tests/Drupal/Tests/Core/Entity/EntityUnitTest.php b/core/tests/Drupal/Tests/Core/Entity/EntityUnitTest.php
index b5bfc2a0d7f9e8619675f2ad3171c203193b047e..864851279c2b2b531c02c466a1ab21e7eed4ebbc 100644
--- a/core/tests/Drupal/Tests/Core/Entity/EntityUnitTest.php
+++ b/core/tests/Drupal/Tests/Core/Entity/EntityUnitTest.php
@@ -398,7 +398,7 @@ public function testPreSave() {
   public function testPostSave() {
     $this->cacheTagsInvalidator->expects($this->exactly(2))
       ->method('invalidateTags')
-      ->willReturnOnConsecutiveCalls([
+      ->withConsecutive([
         [
           // List cache tag.
           $this->entityTypeId . '_list',
@@ -429,7 +429,7 @@ public function testPostSave() {
   public function testPostSaveBundle() {
     $this->cacheTagsInvalidator->expects($this->exactly(2))
       ->method('invalidateTags')
-      ->willReturnOnConsecutiveCalls([
+      ->withConsecutive([
         [
           // List cache tag.
           $this->entityTypeId . '_list',
diff --git a/core/tests/Drupal/Tests/Core/Entity/KeyValueStore/KeyValueEntityStorageTest.php b/core/tests/Drupal/Tests/Core/Entity/KeyValueStore/KeyValueEntityStorageTest.php
index 3db613bb747c5794abdce414c27271fa88f0e495..90b0f1c6ce904ee8d8ac20af7c6b380f1d119ffc 100644
--- a/core/tests/Drupal/Tests/Core/Entity/KeyValueStore/KeyValueEntityStorageTest.php
+++ b/core/tests/Drupal/Tests/Core/Entity/KeyValueStore/KeyValueEntityStorageTest.php
@@ -157,7 +157,7 @@ public function testCreateWithPredefinedUuid() {
 
     $this->moduleHandler->expects($this->exactly(2))
       ->method('invokeAll')
-      ->willReturnOnConsecutiveCalls(['test_entity_type_create'], ['entity_create']);
+      ->withConsecutive(['test_entity_type_create'], ['entity_create']);
     $this->uuidService->expects($this->never())
       ->method('generate');
 
@@ -180,7 +180,7 @@ public function testCreateWithoutUuidKey() {
 
     $this->moduleHandler->expects($this->exactly(2))
       ->method('invokeAll')
-      ->willReturnOnConsecutiveCalls(['test_entity_type_create'], ['entity_create']);
+      ->withConsecutive(['test_entity_type_create'], ['entity_create']);
     $this->uuidService->expects($this->never())
       ->method('generate');
 
@@ -205,7 +205,7 @@ public function testCreate() {
 
     $this->moduleHandler->expects($this->exactly(2))
       ->method('invokeAll')
-      ->willReturnOnConsecutiveCalls(['test_entity_type_create'], ['entity_create']);
+      ->withConsecutive(['test_entity_type_create'], ['entity_create']);
     $this->uuidService->expects($this->once())
       ->method('generate')
       ->willReturn('bar');
@@ -247,7 +247,7 @@ public function testSaveInsert(EntityInterface $entity) {
 
     $this->moduleHandler->expects($this->exactly(4))
       ->method('invokeAll')
-      ->willReturnOnConsecutiveCalls(
+      ->withConsecutive(
         ['test_entity_type_presave'],
         ['entity_presave'],
         ['test_entity_type_insert'],
@@ -291,7 +291,7 @@ public function testSaveUpdate(EntityInterface $entity) {
       ->method('delete');
     $this->moduleHandler->expects($this->exactly(4))
       ->method('invokeAll')
-      ->willReturnOnConsecutiveCalls(
+      ->withConsecutive(
         ['test_entity_type_presave'],
         ['entity_presave'],
         ['test_entity_type_update'],
@@ -569,7 +569,7 @@ public function testDelete() {
 
     $this->moduleHandler->expects($this->exactly(8))
       ->method('invokeAll')
-      ->willReturnOnConsecutiveCalls(
+      ->withConsecutive(
         ['test_entity_type_predelete'],
         ['entity_predelete'],
       );
diff --git a/core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageSchemaTest.php b/core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageSchemaTest.php
index ad1ba5c0bc1cb6e4a4752f55cb9d0f409507ac6b..02b2c7e0603d8c2ce473d7304134c6a0af2aba26 100644
--- a/core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageSchemaTest.php
+++ b/core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageSchemaTest.php
@@ -1538,7 +1538,7 @@ public function testonEntityTypeUpdateWithNewIndex() {
     // The original indexes should be dropped before the new one is added.
     $this->dbSchemaHandler->expects($this->exactly(3))
       ->method('dropIndex')
-      ->willReturnOnConsecutiveCalls(
+      ->withConsecutive(
         ['entity_test', 'entity_test__b588603cb9'],
         ['entity_test', 'entity_test__removed_field'],
       );
diff --git a/core/tests/Drupal/Tests/Core/Extension/ModuleHandlerTest.php b/core/tests/Drupal/Tests/Core/Extension/ModuleHandlerTest.php
index d2f98f078663565fd86215a3c6075914ad03f729..6edf3f03e1bcf16e86e39a41dfbe49ae0137db01 100644
--- a/core/tests/Drupal/Tests/Core/Extension/ModuleHandlerTest.php
+++ b/core/tests/Drupal/Tests/Core/Extension/ModuleHandlerTest.php
@@ -115,7 +115,7 @@ public function testModuleReloading() {
       ->getMock();
     $module_handler->expects($this->exactly(3))
       ->method('load')
-      ->willReturnOnConsecutiveCalls(
+      ->withConsecutive(
         // First reload.
         ['module_handler_test'],
         // Second reload.
diff --git a/core/tests/Drupal/Tests/Core/Form/FormCacheTest.php b/core/tests/Drupal/Tests/Core/Form/FormCacheTest.php
index 01aeed92b1a1143c86236aed7e828498272e2777..765fcfe2814e747bce45affe43c4385d50306c38 100644
--- a/core/tests/Drupal/Tests/Core/Form/FormCacheTest.php
+++ b/core/tests/Drupal/Tests/Core/Form/FormCacheTest.php
@@ -313,7 +313,7 @@ public function testLoadCachedFormStateWithFiles() {
     ];
     $this->moduleHandler->expects($this->exactly(2))
       ->method('loadInclude')
-      ->willReturnOnConsecutiveCalls(
+      ->withConsecutive(
         ['a_module', 'the_type', 'some_name'],
         ['another_module', 'inc', 'another_module'],
       );
diff --git a/core/tests/Drupal/Tests/Core/Form/FormErrorHandlerTest.php b/core/tests/Drupal/Tests/Core/Form/FormErrorHandlerTest.php
index d27fd5e84d68a3f22b1241ec7f5c7e1efa03012b..237050d1b735be52c2e046c7db47241cf68c3298 100644
--- a/core/tests/Drupal/Tests/Core/Form/FormErrorHandlerTest.php
+++ b/core/tests/Drupal/Tests/Core/Form/FormErrorHandlerTest.php
@@ -50,7 +50,7 @@ protected function setUp(): void {
   public function testDisplayErrorMessages() {
     $this->messenger->expects($this->exactly(6))
       ->method('addMessage')
-      ->willReturnOnConsecutiveCalls(
+      ->withConsecutive(
         ['invalid', 'error'],
         ['invalid', 'error'],
         ['invalid', 'error'],
diff --git a/core/tests/Drupal/Tests/Core/Menu/ContextualLinkManagerTest.php b/core/tests/Drupal/Tests/Core/Menu/ContextualLinkManagerTest.php
index 56a03c6c43962669ed52ee93d88623f13f7d03a3..3dea04ef27216fb0e16c45a0c9608c846ae02ae5 100644
--- a/core/tests/Drupal/Tests/Core/Menu/ContextualLinkManagerTest.php
+++ b/core/tests/Drupal/Tests/Core/Menu/ContextualLinkManagerTest.php
@@ -246,7 +246,7 @@ public function testGetContextualLinksArrayByGroup() {
 
     $this->moduleHandler->expects($this->exactly(2))
       ->method('alter')
-      ->willReturnOnConsecutiveCalls(
+      ->withConsecutive(
         ['contextual_links_plugins'],
         ['contextual_links', new Count(2), 'group1', ['key' => 'value']],
       );
diff --git a/core/tests/Drupal/Tests/Core/Menu/LocalTaskManagerTest.php b/core/tests/Drupal/Tests/Core/Menu/LocalTaskManagerTest.php
index 19d8f815d3825921b04e7b5ed9acbf51ececa894..8e6acbf0c0245f46cc3a9976703e56c31fd2f0f1 100644
--- a/core/tests/Drupal/Tests/Core/Menu/LocalTaskManagerTest.php
+++ b/core/tests/Drupal/Tests/Core/Menu/LocalTaskManagerTest.php
@@ -186,7 +186,7 @@ public function testGetLocalTaskForRouteWithEmptyCache() {
       );
     $this->cacheBackend->expects($this->exactly(2))
       ->method('set')
-      ->willReturnOnConsecutiveCalls(
+      ->withConsecutive(
         ['local_task_plugins:en', $definitions, Cache::PERMANENT],
         ['local_task_plugins:en:menu_local_task_test_tasks_view', $this->getLocalTasksCache(), Cache::PERMANENT, ['local_task']],
       );