diff --git a/core/modules/image/tests/src/Unit/ImageStyleTest.php b/core/modules/image/tests/src/Unit/ImageStyleTest.php
index 5025e43911dcf1a77960c9d9913645b0eec928ce..9b923062f143bc0c4940f4e88045bb0bed1dd6bb 100644
--- a/core/modules/image/tests/src/Unit/ImageStyleTest.php
+++ b/core/modules/image/tests/src/Unit/ImageStyleTest.php
@@ -140,7 +140,7 @@ public function testBuildUri() {
       ->getMock();
     $image_effect->expects($this->any())
       ->method('getDerivativeExtension')
-      ->will($this->returnArgument(0));
+      ->willReturnArgument(0);
 
     $image_style = $this->getImageStyleMock($image_effect_id, $image_effect);
     $this->assertEquals($image_style->buildUri('public://test.jpeg'), 'public://styles/' . $image_style->id() . '/public/test.jpeg');
@@ -183,7 +183,7 @@ public function testGetPathToken() {
       ->getMock();
     $image_effect->expects($this->any())
       ->method('getDerivativeExtension')
-      ->will($this->returnArgument(0));
+      ->willReturnArgument(0);
 
     $image_style = $this->getImageStyleMock($image_effect_id, $image_effect, ['getPrivateKey', 'getHashSalt']);
     $image_style->expects($this->any())
diff --git a/core/modules/system/tests/src/Unit/Breadcrumbs/PathBasedBreadcrumbBuilderTest.php b/core/modules/system/tests/src/Unit/Breadcrumbs/PathBasedBreadcrumbBuilderTest.php
index d0fc897a117369625010e4823293f9a70c30a02e..f2f1d6e20cdf3ed3131e49bc4e3cd8ef36cc602c 100644
--- a/core/modules/system/tests/src/Unit/Breadcrumbs/PathBasedBreadcrumbBuilderTest.php
+++ b/core/modules/system/tests/src/Unit/Breadcrumbs/PathBasedBreadcrumbBuilderTest.php
@@ -400,7 +400,7 @@ public function setupAccessManagerToAllow() {
   protected function setupStubPathProcessor() {
     $this->pathProcessor->expects($this->any())
       ->method('processInbound')
-      ->will($this->returnArgument(0));
+      ->willReturnArgument(0);
   }
 
 }
diff --git a/core/tests/Drupal/Tests/Core/Image/ImageTest.php b/core/tests/Drupal/Tests/Core/Image/ImageTest.php
index 53788d4b84b8e10da9f1a90b289d50b0afb31f8e..57ac5de1064a43f90b3d10ebc29e1a2998681f34 100644
--- a/core/tests/Drupal/Tests/Core/Image/ImageTest.php
+++ b/core/tests/Drupal/Tests/Core/Image/ImageTest.php
@@ -296,7 +296,7 @@ public function testScaleWidth() {
     $this->getTestImageForOperation('Scale');
     $this->toolkitOperation->expects($this->once())
       ->method('execute')
-      ->will($this->returnArgument(0));
+      ->willReturnArgument(0);
 
     $ret = $this->image->scale(44, NULL, FALSE);
     $this->assertEquals(50, $ret['height']);
@@ -309,7 +309,7 @@ public function testScaleHeight() {
     $this->getTestImageForOperation('Scale');
     $this->toolkitOperation->expects($this->once())
       ->method('execute')
-      ->will($this->returnArgument(0));
+      ->willReturnArgument(0);
 
     $ret = $this->image->scale(NULL, 50, FALSE);
     $this->assertEquals(44, $ret['width']);
@@ -323,7 +323,7 @@ public function testScaleSame() {
     // Dimensions are the same, resize should not be called.
     $this->toolkitOperation->expects($this->once())
       ->method('execute')
-      ->will($this->returnArgument(0));
+      ->willReturnArgument(0);
 
     $ret = $this->image->scale(88, 100, FALSE);
     $this->assertEquals(88, $ret['width']);
@@ -337,7 +337,7 @@ public function testScaleAndCropWidth() {
     $this->getTestImageForOperation('ScaleAndCrop');
     $this->toolkitOperation->expects($this->once())
       ->method('execute')
-      ->will($this->returnArgument(0));
+      ->willReturnArgument(0);
 
     $ret = $this->image->scaleAndCrop(34, 50);
     $this->assertEquals(5, $ret['x']);
@@ -350,7 +350,7 @@ public function testScaleAndCropHeight() {
     $this->getTestImageForOperation('ScaleAndCrop');
     $this->toolkitOperation->expects($this->once())
       ->method('execute')
-      ->will($this->returnArgument(0));
+      ->willReturnArgument(0);
 
     $ret = $this->image->scaleAndCrop(44, 40);
     $this->assertEquals(5, $ret['y']);
@@ -363,7 +363,7 @@ public function testScaleAndCropFails() {
     $this->getTestImageForOperation('ScaleAndCrop');
     $this->toolkitOperation->expects($this->once())
       ->method('execute')
-      ->will($this->returnArgument(0));
+      ->willReturnArgument(0);
 
     $ret = $this->image->scaleAndCrop(44, 40);
     $this->assertEquals(0, $ret['x']);
@@ -379,7 +379,7 @@ public function testCropWidth() {
     $this->getTestImageForOperation('Crop');
     $this->toolkitOperation->expects($this->once())
       ->method('execute')
-      ->will($this->returnArgument(0));
+      ->willReturnArgument(0);
 
     // Cropping with width only should preserve the aspect ratio.
     $ret = $this->image->crop(0, 0, 44);
@@ -393,7 +393,7 @@ public function testCropHeight() {
     $this->getTestImageForOperation('Crop');
     $this->toolkitOperation->expects($this->once())
       ->method('execute')
-      ->will($this->returnArgument(0));
+      ->willReturnArgument(0);
 
     // Cropping with height only should preserve the aspect ratio.
     $ret = $this->image->crop(0, 0, NULL, 50);
@@ -407,7 +407,7 @@ public function testCrop() {
     $this->getTestImageForOperation('Crop');
     $this->toolkitOperation->expects($this->once())
       ->method('execute')
-      ->will($this->returnArgument(0));
+      ->willReturnArgument(0);
 
     $ret = $this->image->crop(0, 0, 44, 50);
     $this->assertEquals(44, $ret['width']);
@@ -420,7 +420,7 @@ public function testConvert() {
     $this->getTestImageForOperation('Convert');
     $this->toolkitOperation->expects($this->once())
       ->method('execute')
-      ->will($this->returnArgument(0));
+      ->willReturnArgument(0);
 
     $ret = $this->image->convert('png');
     $this->assertEquals('png', $ret['extension']);
@@ -433,7 +433,7 @@ public function testResize() {
     $this->getTestImageForOperation('Resize');
     $this->toolkitOperation->expects($this->once())
       ->method('execute')
-      ->will($this->returnArgument(0));
+      ->willReturnArgument(0);
 
     // Resize with integer for width and height.
     $ret = $this->image->resize(30, 40);
@@ -448,7 +448,7 @@ public function testFloatResize() {
     $this->getTestImageForOperation('Resize');
     $this->toolkitOperation->expects($this->once())
       ->method('execute')
-      ->will($this->returnArgument(0));
+      ->willReturnArgument(0);
 
     // Pass a float for width.
     $ret = $this->image->resize(30.4, 40);
@@ -463,7 +463,7 @@ public function testDesaturate() {
     $this->getTestImageForOperation('Desaturate');
     $this->toolkitOperation->expects($this->once())
       ->method('execute')
-      ->will($this->returnArgument(0));
+      ->willReturnArgument(0);
 
     $this->image->desaturate();
   }
@@ -475,7 +475,7 @@ public function testRotate() {
     $this->getTestImageForOperation('Rotate');
     $this->toolkitOperation->expects($this->once())
       ->method('execute')
-      ->will($this->returnArgument(0));
+      ->willReturnArgument(0);
 
     $ret = $this->image->rotate(90);
     $this->assertEquals(90, $ret['degrees']);
diff --git a/core/tests/Drupal/Tests/Core/Render/ElementInfoManagerTest.php b/core/tests/Drupal/Tests/Core/Render/ElementInfoManagerTest.php
index aae2733dbe21b1552dd31951be165335207b6e66..601b2a43bc9a6a627611a26667fd0c144acf5a46 100644
--- a/core/tests/Drupal/Tests/Core/Render/ElementInfoManagerTest.php
+++ b/core/tests/Drupal/Tests/Core/Render/ElementInfoManagerTest.php
@@ -78,7 +78,7 @@ public function testGetInfoElementPlugin($plugin_class, $expected_info) {
     $this->moduleHandler->expects($this->once())
       ->method('alter')
       ->with('element_info', $this->anything())
-      ->will($this->returnArgument(0));
+      ->willReturnArgument(0);
 
     $plugin = $this->createMock($plugin_class);
     $plugin->expects($this->once())
diff --git a/core/tests/Drupal/Tests/Core/UnroutedUrlTest.php b/core/tests/Drupal/Tests/Core/UnroutedUrlTest.php
index c2cda9eaa94b8e2a953141e202b90fcf9fc836a6..801d52de5bac31c669950a48f9874ebc90947662 100644
--- a/core/tests/Drupal/Tests/Core/UnroutedUrlTest.php
+++ b/core/tests/Drupal/Tests/Core/UnroutedUrlTest.php
@@ -53,7 +53,7 @@ protected function setUp(): void {
     $this->urlAssembler = $this->createMock('Drupal\Core\Utility\UnroutedUrlAssemblerInterface');
     $this->urlAssembler->expects($this->any())
       ->method('assemble')
-      ->will($this->returnArgument(0));
+      ->willReturnArgument(0);
 
     $this->router = $this->createMock('Drupal\Tests\Core\Routing\TestRouterInterface');
     $container = new ContainerBuilder();
diff --git a/core/tests/Drupal/Tests/Core/Utility/LinkGeneratorTest.php b/core/tests/Drupal/Tests/Core/Utility/LinkGeneratorTest.php
index 46a6ac0d42987f4f2533c73c4e0bb07cd9d5696f..f0ff5078c7335fdf6d338f5f825fb45e8037cab9 100644
--- a/core/tests/Drupal/Tests/Core/Utility/LinkGeneratorTest.php
+++ b/core/tests/Drupal/Tests/Core/Utility/LinkGeneratorTest.php
@@ -251,7 +251,7 @@ public function testGenerateExternal() {
     $this->urlAssembler->expects($this->once())
       ->method('assemble')
       ->with('https://www.drupal.org', ['set_active_class' => TRUE, 'external' => TRUE] + $this->defaultOptions)
-      ->will($this->returnArgument(0));
+      ->willReturnArgument(0);
 
     $this->moduleHandler->expects($this->once())
       ->method('alter')