diff --git a/core/modules/image/tests/src/Unit/ImageStyleTest.php b/core/modules/image/tests/src/Unit/ImageStyleTest.php
index c0a80032b27e5fc23705fb7e2ed1f6e1e7521bee..6b4685148fc0ef501eedee753f846645902911c3 100644
--- a/core/modules/image/tests/src/Unit/ImageStyleTest.php
+++ b/core/modules/image/tests/src/Unit/ImageStyleTest.php
@@ -209,7 +209,7 @@ public function testFlush() {
     $stream_wrapper_manager = $this->createMock('\Drupal\Core\StreamWrapper\StreamWrapperManagerInterface');
     $stream_wrapper_manager->expects($this->any())
       ->method('getWrappers')
-      ->will($this->returnValue([]));
+      ->willReturn([]);
     $theme_registry = $this->createMock('\Drupal\Core\Theme\Registry');
 
     $container = new ContainerBuilder();
diff --git a/core/tests/Drupal/Tests/Core/Entity/Query/Sql/QueryTest.php b/core/tests/Drupal/Tests/Core/Entity/Query/Sql/QueryTest.php
index 0da918c29f79800ebe53d77d6cdbd9294c986c66..fcaa9b6a0a7adbe20bbd74eb3cb172aef8cb8b9e 100644
--- a/core/tests/Drupal/Tests/Core/Entity/Query/Sql/QueryTest.php
+++ b/core/tests/Drupal/Tests/Core/Entity/Query/Sql/QueryTest.php
@@ -40,7 +40,7 @@ protected function setUp(): void {
     $container->expects($this->any())
       ->method('get')
       ->with('module_handler')
-      ->will($this->returnValue($this->createMock(ModuleHandler::class)));
+      ->willReturn($this->createMock(ModuleHandler::class));
     \Drupal::setContainer($container);
   }