diff --git a/core/phpstan-baseline.neon b/core/phpstan-baseline.neon
index 17ae7d60faa9014b894dedc94d1a3a19262f46e9..f46a34e445f61ae6ebac7946cd38c54b7f1e0bf3 100644
--- a/core/phpstan-baseline.neon
+++ b/core/phpstan-baseline.neon
@@ -3336,26 +3336,6 @@ parameters:
 			count: 1
 			path: tests/Drupal/Tests/Core/Http/ClientFactoryTest.php
 
-		-
-			message: "#^Call to deprecated method withConsecutive\\(\\) of class PHPUnit\\\\Framework\\\\MockObject\\\\Builder\\\\InvocationMocker\\.$#"
-			count: 1
-			path: tests/Drupal/Tests/Core/Menu/ContextualLinkManagerTest.php
-
-		-
-			message: "#^Call to deprecated method withConsecutive\\(\\) of class PHPUnit\\\\Framework\\\\MockObject\\\\Builder\\\\InvocationMocker\\.$#"
-			count: 1
-			path: tests/Drupal/Tests/Core/Menu/DefaultMenuLinkTreeManipulatorsTest.php
-
-		-
-			message: "#^Call to deprecated method withConsecutive\\(\\) of class PHPUnit\\\\Framework\\\\MockObject\\\\Builder\\\\InvocationMocker\\.$#"
-			count: 2
-			path: tests/Drupal/Tests/Core/Menu/LocalTaskManagerTest.php
-
-		-
-			message: "#^Call to deprecated method withConsecutive\\(\\) of class PHPUnit\\\\Framework\\\\MockObject\\\\Builder\\\\InvocationMocker\\.$#"
-			count: 1
-			path: tests/Drupal/Tests/Core/Menu/StaticMenuLinkOverridesTest.php
-
 		-
 			message: "#^Call to method getDefinitions\\(\\) on an unknown class Drupal\\\\Core\\\\Plugin\\\\CategorizingPluginManagerTrait\\.$#"
 			count: 1
diff --git a/core/tests/Drupal/Tests/Core/Menu/ContextualLinkManagerTest.php b/core/tests/Drupal/Tests/Core/Menu/ContextualLinkManagerTest.php
index 94735d890faac6dc2139439e502816a9ae30369a..4d235bec59b444499ea8d4da3878f708547ded98 100644
--- a/core/tests/Drupal/Tests/Core/Menu/ContextualLinkManagerTest.php
+++ b/core/tests/Drupal/Tests/Core/Menu/ContextualLinkManagerTest.php
@@ -13,7 +13,7 @@
 use Drupal\Core\Menu\ContextualLinkDefault;
 use Drupal\Core\Menu\ContextualLinkManager;
 use Drupal\Tests\UnitTestCase;
-use PHPUnit\Framework\Constraint\Count;
+use Prophecy\Argument;
 use Symfony\Component\HttpFoundation\RequestStack;
 
 /**
@@ -46,7 +46,7 @@ class ContextualLinkManagerTest extends UnitTestCase {
   /**
    * The mocked module handler.
    *
-   * @var \Drupal\Core\Extension\ModuleHandlerInterface|\PHPUnit\Framework\MockObject\MockObject
+   * @var \Drupal\Core\Extension\ModuleHandlerInterface|\Prophecy\Prophecy\ObjectProphecy
    */
   protected $moduleHandler;
 
@@ -75,11 +75,7 @@ protected function setUp(): void {
       ->method('getCurrentLanguage')
       ->willReturn(new Language(['id' => 'en']));
 
-    $this->moduleHandler = $this->createMock(ModuleHandlerInterface::class);
-    $this->moduleHandler->expects($this->any())
-      ->method('getModuleDirectories')
-      ->willReturn([]);
-
+    $this->moduleHandler = $this->prophesize(ModuleHandlerInterface::class);
     $this->pluginDiscovery = $this->createMock('Drupal\Component\Plugin\Discovery\DiscoveryInterface');
     $this->cacheBackend = $this->createMock('Drupal\Core\Cache\CacheBackendInterface');
     $this->accessManager = $this->createMock('Drupal\Core\Access\AccessManagerInterface');
@@ -87,7 +83,7 @@ protected function setUp(): void {
 
     $this->contextualLinkManager = new ContextualLinkManager(
       $this->createMock(ControllerResolverInterface::class),
-      $this->moduleHandler,
+      $this->moduleHandler->reveal(),
       $this->cacheBackend,
       $language_manager,
       $this->accessManager,
@@ -247,12 +243,10 @@ public function testGetContextualLinksArrayByGroup() {
       ->method('checkNamedRoute')
       ->willReturn(AccessResult::allowed());
 
-    $this->moduleHandler->expects($this->exactly(2))
-      ->method('alter')
-      ->withConsecutive(
-        ['contextual_links_plugins'],
-        ['contextual_links', new Count(2), 'group1', ['key' => 'value']],
-      );
+    $this->moduleHandler->alter('contextual_links_plugins', Argument::cetera())
+      ->shouldBeCalledOnce();
+    $this->moduleHandler->alter('contextual_links', Argument::size(2), 'group1', ['key' => 'value'])
+      ->shouldBeCalledOnce();
 
     $result = $this->contextualLinkManager->getContextualLinksArrayByGroup('group1', ['key' => 'value']);
     $this->assertCount(2, $result);
@@ -328,9 +322,8 @@ public function testPluginDefinitionAlter() {
       ->method('getDefinitions')
       ->willReturn($definitions);
 
-    $this->moduleHandler->expects($this->once())
-      ->method('alter')
-      ->with('contextual_links_plugins', $definitions);
+    $this->moduleHandler->alter('contextual_links_plugins', $definitions)
+      ->shouldBeCalledOnce();
 
     $this->contextualLinkManager->getDefinition('test_plugin');
   }
diff --git a/core/tests/Drupal/Tests/Core/Menu/DefaultMenuLinkTreeManipulatorsTest.php b/core/tests/Drupal/Tests/Core/Menu/DefaultMenuLinkTreeManipulatorsTest.php
index ff585943c4836546f4f14767e82b93b394302057..896699b805176222ab6c0d57e3af1e439661df2e 100644
--- a/core/tests/Drupal/Tests/Core/Menu/DefaultMenuLinkTreeManipulatorsTest.php
+++ b/core/tests/Drupal/Tests/Core/Menu/DefaultMenuLinkTreeManipulatorsTest.php
@@ -321,23 +321,16 @@ public function testCheckNodeAccess() {
       6 => new MenuLinkTreeElement($links[6], FALSE, 2, FALSE, []),
     ]);
 
-    $query = $this->createMock('Drupal\Core\Entity\Query\QueryInterface');
-    $query->expects($this->once())
-      ->method('accessCheck')
-      ->with(TRUE);
-    $query->expects($this->exactly(2))
-      ->method('condition')
-      ->withConsecutive(
-        ['nid', [1, 2, 3, 4]],
-        ['status', NodeInterface::PUBLISHED],
-      );
-    $query->expects($this->once())
-      ->method('execute')
-      ->willReturn([1, 2, 4]);
+    $query = $this->prophesize('Drupal\Core\Entity\Query\QueryInterface');
+    $query->accessCheck(TRUE)->shouldBeCalled();
+    $query->condition('nid', [1, 2, 3, 4], 'IN')->shouldBeCalled();
+    $query->condition('status', NodeInterface::PUBLISHED)->shouldBeCalled();
+    $query->execute()->willReturn([1, 2, 4]);
+
     $storage = $this->createMock(EntityStorageInterface::class);
     $storage->expects($this->once())
       ->method('getQuery')
-      ->willReturn($query);
+      ->willReturn($query->reveal());
     $this->entityTypeManager->expects($this->once())
       ->method('getStorage')
       ->with('node')
diff --git a/core/tests/Drupal/Tests/Core/Menu/LocalTaskManagerTest.php b/core/tests/Drupal/Tests/Core/Menu/LocalTaskManagerTest.php
index 7c554e0a22e80f40be46a4587dc12fbd29a39469..5ee43089ad2aff29e02bb2175c3eb88359ce369c 100644
--- a/core/tests/Drupal/Tests/Core/Menu/LocalTaskManagerTest.php
+++ b/core/tests/Drupal/Tests/Core/Menu/LocalTaskManagerTest.php
@@ -70,7 +70,7 @@ class LocalTaskManagerTest extends UnitTestCase {
   /**
    * The cache backend used in the test.
    *
-   * @var \PHPUnit\Framework\MockObject\MockObject
+   * @var \Drupal\Core\Cache\CacheBackendInterface|\Prophecy\Prophecy\ObjectProphecy
    */
   protected $cacheBackend;
 
@@ -106,7 +106,7 @@ protected function setUp(): void {
     $this->routeProvider = $this->createMock('Drupal\Core\Routing\RouteProviderInterface');
     $this->pluginDiscovery = $this->createMock('Drupal\Component\Plugin\Discovery\DiscoveryInterface');
     $this->factory = $this->createMock('Drupal\Component\Plugin\Factory\FactoryInterface');
-    $this->cacheBackend = $this->createMock('Drupal\Core\Cache\CacheBackendInterface');
+    $this->cacheBackend = $this->prophesize('Drupal\Core\Cache\CacheBackendInterface');
     $this->accessManager = $this->createMock('Drupal\Core\Access\AccessManagerInterface');
     $this->routeMatch = $this->createMock('Drupal\Core\Routing\RouteMatchInterface');
     $this->account = $this->createMock('Drupal\Core\Session\AccountInterface');
@@ -180,18 +180,15 @@ public function testGetLocalTaskForRouteWithEmptyCache() {
 
     $result = $this->getLocalTasksForRouteResult($mock_plugin);
 
-    $this->cacheBackend->expects($this->exactly(2))
-      ->method('get')
-      ->withConsecutive(
-        ['local_task_plugins:en:menu_local_task_test_tasks_view'],
-        ['local_task_plugins:en'],
-      );
-    $this->cacheBackend->expects($this->exactly(2))
-      ->method('set')
-      ->withConsecutive(
-        ['local_task_plugins:en', $definitions, Cache::PERMANENT],
-        ['local_task_plugins:en:menu_local_task_test_tasks_view', $this->getLocalTasksCache(), Cache::PERMANENT, ['local_task']],
-      );
+    $this->cacheBackend->get('local_task_plugins:en:menu_local_task_test_tasks_view')
+      ->shouldBeCalled();
+    $this->cacheBackend->get('local_task_plugins:en')
+      ->shouldBeCalled();
+
+    $this->cacheBackend->set('local_task_plugins:en', $definitions, Cache::PERMANENT, ["local_task"])
+      ->shouldBeCalled();
+    $this->cacheBackend->set('local_task_plugins:en:menu_local_task_test_tasks_view', $this->getLocalTasksCache(), Cache::PERMANENT, ['local_task'])
+      ->shouldBeCalled();
 
     $local_tasks = $this->manager->getLocalTasksForRoute('menu_local_task_test_tasks_view');
     $this->assertEquals($result, $local_tasks);
@@ -211,13 +208,11 @@ public function testGetLocalTaskForRouteWithFilledCache() {
 
     $result = $this->getLocalTasksCache();
 
-    $this->cacheBackend->expects($this->once())
-      ->method('get')
-      ->with('local_task_plugins:en:menu_local_task_test_tasks_view')
+    $this->cacheBackend->get('local_task_plugins:en:menu_local_task_test_tasks_view')
       ->willReturn((object) ['data' => $result]);
 
-    $this->cacheBackend->expects($this->never())
-      ->method('set');
+    $this->cacheBackend->set()
+      ->shouldNotBeCalled();
 
     $result = $this->getLocalTasksForRouteResult($mock_plugin);
     $local_tasks = $this->manager->getLocalTasksForRoute('menu_local_task_test_tasks_view');
@@ -257,7 +252,7 @@ protected function setupLocalTaskManager() {
       ->method('getCurrentLanguage')
       ->willReturn(new Language(['id' => 'en']));
 
-    $this->manager = new LocalTaskManager($this->argumentResolver, $request_stack, $this->routeMatch, $this->routeProvider, $module_handler, $this->cacheBackend, $language_manager, $this->accessManager, $this->account);
+    $this->manager = new LocalTaskManager($this->argumentResolver, $request_stack, $this->routeMatch, $this->routeProvider, $module_handler, $this->cacheBackend->reveal(), $language_manager, $this->accessManager, $this->account);
 
     $property = new \ReflectionProperty('Drupal\Core\Menu\LocalTaskManager', 'discovery');
     $property->setValue($this->manager, $this->pluginDiscovery);
diff --git a/core/tests/Drupal/Tests/Core/Menu/StaticMenuLinkOverridesTest.php b/core/tests/Drupal/Tests/Core/Menu/StaticMenuLinkOverridesTest.php
index 8dabf4ccae1619ffbeec025662b97f4d9e49a5cc..39983742006e6b5492fb21ef601a8ee31ec8948b 100644
--- a/core/tests/Drupal/Tests/Core/Menu/StaticMenuLinkOverridesTest.php
+++ b/core/tests/Drupal/Tests/Core/Menu/StaticMenuLinkOverridesTest.php
@@ -110,12 +110,15 @@ public function testSaveOverride() {
         $definition_save_1['definitions'],
         $definition_save_1['definitions'],
       );
-    $config->expects($this->exactly(2))
+    $definitions = [
+      $definition_save_1['definitions'],
+      $definitions_save_2['definitions'],
+    ];
+    $config->expects($this->exactly(count($definitions)))
       ->method('set')
-      ->withConsecutive(
-        ['definitions', $definition_save_1['definitions']],
-        ['definitions', $definitions_save_2['definitions']],
-      )
+      ->with('definitions', $this->callback(function (array $value) use (&$definitions): bool {
+        return array_shift($definitions) === $value;
+      }))
       ->will($this->returnSelf());
     $config->expects($this->exactly(2))
       ->method('save');