diff --git a/core/modules/block/tests/src/Unit/BlockConfigEntityUnitTest.php b/core/modules/block/tests/src/Unit/BlockConfigEntityUnitTest.php
index 77a8d59798e40f6dd842850b96225aa3aadb3917..f26901fc7b826708dfa7b6c6e186946b06a9f4a1 100644
--- a/core/modules/block/tests/src/Unit/BlockConfigEntityUnitTest.php
+++ b/core/modules/block/tests/src/Unit/BlockConfigEntityUnitTest.php
@@ -66,13 +66,13 @@ protected function setUp(): void {
     $this->entityType = $this->createMock('\Drupal\Core\Entity\EntityTypeInterface');
     $this->entityType->expects($this->any())
       ->method('getProvider')
-      ->will($this->returnValue('block'));
+      ->willReturn('block');
 
     $this->entityTypeManager = $this->createMock(EntityTypeManagerInterface::class);
     $this->entityTypeManager->expects($this->any())
       ->method('getDefinition')
       ->with($this->entityTypeId)
-      ->will($this->returnValue($this->entityType));
+      ->willReturn($this->entityType);
 
     $this->uuid = $this->createMock('\Drupal\Component\Uuid\UuidInterface');
 
@@ -111,13 +111,13 @@ public function testCalculateDependencies() {
     $plugin_collection->expects($this->atLeastOnce())
       ->method('get')
       ->with($instance_id)
-      ->will($this->returnValue($instance));
+      ->willReturn($instance);
     $plugin_collection->addInstanceId($instance_id);
 
     // Return the mocked plugin collection.
     $entity->expects($this->once())
       ->method('getPluginCollections')
-      ->will($this->returnValue([$plugin_collection]));
+      ->willReturn([$plugin_collection]);
 
     $dependencies = $entity->calculateDependencies()->getDependencies();
     $this->assertContains('test', $dependencies['module']);
diff --git a/core/modules/block/tests/src/Unit/BlockFormTest.php b/core/modules/block/tests/src/Unit/BlockFormTest.php
index 249e18da27f34a114f195f06c4dfe34c0ab4f134..fdaee38e1ede03223fa4832e440097ed7377a3e5 100644
--- a/core/modules/block/tests/src/Unit/BlockFormTest.php
+++ b/core/modules/block/tests/src/Unit/BlockFormTest.php
@@ -79,7 +79,7 @@ protected function setUp(): void {
     $this->themeHandler = $this->createMock('Drupal\Core\Extension\ThemeHandlerInterface');
     $this->entityTypeManager->expects($this->any())
       ->method('getStorage')
-      ->will($this->returnValue($this->storage));
+      ->willReturn($this->storage);
 
     $this->pluginFormFactory = $this->prophesize(PluginFormFactoryInterface::class);
   }
@@ -99,14 +99,14 @@ protected function getBlockMockWithMachineName($machine_name) {
       ->getMock();
     $plugin->expects($this->any())
       ->method('getMachineNameSuggestion')
-      ->will($this->returnValue($machine_name));
+      ->willReturn($machine_name);
 
     $block = $this->getMockBuilder(Block::class)
       ->disableOriginalConstructor()
       ->getMock();
     $block->expects($this->any())
       ->method('getPlugin')
-      ->will($this->returnValue($plugin));
+      ->willReturn($plugin);
     return $block;
   }
 
@@ -126,15 +126,15 @@ public function testGetUniqueMachineName() {
     $query = $this->createMock('Drupal\Core\Entity\Query\QueryInterface');
     $query->expects($this->exactly(5))
       ->method('condition')
-      ->will($this->returnValue($query));
+      ->willReturn($query);
 
     $query->expects($this->exactly(5))
       ->method('execute')
-      ->will($this->returnValue(['test', 'other_test', 'other_test_1', 'other_test_2']));
+      ->willReturn(['test', 'other_test', 'other_test_1', 'other_test_2']);
 
     $this->storage->expects($this->exactly(5))
       ->method('getQuery')
-      ->will($this->returnValue($query));
+      ->willReturn($query);
 
     $block_form_controller = new BlockForm($this->entityTypeManager, $this->conditionManager, $this->contextRepository, $this->language, $this->themeHandler, $this->pluginFormFactory->reveal());
 
diff --git a/core/modules/block/tests/src/Unit/BlockRepositoryTest.php b/core/modules/block/tests/src/Unit/BlockRepositoryTest.php
index c325a5d0db27148608d79257edc72cc6bb486939..9a13978fe13489b22d0698ae5b5976ef62cb0b00 100644
--- a/core/modules/block/tests/src/Unit/BlockRepositoryTest.php
+++ b/core/modules/block/tests/src/Unit/BlockRepositoryTest.php
@@ -56,7 +56,7 @@ protected function setUp(): void {
     $theme_manager = $this->createMock('Drupal\Core\Theme\ThemeManagerInterface');
     $theme_manager->expects($this->atLeastOnce())
       ->method('getActiveTheme')
-      ->will($this->returnValue($active_theme));
+      ->willReturn($active_theme);
 
     $this->contextHandler = $this->createMock('Drupal\Core\Plugin\Context\ContextHandlerInterface');
     $this->blockStorage = $this->createMock('Drupal\Core\Entity\EntityStorageInterface');
@@ -82,7 +82,7 @@ public function testGetVisibleBlocksPerRegion(array $blocks_config, array $expec
       $block = $this->createMock('Drupal\block\BlockInterface');
       $block->expects($this->once())
         ->method('access')
-        ->will($this->returnValue($block_config[0]));
+        ->willReturn($block_config[0]);
       $block->expects($block_config[0] ? $this->atLeastOnce() : $this->never())
         ->method('getRegion')
         ->willReturn($block_config[1]);
diff --git a/core/modules/block/tests/src/Unit/CategoryAutocompleteTest.php b/core/modules/block/tests/src/Unit/CategoryAutocompleteTest.php
index 94bdee2e101888c68e0dcbe384d14990d4e1fbf4..817c88bd5ae5ef46b978fbcf01e75b2732b71648 100644
--- a/core/modules/block/tests/src/Unit/CategoryAutocompleteTest.php
+++ b/core/modules/block/tests/src/Unit/CategoryAutocompleteTest.php
@@ -27,7 +27,7 @@ protected function setUp(): void {
     $block_manager = $this->createMock('Drupal\Core\Block\BlockManagerInterface');
     $block_manager->expects($this->any())
       ->method('getCategories')
-      ->will($this->returnValue(['Comment', 'Node', 'None & Such', 'User']));
+      ->willReturn(['Comment', 'Node', 'None & Such', 'User']);
 
     $this->autocompleteController = new CategoryAutocompleteController($block_manager);
   }
diff --git a/core/modules/block/tests/src/Unit/Menu/BlockLocalTasksTest.php b/core/modules/block/tests/src/Unit/Menu/BlockLocalTasksTest.php
index dd2f2e049f62938da0700b3fe32e33ca7b66ddec..0141e107e81cf396e12a1164408b6f138cbc289c 100644
--- a/core/modules/block/tests/src/Unit/Menu/BlockLocalTasksTest.php
+++ b/core/modules/block/tests/src/Unit/Menu/BlockLocalTasksTest.php
@@ -46,7 +46,7 @@ protected function setUp(): void {
     $theme_handler = $this->createMock('Drupal\Core\Extension\ThemeHandlerInterface');
     $theme_handler->expects($this->any())
       ->method('listInfo')
-      ->will($this->returnValue($themes));
+      ->willReturn($themes);
     $theme_handler->expects($this->any())
       ->method('hasUi')
       ->willReturnMap([
diff --git a/core/modules/block/tests/src/Unit/Plugin/DisplayVariant/BlockPageVariantTest.php b/core/modules/block/tests/src/Unit/Plugin/DisplayVariant/BlockPageVariantTest.php
index 4528737fe22b6c2485938b814dd90726c54740ef..946387c7c2912e35fe9b4b6ad358571686d82496 100644
--- a/core/modules/block/tests/src/Unit/Plugin/DisplayVariant/BlockPageVariantTest.php
+++ b/core/modules/block/tests/src/Unit/Plugin/DisplayVariant/BlockPageVariantTest.php
@@ -219,7 +219,7 @@ public function testBuild(array $blocks_config, $visible_block_count, array $exp
     }
     $this->blockViewBuilder->expects($this->exactly($visible_block_count))
       ->method('view')
-      ->will($this->returnValue([]));
+      ->willReturn([]);
     $this->blockRepository->expects($this->once())
       ->method('getVisibleBlocksPerRegion')
       ->willReturnCallback(function (&$cacheable_metadata) use ($blocks) {
diff --git a/core/modules/block_content/tests/src/Unit/Menu/BlockContentLocalTasksTest.php b/core/modules/block_content/tests/src/Unit/Menu/BlockContentLocalTasksTest.php
index ccce88c1863f123aac8c92a51b53a396d5b78578..4c407afcc2a73b564de781316bcf68f457b43b00 100644
--- a/core/modules/block_content/tests/src/Unit/Menu/BlockContentLocalTasksTest.php
+++ b/core/modules/block_content/tests/src/Unit/Menu/BlockContentLocalTasksTest.php
@@ -45,7 +45,7 @@ protected function setUp(): void {
     $theme_handler = $this->createMock('Drupal\Core\Extension\ThemeHandlerInterface');
     $theme_handler->expects($this->any())
       ->method('listInfo')
-      ->will($this->returnValue($themes));
+      ->willReturn($themes);
 
     $container = new ContainerBuilder();
     $container->set('config.factory', $config_factory);
diff --git a/core/modules/comment/tests/src/Unit/CommentManagerTest.php b/core/modules/comment/tests/src/Unit/CommentManagerTest.php
index cfc65d3af4c367c8ddeb25ddd155e23a5684683f..e93f9c86d077b920d90352fbbb3c59882c5243d1 100644
--- a/core/modules/comment/tests/src/Unit/CommentManagerTest.php
+++ b/core/modules/comment/tests/src/Unit/CommentManagerTest.php
@@ -26,28 +26,28 @@ public function testGetFields() {
     $entity_type = $this->createMock('Drupal\Core\Entity\ContentEntityTypeInterface');
     $entity_type->expects($this->any())
       ->method('getClass')
-      ->will($this->returnValue('Node'));
+      ->willReturn('Node');
     $entity_type->expects($this->any())
       ->method('entityClassImplements')
       ->with(FieldableEntityInterface::class)
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
 
     $entity_field_manager = $this->createMock(EntityFieldManagerInterface::class);
     $entity_type_manager = $this->createMock(EntityTypeManagerInterface::class);
 
     $entity_field_manager->expects($this->once())
       ->method('getFieldMapByFieldType')
-      ->will($this->returnValue([
+      ->willReturn([
         'node' => [
           'field_foobar' => [
             'type' => 'comment',
           ],
         ],
-      ]));
+      ]);
 
     $entity_type_manager->expects($this->any())
       ->method('getDefinition')
-      ->will($this->returnValue($entity_type));
+      ->willReturn($entity_type);
 
     $comment_manager = new CommentManager(
       $entity_type_manager,
diff --git a/core/modules/comment/tests/src/Unit/CommentStatisticsUnitTest.php b/core/modules/comment/tests/src/Unit/CommentStatisticsUnitTest.php
index b0412210e71722eeb2a841248cb12571a617e43b..76e44401dcbf3cbddefa9df325ebb69e5b9fbeb7 100644
--- a/core/modules/comment/tests/src/Unit/CommentStatisticsUnitTest.php
+++ b/core/modules/comment/tests/src/Unit/CommentStatisticsUnitTest.php
@@ -73,7 +73,7 @@ protected function setUp(): void {
 
     $this->select->expects($this->any())
       ->method('execute')
-      ->will($this->returnValue($this->statement));
+      ->willReturn($this->statement);
 
     $this->database = $this->getMockBuilder('Drupal\Core\Database\Connection')
       ->disableOriginalConstructor()
@@ -81,7 +81,7 @@ protected function setUp(): void {
 
     $this->database->expects($this->once())
       ->method('select')
-      ->will($this->returnValue($this->select));
+      ->willReturn($this->select);
 
     $this->commentStatistics = new CommentStatistics($this->database, $this->createMock('Drupal\Core\Session\AccountInterface'), $this->createMock(EntityTypeManagerInterface::class), $this->createMock('Drupal\Core\State\StateInterface'), $this->database);
   }
diff --git a/core/modules/comment/tests/src/Unit/Entity/CommentLockTest.php b/core/modules/comment/tests/src/Unit/Entity/CommentLockTest.php
index 304d2dd8555b6f3c86fb809510000f015dbd9876..3e70f0bb8a154a5484dff2708d3e6a0c3a199789 100644
--- a/core/modules/comment/tests/src/Unit/Entity/CommentLockTest.php
+++ b/core/modules/comment/tests/src/Unit/Entity/CommentLockTest.php
@@ -33,7 +33,7 @@ public function testLocks() {
     $lock->expects($this->once())
       ->method('acquire')
       ->with($lock_name, 30)
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
     $lock->expects($this->once())
       ->method('release')
       ->with($lock_name);
@@ -55,27 +55,27 @@ public function testLocks() {
       ->getMock();
     $comment->expects($this->once())
       ->method('isNew')
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
     $comment->expects($this->once())
       ->method('hasParentComment')
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
     $comment->expects($this->once())
       ->method('getParentComment')
-      ->will($this->returnValue($comment));
+      ->willReturn($comment);
     $comment->expects($this->once())
       ->method('getCommentedEntityId')
-      ->will($this->returnValue($cid));
+      ->willReturn($cid);
     $comment->expects($this->any())
       ->method('getThread')
-      ->will($this->returnValue(''));
+      ->willReturn('');
 
     $anon_user = $this->createMock('Drupal\Core\Session\AccountInterface');
     $anon_user->expects($this->any())
       ->method('isAnonymous')
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
     $comment->expects($this->any())
       ->method('getOwner')
-      ->will($this->returnValue($anon_user));
+      ->willReturn($anon_user);
 
     $parent_entity = $this->createMock('\Drupal\Core\Entity\ContentEntityInterface');
     $parent_entity->expects($this->atLeastOnce())
@@ -88,7 +88,7 @@ public function testLocks() {
     $entity_type = $this->createMock('\Drupal\Core\Entity\EntityTypeInterface');
     $comment->expects($this->any())
       ->method('getEntityType')
-      ->will($this->returnValue($entity_type));
+      ->willReturn($entity_type);
     $storage = $this->createMock('Drupal\comment\CommentStorageInterface');
 
     // preSave() should acquire the lock. (This is what's really being tested.)
diff --git a/core/modules/comment/tests/src/Unit/Plugin/views/field/CommentBulkFormTest.php b/core/modules/comment/tests/src/Unit/Plugin/views/field/CommentBulkFormTest.php
index d342bda45e8d7c5931a172868280153ca21d5e08..6a9aded8c94537d8c8a771d66269fc88d073024e 100644
--- a/core/modules/comment/tests/src/Unit/Plugin/views/field/CommentBulkFormTest.php
+++ b/core/modules/comment/tests/src/Unit/Plugin/views/field/CommentBulkFormTest.php
@@ -33,26 +33,26 @@ public function testConstructor() {
       $action = $this->createMock('\Drupal\system\ActionConfigEntityInterface');
       $action->expects($this->any())
         ->method('getType')
-        ->will($this->returnValue('comment'));
+        ->willReturn('comment');
       $actions[$i] = $action;
     }
 
     $action = $this->createMock('\Drupal\system\ActionConfigEntityInterface');
     $action->expects($this->any())
       ->method('getType')
-      ->will($this->returnValue('user'));
+      ->willReturn('user');
     $actions[] = $action;
 
     $entity_storage = $this->createMock('Drupal\Core\Entity\EntityStorageInterface');
     $entity_storage->expects($this->any())
       ->method('loadMultiple')
-      ->will($this->returnValue($actions));
+      ->willReturn($actions);
 
     $entity_type_manager = $this->createMock(EntityTypeManagerInterface::class);
     $entity_type_manager->expects($this->once())
       ->method('getStorage')
       ->with('action')
-      ->will($this->returnValue($entity_storage));
+      ->willReturn($entity_storage);
 
     $entity_repository = $this->createMock(EntityRepositoryInterface::class);
 
@@ -66,7 +66,7 @@ public function testConstructor() {
     $views_data->expects($this->any())
       ->method('get')
       ->with('comment')
-      ->will($this->returnValue(['table' => ['entity type' => 'comment']]));
+      ->willReturn(['table' => ['entity type' => 'comment']]);
     $container = new ContainerBuilder();
     $container->set('views.views_data', $views_data);
     $container->set('string_translation', $this->getStringTranslationStub());
@@ -76,7 +76,7 @@ public function testConstructor() {
     $storage->expects($this->any())
       ->method('get')
       ->with('base_table')
-      ->will($this->returnValue('comment'));
+      ->willReturn('comment');
 
     $executable = $this->getMockBuilder('Drupal\views\ViewExecutable')
       ->disableOriginalConstructor()
diff --git a/core/modules/config_translation/tests/src/Unit/ConfigEntityMapperTest.php b/core/modules/config_translation/tests/src/Unit/ConfigEntityMapperTest.php
index b78f0048f6d65f13ae55945af62f945580539b9d..ccae8e23b1dff755f611f94bd064e594de084dc6 100644
--- a/core/modules/config_translation/tests/src/Unit/ConfigEntityMapperTest.php
+++ b/core/modules/config_translation/tests/src/Unit/ConfigEntityMapperTest.php
@@ -70,7 +70,7 @@ protected function setUp(): void {
       ->expects($this->any())
       ->method('getRouteByName')
       ->with('entity.configurable_language.edit_form')
-      ->will($this->returnValue(new Route('/admin/config/regional/language/edit/{configurable_language}')));
+      ->willReturn(new Route('/admin/config/regional/language/edit/{configurable_language}'));
 
     $definition = [
       'class' => '\Drupal\config_translation\ConfigEntityMapper',
@@ -114,18 +114,18 @@ public function testEntityGetterAndSetter() {
       ->expects($this->once())
       ->method('id')
       ->with()
-      ->will($this->returnValue('entity_id'));
+      ->willReturn('entity_id');
 
     $entity_type = $this->createMock('Drupal\Core\Config\Entity\ConfigEntityTypeInterface');
     $entity_type
       ->expects($this->any())
       ->method('getConfigPrefix')
-      ->will($this->returnValue('config_prefix'));
+      ->willReturn('config_prefix');
     $this->entityTypeManager
       ->expects($this->once())
       ->method('getDefinition')
       ->with('configurable_language')
-      ->will($this->returnValue($entity_type));
+      ->willReturn($entity_type);
 
     // No entity is set.
     $this->assertNull($this->configEntityMapper->getEntity());
@@ -154,14 +154,14 @@ public function testGetOverviewRouteParameters() {
       ->expects($this->once())
       ->method('getDefinition')
       ->with('configurable_language')
-      ->will($this->returnValue($entity_type));
+      ->willReturn($entity_type);
     $this->configEntityMapper->setEntity($this->entity);
 
     $this->entity
       ->expects($this->once())
       ->method('id')
       ->with()
-      ->will($this->returnValue('entity_id'));
+      ->willReturn('entity_id');
 
     $result = $this->configEntityMapper->getOverviewRouteParameters();
 
@@ -183,12 +183,12 @@ public function testGetTypeName() {
     $entity_type = $this->createMock('Drupal\Core\Config\Entity\ConfigEntityTypeInterface');
     $entity_type->expects($this->once())
       ->method('getLabel')
-      ->will($this->returnValue('test'));
+      ->willReturn('test');
     $this->entityTypeManager
       ->expects($this->once())
       ->method('getDefinition')
       ->with('configurable_language')
-      ->will($this->returnValue($entity_type));
+      ->willReturn($entity_type);
 
     $result = $this->configEntityMapper->getTypeName();
     $this->assertSame('test', $result);
@@ -201,12 +201,12 @@ public function testGetTypeLabel() {
     $entity_type = $this->createMock('Drupal\Core\Config\Entity\ConfigEntityTypeInterface');
     $entity_type->expects($this->once())
       ->method('getLabel')
-      ->will($this->returnValue('test'));
+      ->willReturn('test');
     $this->entityTypeManager
       ->expects($this->once())
       ->method('getDefinition')
       ->with('configurable_language')
-      ->will($this->returnValue($entity_type));
+      ->willReturn($entity_type);
 
     $result = $this->configEntityMapper->getTypeLabel();
     $this->assertSame('test', $result);
diff --git a/core/modules/config_translation/tests/src/Unit/ConfigFieldMapperTest.php b/core/modules/config_translation/tests/src/Unit/ConfigFieldMapperTest.php
index e1f9b16ecdbea9fb5fdcfcce587d0defc9083b96..4c3a05ea95e0b545b4e30e52a82dc9d116016216 100644
--- a/core/modules/config_translation/tests/src/Unit/ConfigFieldMapperTest.php
+++ b/core/modules/config_translation/tests/src/Unit/ConfigFieldMapperTest.php
@@ -88,23 +88,23 @@ public function testSetEntity() {
     $entity_type
       ->expects($this->any())
       ->method('getConfigPrefix')
-      ->will($this->returnValue('config_prefix'));
+      ->willReturn('config_prefix');
 
     $this->entityTypeManager
       ->expects($this->any())
       ->method('getDefinition')
-      ->will($this->returnValue($entity_type));
+      ->willReturn($entity_type);
 
     $field_storage = $this->createMock('Drupal\field\FieldStorageConfigInterface');
     $field_storage
       ->expects($this->any())
       ->method('id')
-      ->will($this->returnValue('field_storage_id'));
+      ->willReturn('field_storage_id');
 
     $this->entity
       ->expects($this->any())
       ->method('getFieldStorageDefinition')
-      ->will($this->returnValue($field_storage));
+      ->willReturn($field_storage);
 
     $result = $this->configFieldMapper->setEntity($this->entity);
     $this->assertTrue($result);
diff --git a/core/modules/config_translation/tests/src/Unit/ConfigMapperManagerTest.php b/core/modules/config_translation/tests/src/Unit/ConfigMapperManagerTest.php
index 9c8f172d7c629b03eaacbea16dca43afa88b6a62..b91b61360319239a51b10628ca7ebcfdc461fd17 100644
--- a/core/modules/config_translation/tests/src/Unit/ConfigMapperManagerTest.php
+++ b/core/modules/config_translation/tests/src/Unit/ConfigMapperManagerTest.php
@@ -39,7 +39,7 @@ protected function setUp(): void {
     $language_manager->expects($this->once())
       ->method('getCurrentLanguage')
       ->with(LanguageInterface::TYPE_INTERFACE)
-      ->will($this->returnValue($language));
+      ->willReturn($language);
 
     $this->typedConfigManager = $this->getMockBuilder('Drupal\Core\Config\TypedConfigManagerInterface')
       ->getMock();
@@ -71,7 +71,7 @@ public function testHasTranslatable(TypedDataInterface $element, $expected) {
       ->expects($this->once())
       ->method('get')
       ->with('test')
-      ->will($this->returnValue($element));
+      ->willReturn($element);
 
     $result = $this->configMapperManager->hasTranslatable('test');
     $this->assertSame($expected, $result);
@@ -154,7 +154,7 @@ protected function getElement(array $definition) {
     $element = $this->createMock('Drupal\Core\TypedData\TypedDataInterface');
     $element->expects($this->any())
       ->method('getDataDefinition')
-      ->will($this->returnValue($data_definition));
+      ->willReturn($data_definition);
     return $element;
   }
 
@@ -179,7 +179,7 @@ protected function getNestedElement(array $elements) {
       ->getMock();
     $nested_element->expects($this->once())
       ->method('getIterator')
-      ->will($this->returnValue(new \ArrayIterator($elements)));
+      ->willReturn(new \ArrayIterator($elements));
     return $nested_element;
   }
 
diff --git a/core/modules/config_translation/tests/src/Unit/ConfigNamesMapperTest.php b/core/modules/config_translation/tests/src/Unit/ConfigNamesMapperTest.php
index 914c3002599a4e18a146ab8166cbc66a21035991..915ac9dc6064b3250900199914b7fdeca37a7aa8 100644
--- a/core/modules/config_translation/tests/src/Unit/ConfigNamesMapperTest.php
+++ b/core/modules/config_translation/tests/src/Unit/ConfigNamesMapperTest.php
@@ -128,7 +128,7 @@ protected function setUp(): void {
       ->expects($this->any())
       ->method('getRouteByName')
       ->with('system.site_information_settings')
-      ->will($this->returnValue($this->baseRoute));
+      ->willReturn($this->baseRoute);
 
     $this->languageManager = $this->createMock('Drupal\Core\Language\LanguageManagerInterface');
 
diff --git a/core/modules/contact/tests/src/Unit/MailHandlerTest.php b/core/modules/contact/tests/src/Unit/MailHandlerTest.php
index 439e5077bfe18427e1b3bd157346aa72e7d7fe05..57108d3fcefa4eba80eb9ac11e15efc02bece425 100644
--- a/core/modules/contact/tests/src/Unit/MailHandlerTest.php
+++ b/core/modules/contact/tests/src/Unit/MailHandlerTest.php
@@ -86,11 +86,11 @@ protected function setUp(): void {
 
     $this->languageManager->expects($this->any())
       ->method('getDefaultLanguage')
-      ->will($this->returnValue($language));
+      ->willReturn($language);
 
     $this->languageManager->expects($this->any())
       ->method('getCurrentLanguage')
-      ->will($this->returnValue($language));
+      ->willReturn($language);
   }
 
   /**
diff --git a/core/modules/content_moderation/tests/src/Unit/ContentModerationRouteSubscriberTest.php b/core/modules/content_moderation/tests/src/Unit/ContentModerationRouteSubscriberTest.php
index 8eeef3beba408919f1132494934713e3be11e943..6801ef7cf77a803d38eb03fb7303716d4f31649d 100644
--- a/core/modules/content_moderation/tests/src/Unit/ContentModerationRouteSubscriberTest.php
+++ b/core/modules/content_moderation/tests/src/Unit/ContentModerationRouteSubscriberTest.php
@@ -42,14 +42,14 @@ protected function setupEntityTypes() {
     $definition = $this->createMock(EntityTypeInterface::class);
     $definition->expects($this->any())
       ->method('getClass')
-      ->will($this->returnValue(TestEntity::class));
+      ->willReturn(TestEntity::class);
     $definition->expects($this->any())
       ->method('isRevisionable')
       ->willReturn(FALSE);
     $revisionable_definition = $this->createMock(EntityTypeInterface::class);
     $revisionable_definition->expects($this->any())
       ->method('getClass')
-      ->will($this->returnValue(TestEntity::class));
+      ->willReturn(TestEntity::class);
     $revisionable_definition->expects($this->any())
       ->method('isRevisionable')
       ->willReturn(TRUE);
diff --git a/core/modules/content_translation/tests/src/Unit/Access/ContentTranslationManageAccessCheckTest.php b/core/modules/content_translation/tests/src/Unit/Access/ContentTranslationManageAccessCheckTest.php
index 4e585c9a511d58f26d42912b5581bea8b43fbe2e..9c440fb0e02c912f24ede5ce0e35bfef0cbabc1d 100644
--- a/core/modules/content_translation/tests/src/Unit/Access/ContentTranslationManageAccessCheckTest.php
+++ b/core/modules/content_translation/tests/src/Unit/Access/ContentTranslationManageAccessCheckTest.php
@@ -53,13 +53,13 @@ public function testCreateAccess() {
     $translation_handler = $this->createMock('\Drupal\content_translation\ContentTranslationHandlerInterface');
     $translation_handler->expects($this->once())
       ->method('getTranslationAccess')
-      ->will($this->returnValue(AccessResult::allowed()));
+      ->willReturn(AccessResult::allowed());
 
     $entity_type_manager = $this->createMock(EntityTypeManagerInterface::class);
     $entity_type_manager->expects($this->once())
       ->method('getHandler')
       ->withAnyParameters()
-      ->will($this->returnValue($translation_handler));
+      ->willReturn($translation_handler);
 
     // Set our source and target languages.
     $source = 'en';
@@ -87,7 +87,7 @@ public function testCreateAccess() {
     $entity->expects($this->once())
       ->method('getTranslationLanguages')
       ->with()
-      ->will($this->returnValue([]));
+      ->willReturn([]);
     $entity->expects($this->once())
       ->method('getCacheContexts')
       ->willReturn([]);
@@ -96,7 +96,7 @@ public function testCreateAccess() {
       ->willReturn(Cache::PERMANENT);
     $entity->expects($this->once())
       ->method('getCacheTags')
-      ->will($this->returnValue(['node:1337']));
+      ->willReturn(['node:1337']);
     $entity->expects($this->once())
       ->method('getCacheContexts')
       ->willReturn([]);
@@ -110,7 +110,7 @@ public function testCreateAccess() {
     $route_match->expects($this->once())
       ->method('getParameter')
       ->with('node')
-      ->will($this->returnValue($entity));
+      ->willReturn($entity);
 
     // Set the mock account.
     $account = $this->createMock('Drupal\Core\Session\AccountInterface');
diff --git a/core/modules/content_translation/tests/src/Unit/Menu/ContentTranslationLocalTasksTest.php b/core/modules/content_translation/tests/src/Unit/Menu/ContentTranslationLocalTasksTest.php
index f347403c4bf33304fafb100cdabdc3f40f91cf65..00e300ba0696b9b13924edce396a576172aaebc6 100644
--- a/core/modules/content_translation/tests/src/Unit/Menu/ContentTranslationLocalTasksTest.php
+++ b/core/modules/content_translation/tests/src/Unit/Menu/ContentTranslationLocalTasksTest.php
@@ -34,9 +34,9 @@ protected function setUp(): void {
     $content_translation_manager = $this->createMock('Drupal\content_translation\ContentTranslationManagerInterface');
     $content_translation_manager->expects($this->any())
       ->method('getSupportedEntityTypes')
-      ->will($this->returnValue([
+      ->willReturn([
         'node' => $entity_type,
-      ]));
+      ]);
     \Drupal::getContainer()->set('content_translation.manager', $content_translation_manager);
     \Drupal::getContainer()->set('string_translation', $this->getStringTranslationStub());
   }
diff --git a/core/modules/datetime/tests/src/Unit/Plugin/migrate/field/DateFieldTest.php b/core/modules/datetime/tests/src/Unit/Plugin/migrate/field/DateFieldTest.php
index 1fce8a1a2f023535022e2823bf82bb140bb0885f..e3a7b8ed35e9161477c922ca46f677a83465c5ff 100644
--- a/core/modules/datetime/tests/src/Unit/Plugin/migrate/field/DateFieldTest.php
+++ b/core/modules/datetime/tests/src/Unit/Plugin/migrate/field/DateFieldTest.php
@@ -55,7 +55,7 @@ public function testDefineValueProcessPipeline($data, $from_format, $to_format)
     $migration->expects($this->once())
       ->method('mergeProcessOfProperty')
       ->with('field_date', $pipeline)
-      ->will($this->returnValue($migration));
+      ->willReturn($migration);
 
     $plugin = new DateField([], '', []);
     $plugin->defineValueProcessPipeline($migration, 'field_date', $data);
diff --git a/core/modules/editor/tests/src/Unit/EditorConfigEntityUnitTest.php b/core/modules/editor/tests/src/Unit/EditorConfigEntityUnitTest.php
index ab781b39235240b16dc91708d56c63d819b58651..89787633fa9ea6d4da673bdc091238f3c5eef854 100644
--- a/core/modules/editor/tests/src/Unit/EditorConfigEntityUnitTest.php
+++ b/core/modules/editor/tests/src/Unit/EditorConfigEntityUnitTest.php
@@ -65,13 +65,13 @@ protected function setUp(): void {
     $this->entityType = $this->createMock('\Drupal\Core\Entity\EntityTypeInterface');
     $this->entityType->expects($this->any())
       ->method('getProvider')
-      ->will($this->returnValue('editor'));
+      ->willReturn('editor');
 
     $this->entityTypeManager = $this->createMock(EntityTypeManagerInterface::class);
     $this->entityTypeManager->expects($this->any())
       ->method('getDefinition')
       ->with($this->entityTypeId)
-      ->will($this->returnValue($this->entityType));
+      ->willReturn($this->entityType);
 
     $this->uuid = $this->createMock('\Drupal\Component\Uuid\UuidInterface');
 
@@ -98,33 +98,33 @@ public function testCalculateDependencies() {
       ->getMock();
     $plugin->expects($this->once())
       ->method('getPluginDefinition')
-      ->will($this->returnValue(['provider' => 'test_module']));
+      ->willReturn(['provider' => 'test_module']);
     $plugin->expects($this->once())
       ->method('getDefaultSettings')
-      ->will($this->returnValue([]));
+      ->willReturn([]);
 
     $this->editorPluginManager->expects($this->any())
       ->method('createInstance')
       ->with($this->editorId)
-      ->will($this->returnValue($plugin));
+      ->willReturn($plugin);
 
     $entity = new Editor($values, $this->entityTypeId);
 
     $filter_format = $this->createMock('Drupal\Core\Config\Entity\ConfigEntityInterface');
     $filter_format->expects($this->once())
       ->method('getConfigDependencyName')
-      ->will($this->returnValue('filter.format.test'));
+      ->willReturn('filter.format.test');
 
     $storage = $this->createMock('Drupal\Core\Entity\EntityStorageInterface');
     $storage->expects($this->once())
       ->method('load')
       ->with($format_id)
-      ->will($this->returnValue($filter_format));
+      ->willReturn($filter_format);
 
     $this->entityTypeManager->expects($this->once())
       ->method('getStorage')
       ->with('filter_format')
-      ->will($this->returnValue($storage));
+      ->willReturn($storage);
 
     $dependencies = $entity->calculateDependencies()->getDependencies();
     $this->assertContains('test_module', $dependencies['module']);
diff --git a/core/modules/editor/tests/src/Unit/EditorXssFilter/StandardTest.php b/core/modules/editor/tests/src/Unit/EditorXssFilter/StandardTest.php
index 882ddb7ea7f03ddb9c7a7940512dc9bec0a60344..d3a52071275bb082e50ebc3886d393c93c52af6b 100644
--- a/core/modules/editor/tests/src/Unit/EditorXssFilter/StandardTest.php
+++ b/core/modules/editor/tests/src/Unit/EditorXssFilter/StandardTest.php
@@ -34,7 +34,7 @@ protected function setUp(): void {
       ->getMock();
     $this->format->expects($this->any())
       ->method('getFilterTypes')
-      ->will($this->returnValue([FilterInterface::TYPE_HTML_RESTRICTOR]));
+      ->willReturn([FilterInterface::TYPE_HTML_RESTRICTOR]);
     $restrictions = [
       'allowed' => [
         'p' => TRUE,
@@ -47,7 +47,7 @@ protected function setUp(): void {
     ];
     $this->format->expects($this->any())
       ->method('getHtmlRestrictions')
-      ->will($this->returnValue($restrictions));
+      ->willReturn($restrictions);
   }
 
   /**
diff --git a/core/modules/field/tests/src/Unit/FieldConfigEntityUnitTest.php b/core/modules/field/tests/src/Unit/FieldConfigEntityUnitTest.php
index 87945c8069aca6be0e16a53b866ea1d35526f42b..cb5e94cda3d556db370070a26353404cae23c325 100644
--- a/core/modules/field/tests/src/Unit/FieldConfigEntityUnitTest.php
+++ b/core/modules/field/tests/src/Unit/FieldConfigEntityUnitTest.php
@@ -95,10 +95,10 @@ protected function setUp(): void {
     $this->fieldStorage = $this->createMock('\Drupal\field\FieldStorageConfigInterface');
     $this->fieldStorage->expects($this->any())
       ->method('getType')
-      ->will($this->returnValue('test_field'));
+      ->willReturn('test_field');
     $this->fieldStorage->expects($this->any())
       ->method('getName')
-      ->will($this->returnValue('field_test'));
+      ->willReturn('field_test');
     $this->fieldStorage->expects($this->any())
       ->method('getSettings')
       ->willReturn([]);
@@ -106,9 +106,9 @@ protected function setUp(): void {
     $this->entityFieldManager->expects($this->any())
       ->method('getFieldStorageDefinitions')
       ->with('test_entity_type')
-      ->will($this->returnValue([
+      ->willReturn([
         $this->fieldStorage->getName() => $this->fieldStorage,
-      ]));
+      ]);
   }
 
   /**
@@ -119,7 +119,7 @@ public function testCalculateDependencies() {
     $target_entity_type = $this->createMock('\Drupal\Core\Entity\EntityTypeInterface');
     $target_entity_type->expects($this->any())
       ->method('getBundleConfigDependency')
-      ->will($this->returnValue(['type' => 'config', 'name' => 'test.test_entity_type.id']));
+      ->willReturn(['type' => 'config', 'name' => 'test.test_entity_type.id']);
 
     $this->entityTypeManager->expects($this->any())
       ->method('getDefinition')
@@ -135,7 +135,7 @@ public function testCalculateDependencies() {
 
     $this->fieldStorage->expects($this->once())
       ->method('getConfigDependencyName')
-      ->will($this->returnValue('field.storage.test_entity_type.test_field'));
+      ->willReturn('field.storage.test_entity_type.test_field');
 
     $field = new FieldConfig([
       'field_name' => $this->fieldStorage->getName(),
@@ -157,12 +157,12 @@ public function testCalculateDependenciesIncorrectBundle() {
     $storage->expects($this->any())
       ->method('load')
       ->with('test_bundle_not_exists')
-      ->will($this->returnValue(NULL));
+      ->willReturn(NULL);
 
     $this->entityTypeManager->expects($this->any())
       ->method('getStorage')
       ->with('bundle_entity_type')
-      ->will($this->returnValue($storage));
+      ->willReturn($storage);
 
     $target_entity_type = new EntityType([
       'id' => 'test_entity_type',
@@ -252,15 +252,15 @@ public function testToArray() {
     $this->entityTypeManager->expects($this->any())
       ->method('getDefinition')
       ->with($this->entityTypeId)
-      ->will($this->returnValue($this->entityType));
+      ->willReturn($this->entityType);
     $this->entityType->expects($this->once())
       ->method('getKey')
       ->with('id')
-      ->will($this->returnValue('id'));
+      ->willReturn('id');
     $this->entityType->expects($this->once())
       ->method('getPropertiesToExport')
       ->with('test_entity_type.test_bundle.field_test')
-      ->will($this->returnValue(array_combine(array_keys($expected), array_keys($expected))));
+      ->willReturn(array_combine(array_keys($expected), array_keys($expected)));
 
     $export = $field->toArray();
     $this->assertEquals($expected, $export);
diff --git a/core/modules/field/tests/src/Unit/FieldStorageConfigAccessControlHandlerTest.php b/core/modules/field/tests/src/Unit/FieldStorageConfigAccessControlHandlerTest.php
index 772c2e7e8e9978163951702f8d0292457a780672..7ce3c92c7f8be02cfface3e64505bede486740b4 100644
--- a/core/modules/field/tests/src/Unit/FieldStorageConfigAccessControlHandlerTest.php
+++ b/core/modules/field/tests/src/Unit/FieldStorageConfigAccessControlHandlerTest.php
@@ -68,11 +68,11 @@ protected function setUp(): void {
     $this->anon
       ->expects($this->any())
       ->method('hasPermission')
-      ->will($this->returnValue(FALSE));
+      ->willReturn(FALSE);
     $this->anon
       ->expects($this->any())
       ->method('id')
-      ->will($this->returnValue(0));
+      ->willReturn(0);
 
     $this->member = $this->createMock(AccountInterface::class);
     $this->member
@@ -84,23 +84,23 @@ protected function setUp(): void {
     $this->member
       ->expects($this->any())
       ->method('id')
-      ->will($this->returnValue(2));
+      ->willReturn(2);
 
     $storageType = $this->createMock(ConfigEntityTypeInterface::class);
     $storageType
       ->expects($this->any())
       ->method('getProvider')
-      ->will($this->returnValue('field'));
+      ->willReturn('field');
     $storageType
       ->expects($this->any())
       ->method('getConfigPrefix')
-      ->will($this->returnValue('field.storage'));
+      ->willReturn('field.storage');
 
     $entityType = $this->createMock(ConfigEntityTypeInterface::class);
     $entityType
       ->expects($this->any())
       ->method('getProvider')
-      ->will($this->returnValue('node'));
+      ->willReturn('node');
     $entityType
       ->expects($this->any())
       ->method('getConfigPrefix')
@@ -110,7 +110,7 @@ protected function setUp(): void {
     $this->moduleHandler
       ->expects($this->any())
       ->method('invokeAll')
-      ->will($this->returnValue([]));
+      ->willReturn([]);
 
     $storage_access_control_handler = new FieldStorageConfigAccessControlHandler($storageType);
     $storage_access_control_handler->setModuleHandler($this->moduleHandler);
diff --git a/core/modules/field/tests/src/Unit/FieldStorageConfigEntityUnitTest.php b/core/modules/field/tests/src/Unit/FieldStorageConfigEntityUnitTest.php
index 184e1f4ac7d97010379f40037908bca65c35e918..2b6cda81ecf87a7219b847efa95a8058487e93e8 100644
--- a/core/modules/field/tests/src/Unit/FieldStorageConfigEntityUnitTest.php
+++ b/core/modules/field/tests/src/Unit/FieldStorageConfigEntityUnitTest.php
@@ -73,14 +73,14 @@ public function testCalculateDependencies() {
     $fieldStorageConfigentityType = $this->createMock('\Drupal\Core\Config\Entity\ConfigEntityTypeInterface');
     $fieldStorageConfigentityType->expects($this->any())
       ->method('getProvider')
-      ->will($this->returnValue('field'));
+      ->willReturn('field');
 
     // Create a mock entity type to attach the field to.
     $attached_entity_type_id = $this->randomMachineName();
     $attached_entity_type = $this->createMock('\Drupal\Core\Entity\EntityTypeInterface');
     $attached_entity_type->expects($this->any())
       ->method('getProvider')
-      ->will($this->returnValue('entity_provider_module'));
+      ->willReturn('entity_provider_module');
 
     // Get definition is called three times. Twice in
     // ConfigEntityBase::addDependency() to get the provider of the field config
diff --git a/core/modules/forum/tests/src/Unit/Breadcrumb/ForumListingBreadcrumbBuilderTest.php b/core/modules/forum/tests/src/Unit/Breadcrumb/ForumListingBreadcrumbBuilderTest.php
index 960cb53d343dba0e97d327b878359b666f14a5b7..42d15d46b55a3cd25172803c101bf61e375a6743 100644
--- a/core/modules/forum/tests/src/Unit/Breadcrumb/ForumListingBreadcrumbBuilderTest.php
+++ b/core/modules/forum/tests/src/Unit/Breadcrumb/ForumListingBreadcrumbBuilderTest.php
@@ -57,7 +57,7 @@ public function testApplies($expected, $route_name = NULL, $parameter_map = [])
     $route_match = $this->createMock('Drupal\Core\Routing\RouteMatchInterface');
     $route_match->expects($this->once())
       ->method('getRouteName')
-      ->will($this->returnValue($route_name));
+      ->willReturn($route_name);
     $route_match->expects($this->any())
       ->method('getParameter')
       ->willReturnMap($parameter_map);
@@ -196,7 +196,7 @@ public function testBuild() {
     $route_match->expects($this->exactly(2))
       ->method('getParameter')
       ->with('taxonomy_term')
-      ->will($this->returnValue($forum_listing));
+      ->willReturn($forum_listing);
 
     // First test.
     $expected1 = [
diff --git a/core/modules/forum/tests/src/Unit/Breadcrumb/ForumNodeBreadcrumbBuilderTest.php b/core/modules/forum/tests/src/Unit/Breadcrumb/ForumNodeBreadcrumbBuilderTest.php
index 3c903fe415c51ba53db5111fa7ef1633d0a15ab2..893b483050e0e42603d3cb3ccae8f164b38ec87d 100644
--- a/core/modules/forum/tests/src/Unit/Breadcrumb/ForumNodeBreadcrumbBuilderTest.php
+++ b/core/modules/forum/tests/src/Unit/Breadcrumb/ForumNodeBreadcrumbBuilderTest.php
@@ -52,7 +52,7 @@ public function testApplies($expected, $route_name = NULL, $parameter_map = [])
     $forum_manager = $this->createMock('Drupal\forum\ForumManagerInterface');
     $forum_manager->expects($this->any())
       ->method('checkNodeType')
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
 
     $translation_manager = $this->createMock('Drupal\Core\StringTranslation\TranslationInterface');
 
@@ -62,7 +62,7 @@ public function testApplies($expected, $route_name = NULL, $parameter_map = [])
     $route_match = $this->createMock('Drupal\Core\Routing\RouteMatchInterface');
     $route_match->expects($this->once())
       ->method('getRouteName')
-      ->will($this->returnValue($route_name));
+      ->willReturn($route_name);
     $route_match->expects($this->any())
       ->method('getParameter')
       ->willReturnMap($parameter_map);
@@ -201,7 +201,7 @@ public function testBuild() {
     $route_match->expects($this->exactly(2))
       ->method('getParameter')
       ->with('node')
-      ->will($this->returnValue($forum_node));
+      ->willReturn($forum_node);
 
     // First test.
     $expected1 = [
diff --git a/core/modules/forum/tests/src/Unit/ForumManagerTest.php b/core/modules/forum/tests/src/Unit/ForumManagerTest.php
index c9208a70477d1247276994d29484ba963a881309..e0c9055846b3afcb281a8b66b24d7d0ede9fd913 100644
--- a/core/modules/forum/tests/src/Unit/ForumManagerTest.php
+++ b/core/modules/forum/tests/src/Unit/ForumManagerTest.php
@@ -31,22 +31,22 @@ public function testGetIndex() {
 
     $config_factory->expects($this->once())
       ->method('get')
-      ->will($this->returnValue($config));
+      ->willReturn($config);
 
     $config->expects($this->once())
       ->method('get')
-      ->will($this->returnValue('forums'));
+      ->willReturn('forums');
 
     $entity_type_manager->expects($this->once())
       ->method('getStorage')
-      ->will($this->returnValue($storage));
+      ->willReturn($storage);
 
     // This is sufficient for testing purposes.
     $term = new \stdClass();
 
     $storage->expects($this->once())
       ->method('create')
-      ->will($this->returnValue($term));
+      ->willReturn($term);
 
     $connection = $this->getMockBuilder('\Drupal\Core\Database\Connection')
       ->disableOriginalConstructor()
@@ -74,7 +74,7 @@ public function testGetIndex() {
 
     $manager->expects($this->once())
       ->method('getChildren')
-      ->will($this->returnValue([]));
+      ->willReturn([]);
 
     // Get the index once.
     $index1 = $manager->getIndex();
diff --git a/core/modules/image/tests/src/Unit/ImageStyleTest.php b/core/modules/image/tests/src/Unit/ImageStyleTest.php
index eef2acb8a3aa0237259cfa1c4c9311b1127b5993..6ea87730a2b28f456e6e04a3d70731f2018a5465 100644
--- a/core/modules/image/tests/src/Unit/ImageStyleTest.php
+++ b/core/modules/image/tests/src/Unit/ImageStyleTest.php
@@ -53,7 +53,7 @@ protected function getImageStyleMock($image_effect_id, $image_effect, $stubs = [
     $effectManager->expects($this->any())
       ->method('createInstance')
       ->with($image_effect_id)
-      ->will($this->returnValue($image_effect));
+      ->willReturn($image_effect);
     $default_stubs = ['getImageEffectPluginManager', 'fileDefaultScheme'];
     $image_style = $this->getMockBuilder('\Drupal\image\Entity\ImageStyle')
       ->setConstructorArgs([
@@ -65,7 +65,7 @@ protected function getImageStyleMock($image_effect_id, $image_effect, $stubs = [
 
     $image_style->expects($this->any())
       ->method('getImageEffectPluginManager')
-      ->will($this->returnValue($effectManager));
+      ->willReturn($effectManager);
     $image_style->expects($this->any())
       ->method('fileDefaultScheme')
       ->willReturnCallback([$this, 'fileDefaultScheme']);
@@ -82,12 +82,12 @@ protected function setUp(): void {
     $this->entityType = $this->createMock('\Drupal\Core\Entity\EntityTypeInterface');
     $this->entityType->expects($this->any())
       ->method('getProvider')
-      ->will($this->returnValue($provider));
+      ->willReturn($provider);
     $this->entityTypeManager = $this->createMock('\Drupal\Core\Entity\EntityTypeManagerInterface');
     $this->entityTypeManager->expects($this->any())
       ->method('getDefinition')
       ->with($this->entityTypeId)
-      ->will($this->returnValue($this->entityType));
+      ->willReturn($this->entityType);
   }
 
   /**
@@ -101,7 +101,7 @@ public function testGetDerivativeExtension() {
       ->getMock();
     $image_effect->expects($this->any())
       ->method('getDerivativeExtension')
-      ->will($this->returnValue('png'));
+      ->willReturn('png');
 
     $image_style = $this->getImageStyleMock($image_effect_id, $image_effect);
 
@@ -124,7 +124,7 @@ public function testBuildUri() {
       ->getMock();
     $image_effect->expects($this->any())
       ->method('getDerivativeExtension')
-      ->will($this->returnValue('png'));
+      ->willReturn('png');
 
     $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.png');
@@ -157,15 +157,15 @@ public function testGetPathToken() {
       ->getMock();
     $image_effect->expects($this->any())
       ->method('getDerivativeExtension')
-      ->will($this->returnValue('png'));
+      ->willReturn('png');
 
     $image_style = $this->getImageStyleMock($image_effect_id, $image_effect, ['getPrivateKey', 'getHashSalt']);
     $image_style->expects($this->any())
       ->method('getPrivateKey')
-      ->will($this->returnValue($private_key));
+      ->willReturn($private_key);
     $image_style->expects($this->any())
       ->method('getHashSalt')
-      ->will($this->returnValue($hash_salt));
+      ->willReturn($hash_salt);
 
     // Assert the extension has been added to the URI before creating the token.
     $this->assertEquals($image_style->getPathToken('public://test.jpeg.png'), $image_style->getPathToken('public://test.jpeg'));
@@ -184,10 +184,10 @@ public function testGetPathToken() {
     $image_style = $this->getImageStyleMock($image_effect_id, $image_effect, ['getPrivateKey', 'getHashSalt']);
     $image_style->expects($this->any())
       ->method('getPrivateKey')
-      ->will($this->returnValue($private_key));
+      ->willReturn($private_key);
     $image_style->expects($this->any())
       ->method('getHashSalt')
-      ->will($this->returnValue($hash_salt));
+      ->willReturn($hash_salt);
     // Assert no extension has been added to the uri before creating the token.
     $this->assertNotEquals($image_style->getPathToken('public://test.jpeg.png'), $image_style->getPathToken('public://test.jpeg'));
     $this->assertNotEquals(substr(Crypt::hmacBase64($image_style->id() . ':' . 'public://test.jpeg.png', $private_key . $hash_salt), 0, 8), $image_style->getPathToken('public://test.jpeg'));
diff --git a/core/modules/image/tests/src/Unit/PageCache/DenyPrivateImageStyleDownloadTest.php b/core/modules/image/tests/src/Unit/PageCache/DenyPrivateImageStyleDownloadTest.php
index 65cfab6d5f523a5b86d5b23619a2e6b12074a0d7..1fd9679f043f7af8c06c0c470961d0fe251624d0 100644
--- a/core/modules/image/tests/src/Unit/PageCache/DenyPrivateImageStyleDownloadTest.php
+++ b/core/modules/image/tests/src/Unit/PageCache/DenyPrivateImageStyleDownloadTest.php
@@ -61,7 +61,7 @@ protected function setUp(): void {
   public function testPrivateImageStyleDownloadPolicy($expected_result, $route_name) {
     $this->routeMatch->expects($this->once())
       ->method('getRouteName')
-      ->will($this->returnValue($route_name));
+      ->willReturn($route_name);
 
     $actual_result = $this->policy->check($this->response, $this->request);
     $this->assertSame($expected_result, $actual_result);
diff --git a/core/modules/language/tests/src/Unit/ContentLanguageSettingsUnitTest.php b/core/modules/language/tests/src/Unit/ContentLanguageSettingsUnitTest.php
index 31a2c1c48acba57859d17e5bcabb5c48da3916d0..636265bcf68808e4f2e490dba4ad31bcb9b2dd59 100644
--- a/core/modules/language/tests/src/Unit/ContentLanguageSettingsUnitTest.php
+++ b/core/modules/language/tests/src/Unit/ContentLanguageSettingsUnitTest.php
@@ -88,12 +88,12 @@ public function testCalculateDependencies() {
     $target_entity_type = $this->createMock('\Drupal\Core\Entity\EntityTypeInterface');
     $target_entity_type->expects($this->any())
       ->method('getBundleConfigDependency')
-      ->will($this->returnValue(['type' => 'config', 'name' => 'test.test_entity_type.id']));
+      ->willReturn(['type' => 'config', 'name' => 'test.test_entity_type.id']);
 
     $this->entityTypeManager->expects($this->any())
       ->method('getDefinition')
       ->with('test_entity_type')
-      ->will($this->returnValue($target_entity_type));
+      ->willReturn($target_entity_type);
 
     $config = new ContentLanguageSettings([
       'target_entity_type_id' => 'test_entity_type',
@@ -250,17 +250,17 @@ public function testLoadByEntityTypeBundle($config_id, ContentLanguageSettings $
       ->expects($this->any())
       ->method('load')
       ->with($config_id)
-      ->will($this->returnValue($existing_config));
+      ->willReturn($existing_config);
     $this->configEntityStorageInterface
       ->expects($this->any())
       ->method('create')
-      ->will($this->returnValue($nullConfig));
+      ->willReturn($nullConfig);
 
     $this->entityTypeManager
       ->expects($this->any())
       ->method('getStorage')
       ->with('language_content_settings')
-      ->will($this->returnValue($this->configEntityStorageInterface));
+      ->willReturn($this->configEntityStorageInterface);
 
     $entity_type_repository = $this->getMockForAbstractClass(EntityTypeRepositoryInterface::class);
     $entity_type_repository->expects($this->any())
diff --git a/core/modules/language/tests/src/Unit/LanguageNegotiationUrlTest.php b/core/modules/language/tests/src/Unit/LanguageNegotiationUrlTest.php
index 13873b940cf412b900ec0104c9dc4f5b3e1b9a1a..b135192323a0dc45c882c87b4569e628ad7302f0 100644
--- a/core/modules/language/tests/src/Unit/LanguageNegotiationUrlTest.php
+++ b/core/modules/language/tests/src/Unit/LanguageNegotiationUrlTest.php
@@ -29,11 +29,11 @@ protected function setUp(): void {
     $language_de = $this->createMock('\Drupal\Core\Language\LanguageInterface');
     $language_de->expects($this->any())
       ->method('getId')
-      ->will($this->returnValue('de'));
+      ->willReturn('de');
     $language_en = $this->createMock('\Drupal\Core\Language\LanguageInterface');
     $language_en->expects($this->any())
       ->method('getId')
-      ->will($this->returnValue('en'));
+      ->willReturn('en');
     $languages = [
       'de' => $language_de,
       'en' => $language_en,
@@ -45,7 +45,7 @@ protected function setUp(): void {
       ->getMock();
     $language_manager->expects($this->any())
       ->method('getLanguages')
-      ->will($this->returnValue($languages));
+      ->willReturn($languages);
     $this->languageManager = $language_manager;
 
     // Create a user stub.
@@ -69,7 +69,10 @@ protected function setUp(): void {
   public function testPathPrefix($prefix, $prefixes, $expected_langcode) {
     $this->languageManager->expects($this->any())
       ->method('getCurrentLanguage')
-      ->will($this->returnValue($this->languages[(in_array($expected_langcode, ['en', 'de'])) ? $expected_langcode : 'en']));
+      ->willReturn($this->languages[(in_array($expected_langcode, [
+        'en',
+        'de',
+      ])) ? $expected_langcode : 'en']);
 
     $config = $this->getConfigFactoryStub([
       'language.negotiation' => [
@@ -158,7 +161,7 @@ public function providerTestPathPrefix() {
   public function testDomain($http_host, $domains, $expected_langcode) {
     $this->languageManager->expects($this->any())
       ->method('getCurrentLanguage')
-      ->will($this->returnValue($this->languages['en']));
+      ->willReturn($this->languages['en']);
 
     $config = $this->getConfigFactoryStub([
       'language.negotiation' => [
diff --git a/core/modules/language/tests/src/Unit/process/LanguageDomainsTest.php b/core/modules/language/tests/src/Unit/process/LanguageDomainsTest.php
index 0fe3e3c88f9c6c8f168eba1320f38aab60e10bd4..64e9b3b879fe8592e4129e2efeff297fa88d6573 100644
--- a/core/modules/language/tests/src/Unit/process/LanguageDomainsTest.php
+++ b/core/modules/language/tests/src/Unit/process/LanguageDomainsTest.php
@@ -32,7 +32,7 @@ protected function setUp(): void {
     // to return TRUE to be able to test the process.
     $this->row->expects($this->once())
       ->method('getSourceProperty')
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
 
     // The language_domains plugin use $base_url to fill empty domains.
     global $base_url;
diff --git a/core/modules/locale/tests/src/Unit/LocaleLookupTest.php b/core/modules/locale/tests/src/Unit/LocaleLookupTest.php
index de1409d523736e2c7cf18f9e9632e8e8dd6481c1..3421de836399f2e7656e132954479e2b15c42b2e 100644
--- a/core/modules/locale/tests/src/Unit/LocaleLookupTest.php
+++ b/core/modules/locale/tests/src/Unit/LocaleLookupTest.php
@@ -77,7 +77,7 @@ protected function setUp(): void {
     $this->user = $this->createMock('Drupal\Core\Session\AccountInterface');
     $this->user->expects($this->any())
       ->method('getRoles')
-      ->will($this->returnValue(['anonymous']));
+      ->willReturn(['anonymous']);
 
     $this->configFactory = $this->getConfigFactoryStub(['locale.settings' => ['cache_strings' => FALSE]]);
 
@@ -112,7 +112,7 @@ public function testResolveCacheMissWithoutFallback() {
     $this->storage->expects($this->once())
       ->method('findTranslation')
       ->with($this->equalTo($args))
-      ->will($this->returnValue($result));
+      ->willReturn($result);
 
     $locale_lookup = $this->getMockBuilder('Drupal\locale\LocaleLookup')
       ->setConstructorArgs(['en', 'irrelevant', $this->storage, $this->cache, $this->lock, $this->configFactory, $this->languageManager, $this->requestStack])
@@ -229,7 +229,7 @@ public function testResolveCacheMissWithPersist() {
     $this->storage->expects($this->once())
       ->method('findTranslation')
       ->with($this->equalTo($args))
-      ->will($this->returnValue($result));
+      ->willReturn($result);
 
     $this->configFactory = $this->getConfigFactoryStub(['locale.settings' => ['cache_strings' => TRUE]]);
     $locale_lookup = $this->getMockBuilder('Drupal\locale\LocaleLookup')
@@ -254,10 +254,10 @@ public function testResolveCacheMissNoTranslation() {
       ->will($this->returnSelf());
     $this->storage->expects($this->once())
       ->method('findTranslation')
-      ->will($this->returnValue(NULL));
+      ->willReturn(NULL);
     $this->storage->expects($this->once())
       ->method('createString')
-      ->will($this->returnValue($string));
+      ->willReturn($string);
 
     $request = Request::create('/test');
     $this->requestStack->push($request);
@@ -349,7 +349,7 @@ public function testGetCid(array $roles, $expected) {
     $this->user = $this->createMock('Drupal\Core\Session\AccountInterface');
     $this->user->expects($this->any())
       ->method('getRoles')
-      ->will($this->returnValue($roles));
+      ->willReturn($roles);
 
     $container = new ContainerBuilder();
     $container->set('current_user', $this->user);
diff --git a/core/modules/menu_link_content/tests/src/Unit/MenuLinkContentEntityAccessTest.php b/core/modules/menu_link_content/tests/src/Unit/MenuLinkContentEntityAccessTest.php
index ea39e96b87989608f1e29500a60905aa0843b406..6751fcf296edc113ab47ebcdd5e17fc432a0f411 100644
--- a/core/modules/menu_link_content/tests/src/Unit/MenuLinkContentEntityAccessTest.php
+++ b/core/modules/menu_link_content/tests/src/Unit/MenuLinkContentEntityAccessTest.php
@@ -36,7 +36,7 @@ public function testUnrecognizedOperation() {
     $language = $this->createMock(LanguageInterface::class);
     $language->expects($this->any())
       ->method('getId')
-      ->will($this->returnValue('de'));
+      ->willReturn('de');
 
     $entity = $this->createMock(ContentEntityInterface::class);
     $entity->expects($this->any())
diff --git a/core/modules/migrate/tests/src/Unit/MigrateExecutableTest.php b/core/modules/migrate/tests/src/Unit/MigrateExecutableTest.php
index 5999e7af8cbfda30d70bbf638c9438c4bd34e3fb..073a21a4a310def0a1d2fd334ec3af40f6308ad1 100644
--- a/core/modules/migrate/tests/src/Unit/MigrateExecutableTest.php
+++ b/core/modules/migrate/tests/src/Unit/MigrateExecutableTest.php
@@ -89,7 +89,7 @@ public function testImportWithFailingRewind() {
 
     $this->migration->expects($this->any())
       ->method('getSourcePlugin')
-      ->will($this->returnValue($source));
+      ->willReturn($source);
 
     // Ensure that a message with the proper message was added.
     $exception_message .= " in " . __FILE__ . " line $line";
@@ -115,7 +115,7 @@ public function testImportWithValidRow() {
 
     $this->migration->expects($this->once())
       ->method('getProcessPlugins')
-      ->will($this->returnValue([]));
+      ->willReturn([]);
 
     $destination = $this->createMock('Drupal\migrate\Plugin\MigrateDestinationInterface');
 
@@ -140,7 +140,7 @@ public function testImportWithValidRowWithoutDestinationId() {
 
     $this->migration->expects($this->once())
       ->method('getProcessPlugins')
-      ->will($this->returnValue([]));
+      ->willReturn([]);
 
     $destination = $this->createMock('Drupal\migrate\Plugin\MigrateDestinationInterface');
 
@@ -168,7 +168,7 @@ public function testImportWithValidRowNoDestinationValues() {
 
     $this->migration->expects($this->once())
       ->method('getProcessPlugins')
-      ->will($this->returnValue([]));
+      ->willReturn([]);
 
     $destination = $this->createMock('Drupal\migrate\Plugin\MigrateDestinationInterface');
 
@@ -196,7 +196,7 @@ public function testImportWithValidRowWithDestinationMigrateException() {
 
     $this->migration->expects($this->once())
       ->method('getProcessPlugins')
-      ->will($this->returnValue([]));
+      ->willReturn([]);
 
     $destination = $this->createMock('Drupal\migrate\Plugin\MigrateDestinationInterface');
 
@@ -270,7 +270,7 @@ public function testImportWithValidRowWithException() {
 
     $this->migration->expects($this->once())
       ->method('getProcessPlugins')
-      ->will($this->returnValue([]));
+      ->willReturn([]);
 
     $destination = $this->createMock('Drupal\migrate\Plugin\MigrateDestinationInterface');
 
@@ -293,15 +293,15 @@ public function testProcessRow() {
       $plugins[$key][0] = $this->createMock('Drupal\migrate\Plugin\MigrateProcessInterface');
       $plugins[$key][0]->expects($this->once())
         ->method('getPluginDefinition')
-        ->will($this->returnValue([]));
+        ->willReturn([]);
       $plugins[$key][0]->expects($this->once())
         ->method('transform')
-        ->will($this->returnValue($value));
+        ->willReturn($value);
     }
     $this->migration->expects($this->once())
       ->method('getProcessPlugins')
       ->with(NULL)
-      ->will($this->returnValue($plugins));
+      ->willReturn($plugins);
     $row = new Row();
     $this->executable->processRow($row);
     foreach ($expected as $key => $value) {
@@ -317,7 +317,7 @@ public function testProcessRowEmptyPipeline() {
     $this->migration->expects($this->once())
       ->method('getProcessPlugins')
       ->with(NULL)
-      ->will($this->returnValue(['test' => []]));
+      ->willReturn(['test' => []]);
     $row = new Row();
     $this->executable->processRow($row);
     $this->assertSame($row->getDestination(), []);
@@ -386,10 +386,10 @@ protected function getMockSource() {
       ->getMockForAbstractClass();
     $source->expects($this->once())
       ->method('rewind')
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
     $source->expects($this->any())
       ->method('initializeIterator')
-      ->will($this->returnValue([]));
+      ->willReturn([]);
     $source->expects($this->any())
       ->method('valid')
       ->will($this->onConsecutiveCalls(TRUE, FALSE));
diff --git a/core/modules/migrate/tests/src/Unit/destination/ConfigTest.php b/core/modules/migrate/tests/src/Unit/destination/ConfigTest.php
index d55c21197b4e7fe7f88baaf5868ab01ef1be59db..cf3f77b5bfde323c07e4a2f78843c9472696f7e5 100644
--- a/core/modules/migrate/tests/src/Unit/destination/ConfigTest.php
+++ b/core/modules/migrate/tests/src/Unit/destination/ConfigTest.php
@@ -29,7 +29,7 @@ public function testImport() {
       $config->expects($this->once())
         ->method('set')
         ->with($this->equalTo($key), $this->equalTo($val))
-        ->will($this->returnValue($config));
+        ->willReturn($config);
     }
     $config->expects($this->once())
       ->method('save');
@@ -40,20 +40,20 @@ public function testImport() {
     $config_factory->expects($this->once())
       ->method('getEditable')
       ->with('d8_config')
-      ->will($this->returnValue($config));
+      ->willReturn($config);
     $row = $this->getMockBuilder('Drupal\migrate\Row')
       ->disableOriginalConstructor()
       ->getMock();
     $row->expects($this->any())
       ->method('getRawDestination')
-      ->will($this->returnValue($source));
+      ->willReturn($source);
     $language_manager = $this->getMockBuilder('Drupal\language\ConfigurableLanguageManagerInterface')
       ->disableOriginalConstructor()
       ->getMock();
     $language_manager->expects($this->never())
       ->method('getLanguageConfigOverride')
       ->with('fr', 'd8_config')
-      ->will($this->returnValue($config));
+      ->willReturn($config);
     $destination = new Config(['config_name' => 'd8_config'], 'd8_config', ['pluginId' => 'd8_config'], $migration, $config_factory, $language_manager);
     $destination_id = $destination->import($row);
     $this->assertEquals(['d8_config'], $destination_id);
@@ -76,7 +76,7 @@ public function testLanguageImport() {
       $config->expects($this->once())
         ->method('set')
         ->with($this->equalTo($key), $this->equalTo($val))
-        ->will($this->returnValue($config));
+        ->willReturn($config);
     }
     $config->expects($this->once())
       ->method('save');
@@ -87,23 +87,23 @@ public function testLanguageImport() {
     $config_factory->expects($this->once())
       ->method('getEditable')
       ->with('d8_config')
-      ->will($this->returnValue($config));
+      ->willReturn($config);
     $row = $this->getMockBuilder('Drupal\migrate\Row')
       ->disableOriginalConstructor()
       ->getMock();
     $row->expects($this->any())
       ->method('getRawDestination')
-      ->will($this->returnValue($source));
+      ->willReturn($source);
     $row->expects($this->any())
       ->method('getDestinationProperty')
-      ->will($this->returnValue($source['langcode']));
+      ->willReturn($source['langcode']);
     $language_manager = $this->getMockBuilder('Drupal\language\ConfigurableLanguageManagerInterface')
       ->disableOriginalConstructor()
       ->getMock();
     $language_manager->expects($this->any())
       ->method('getLanguageConfigOverride')
       ->with('mi', 'd8_config')
-      ->will($this->returnValue($config));
+      ->willReturn($config);
     $destination = new Config(['config_name' => 'd8_config', 'translations' => 'true'], 'd8_config', ['pluginId' => 'd8_config'], $migration, $config_factory, $language_manager);
     $destination_id = $destination->import($row);
     $this->assertEquals(['d8_config', 'mi'], $destination_id);
diff --git a/core/modules/migrate/tests/src/Unit/process/GetTest.php b/core/modules/migrate/tests/src/Unit/process/GetTest.php
index f9793bb8e2d863ffbcdc38b8a02a2f35e03fa59e..c921b8db890cf35b4621b7c1ea14b0a96117a94e 100644
--- a/core/modules/migrate/tests/src/Unit/process/GetTest.php
+++ b/core/modules/migrate/tests/src/Unit/process/GetTest.php
@@ -18,7 +18,7 @@ public function testTransformSourceString() {
     $this->row->expects($this->once())
       ->method('get')
       ->with('test')
-      ->will($this->returnValue('source_value'));
+      ->willReturn('source_value');
     $this->plugin = new Get(['source' => 'test'], '', []);
     $value = $this->plugin->transform(NULL, $this->migrateExecutable, $this->row, 'destination_property');
     $this->assertSame('source_value', $value);
@@ -49,7 +49,7 @@ public function testTransformSourceStringAt() {
     $this->row->expects($this->once())
       ->method('get')
       ->with('@@test')
-      ->will($this->returnValue('source_value'));
+      ->willReturn('source_value');
     $this->plugin = new Get(['source' => '@@test'], '', []);
     $value = $this->plugin->transform(NULL, $this->migrateExecutable, $this->row, 'destination_property');
     $this->assertSame('source_value', $value);
diff --git a/core/modules/migrate/tests/src/Unit/process/MakeUniqueEntityFieldTest.php b/core/modules/migrate/tests/src/Unit/process/MakeUniqueEntityFieldTest.php
index 05a5a8d53dff434a75afa567c0234bd64db05f70..465de7e3dadb1fd6646bd7ea9dfeb8a1ebe3e1fb 100644
--- a/core/modules/migrate/tests/src/Unit/process/MakeUniqueEntityFieldTest.php
+++ b/core/modules/migrate/tests/src/Unit/process/MakeUniqueEntityFieldTest.php
@@ -162,10 +162,10 @@ public function providerTestMakeUniqueEntityField() {
   protected function entityQueryExpects($count) {
     $this->entityQuery->expects($this->exactly($count + 1))
       ->method('condition')
-      ->will($this->returnValue($this->entityQuery));
+      ->willReturn($this->entityQuery);
     $this->entityQuery->expects($this->exactly($count + 1))
       ->method('count')
-      ->will($this->returnValue($this->entityQuery));
+      ->willReturn($this->entityQuery);
     $this->entityQuery->expects($this->exactly($count + 1))
       ->method('execute')
       ->willReturnCallback(function () use (&$count) {
diff --git a/core/modules/node/tests/src/Unit/NodeOperationAccessTest.php b/core/modules/node/tests/src/Unit/NodeOperationAccessTest.php
index 3ed6cb421427731747d7f4d394907a2a8811cf00..569e71c57846c2ad87aac7bb39518ba4c795c9ce 100644
--- a/core/modules/node/tests/src/Unit/NodeOperationAccessTest.php
+++ b/core/modules/node/tests/src/Unit/NodeOperationAccessTest.php
@@ -70,7 +70,7 @@ public function testRevisionOperations($operation, array $hasPermissionMap, $ass
     $language = $this->createMock(LanguageInterface::class);
     $language->expects($this->any())
       ->method('getId')
-      ->will($this->returnValue('de'));
+      ->willReturn('de');
 
     $nid = 333;
     /** @var \Drupal\node\NodeInterface|\PHPUnit\Framework\MockObject\MockObject $node */
diff --git a/core/modules/node/tests/src/Unit/PageCache/DenyNodePreviewTest.php b/core/modules/node/tests/src/Unit/PageCache/DenyNodePreviewTest.php
index 607b11a59cbbab5ec920781af578d3c426d11de8..674deab0b61b63158c9559d04db31dc3c5ae6734 100644
--- a/core/modules/node/tests/src/Unit/PageCache/DenyNodePreviewTest.php
+++ b/core/modules/node/tests/src/Unit/PageCache/DenyNodePreviewTest.php
@@ -61,7 +61,7 @@ protected function setUp(): void {
   public function testPrivateImageStyleDownloadPolicy($expected_result, $route_name) {
     $this->routeMatch->expects($this->once())
       ->method('getRouteName')
-      ->will($this->returnValue($route_name));
+      ->willReturn($route_name);
 
     $actual_result = $this->policy->check($this->response, $this->request);
     $this->assertSame($expected_result, $actual_result);
diff --git a/core/modules/node/tests/src/Unit/Plugin/views/field/NodeBulkFormTest.php b/core/modules/node/tests/src/Unit/Plugin/views/field/NodeBulkFormTest.php
index cd421f167e26011de588032a19c01b5bb7d42fbc..4f3f98b571c78e71834e9bcea66775a3cea32b65 100644
--- a/core/modules/node/tests/src/Unit/Plugin/views/field/NodeBulkFormTest.php
+++ b/core/modules/node/tests/src/Unit/Plugin/views/field/NodeBulkFormTest.php
@@ -33,26 +33,26 @@ public function testConstructor() {
       $action = $this->createMock('\Drupal\system\ActionConfigEntityInterface');
       $action->expects($this->any())
         ->method('getType')
-        ->will($this->returnValue('node'));
+        ->willReturn('node');
       $actions[$i] = $action;
     }
 
     $action = $this->createMock('\Drupal\system\ActionConfigEntityInterface');
     $action->expects($this->any())
       ->method('getType')
-      ->will($this->returnValue('user'));
+      ->willReturn('user');
     $actions[] = $action;
 
     $entity_storage = $this->createMock('Drupal\Core\Entity\EntityStorageInterface');
     $entity_storage->expects($this->any())
       ->method('loadMultiple')
-      ->will($this->returnValue($actions));
+      ->willReturn($actions);
 
     $entity_type_manager = $this->createMock(EntityTypeManagerInterface::class);
     $entity_type_manager->expects($this->once())
       ->method('getStorage')
       ->with('action')
-      ->will($this->returnValue($entity_storage));
+      ->willReturn($entity_storage);
 
     $entity_repository = $this->createMock(EntityRepositoryInterface::class);
 
@@ -66,7 +66,7 @@ public function testConstructor() {
     $views_data->expects($this->any())
       ->method('get')
       ->with('node')
-      ->will($this->returnValue(['table' => ['entity type' => 'node']]));
+      ->willReturn(['table' => ['entity type' => 'node']]);
     $container = new ContainerBuilder();
     $container->set('views.views_data', $views_data);
     $container->set('string_translation', $this->getStringTranslationStub());
@@ -76,7 +76,7 @@ public function testConstructor() {
     $storage->expects($this->any())
       ->method('get')
       ->with('base_table')
-      ->will($this->returnValue('node'));
+      ->willReturn('node');
 
     $executable = $this->getMockBuilder('Drupal\views\ViewExecutable')
       ->disableOriginalConstructor()
diff --git a/core/modules/path_alias/tests/src/Unit/AliasManagerTest.php b/core/modules/path_alias/tests/src/Unit/AliasManagerTest.php
index 0e76f07a166182f6576162e0e0b77f2c3bcedd2f..1bff1a5d80ae203c5f01c49ce40b525b9eea1b8b 100644
--- a/core/modules/path_alias/tests/src/Unit/AliasManagerTest.php
+++ b/core/modules/path_alias/tests/src/Unit/AliasManagerTest.php
@@ -91,12 +91,12 @@ public function testGetPathByAliasNoMatch() {
     $this->languageManager->expects($this->any())
       ->method('getCurrentLanguage')
       ->with(LanguageInterface::TYPE_URL)
-      ->will($this->returnValue($language));
+      ->willReturn($language);
 
     $this->aliasRepository->expects($this->once())
       ->method('lookupByAlias')
       ->with($alias, $language->getId())
-      ->will($this->returnValue(NULL));
+      ->willReturn(NULL);
 
     $this->assertEquals($alias, $this->aliasManager->getPathByAlias($alias));
     // Call it twice to test the static cache.
@@ -117,7 +117,7 @@ public function testGetPathByAliasMatch() {
     $this->aliasRepository->expects($this->once())
       ->method('lookupByAlias')
       ->with($alias, $language->getId())
-      ->will($this->returnValue(['path' => $path]));
+      ->willReturn(['path' => $path]);
 
     $this->assertEquals($path, $this->aliasManager->getPathByAlias($alias));
     // Call it twice to test the static cache.
@@ -139,7 +139,7 @@ public function testGetPathByAliasLangcode() {
     $this->aliasRepository->expects($this->once())
       ->method('lookupByAlias')
       ->with($alias, 'de')
-      ->will($this->returnValue(['path' => $path]));
+      ->willReturn(['path' => $path]);
 
     $this->assertEquals($path, $this->aliasManager->getPathByAlias($alias, 'de'));
     // Call it twice to test the static cache.
@@ -161,7 +161,7 @@ public function testGetAliasByPathWhitelist() {
     $this->aliasWhitelist->expects($this->any())
       ->method('get')
       ->with($path_part1)
-      ->will($this->returnValue(FALSE));
+      ->willReturn(FALSE);
 
     // The whitelist returns FALSE for that path part, so the storage should
     // never be called.
@@ -188,12 +188,12 @@ public function testGetAliasByPathNoMatch() {
     $this->aliasWhitelist->expects($this->any())
       ->method('get')
       ->with($path_part1)
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
 
     $this->aliasRepository->expects($this->once())
       ->method('lookupBySystemPath')
       ->with($path, $language->getId())
-      ->will($this->returnValue(NULL));
+      ->willReturn(NULL);
 
     $this->assertEquals($path, $this->aliasManager->getAliasByPath($path));
     // Call it twice to test the static cache.
@@ -226,12 +226,12 @@ public function testGetAliasByPathMatch() {
     $this->aliasWhitelist->expects($this->any())
       ->method('get')
       ->with($path_part1)
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
 
     $this->aliasRepository->expects($this->once())
       ->method('lookupBySystemPath')
       ->with($path, $language->getId())
-      ->will($this->returnValue(['alias' => $alias]));
+      ->willReturn(['alias' => $alias]);
 
     $this->assertEquals($alias, $this->aliasManager->getAliasByPath($path));
     // Call it twice to test the static cache.
@@ -263,7 +263,7 @@ public function testGetAliasByPathCachedMatch() {
     $this->cache->expects($this->once())
       ->method('get')
       ->with($this->cacheKey)
-      ->will($this->returnValue((object) ['data' => $cached_paths]));
+      ->willReturn((object) ['data' => $cached_paths]);
 
     // Simulate a request so that the preloaded paths are fetched.
     $this->aliasManager->setCacheKey($this->path);
@@ -271,12 +271,12 @@ public function testGetAliasByPathCachedMatch() {
     $this->aliasWhitelist->expects($this->any())
       ->method('get')
       ->with($path_part1)
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
 
     $this->aliasRepository->expects($this->once())
       ->method('preloadPathAlias')
       ->with($cached_paths[$language->getId()], $language->getId())
-      ->will($this->returnValue([$path => $alias]));
+      ->willReturn([$path => $alias]);
 
     // LookupPathAlias should not be called.
     $this->aliasRepository->expects($this->never())
@@ -311,7 +311,7 @@ public function testGetAliasByPathCachedMissLanguage() {
     $this->cache->expects($this->once())
       ->method('get')
       ->with($this->cacheKey)
-      ->will($this->returnValue((object) ['data' => $cached_paths]));
+      ->willReturn((object) ['data' => $cached_paths]);
 
     // Simulate a request so that the preloaded paths are fetched.
     $this->aliasManager->setCacheKey($this->path);
@@ -319,7 +319,7 @@ public function testGetAliasByPathCachedMissLanguage() {
     $this->aliasWhitelist->expects($this->any())
       ->method('get')
       ->with($path_part1)
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
 
     // The requested language is different than the cached, so this will
     // need to load.
@@ -328,7 +328,7 @@ public function testGetAliasByPathCachedMissLanguage() {
     $this->aliasRepository->expects($this->once())
       ->method('lookupBySystemPath')
       ->with($path, $language->getId())
-      ->will($this->returnValue(['alias' => $alias]));
+      ->willReturn(['alias' => $alias]);
 
     $this->assertEquals($alias, $this->aliasManager->getAliasByPath($path));
     // Call it twice to test the static cache.
@@ -360,7 +360,7 @@ public function testGetAliasByPathCachedMissNoAlias() {
     $this->cache->expects($this->once())
       ->method('get')
       ->with($this->cacheKey)
-      ->will($this->returnValue((object) ['data' => $cached_paths]));
+      ->willReturn((object) ['data' => $cached_paths]);
 
     // Simulate a request so that the preloaded paths are fetched.
     $this->aliasManager->setCacheKey($this->path);
@@ -368,12 +368,12 @@ public function testGetAliasByPathCachedMissNoAlias() {
     $this->aliasWhitelist->expects($this->any())
       ->method('get')
       ->with($path_part1)
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
 
     $this->aliasRepository->expects($this->once())
       ->method('preloadPathAlias')
       ->with($cached_paths[$language->getId()], $language->getId())
-      ->will($this->returnValue([$cached_path => $cached_alias]));
+      ->willReturn([$cached_path => $cached_alias]);
 
     // LookupPathAlias() should not be called.
     $this->aliasRepository->expects($this->never())
@@ -408,7 +408,7 @@ public function testGetAliasByPathUncachedMissNoAlias() {
     $this->cache->expects($this->once())
       ->method('get')
       ->with($this->cacheKey)
-      ->will($this->returnValue((object) ['data' => $cached_paths]));
+      ->willReturn((object) ['data' => $cached_paths]);
 
     // Simulate a request so that the preloaded paths are fetched.
     $this->aliasManager->setCacheKey($this->path);
@@ -416,17 +416,17 @@ public function testGetAliasByPathUncachedMissNoAlias() {
     $this->aliasWhitelist->expects($this->any())
       ->method('get')
       ->with($path_part1)
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
 
     $this->aliasRepository->expects($this->once())
       ->method('preloadPathAlias')
       ->with($cached_paths[$language->getId()], $language->getId())
-      ->will($this->returnValue([$cached_path => $cached_alias]));
+      ->willReturn([$cached_path => $cached_alias]);
 
     $this->aliasRepository->expects($this->once())
       ->method('lookupBySystemPath')
       ->with($path, $language->getId())
-      ->will($this->returnValue(NULL));
+      ->willReturn(NULL);
 
     $this->assertEquals($path, $this->aliasManager->getAliasByPath($path));
     // Call it twice to test the static cache.
@@ -494,7 +494,7 @@ public function testGetAliasByPathUncachedMissWithAlias() {
     $this->cache->expects($this->once())
       ->method('get')
       ->with($this->cacheKey)
-      ->will($this->returnValue((object) ['data' => $cached_paths]));
+      ->willReturn((object) ['data' => $cached_paths]);
 
     // Simulate a request so that the preloaded paths are fetched.
     $this->aliasManager->setCacheKey($this->path);
@@ -502,17 +502,17 @@ public function testGetAliasByPathUncachedMissWithAlias() {
     $this->aliasWhitelist->expects($this->any())
       ->method('get')
       ->with($path_part1)
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
 
     $this->aliasRepository->expects($this->once())
       ->method('preloadPathAlias')
       ->with($cached_paths[$language->getId()], $language->getId())
-      ->will($this->returnValue([$cached_path => $cached_alias]));
+      ->willReturn([$cached_path => $cached_alias]);
 
     $this->aliasRepository->expects($this->once())
       ->method('lookupBySystemPath')
       ->with($path, $language->getId())
-      ->will($this->returnValue(['alias' => $new_alias]));
+      ->willReturn(['alias' => $new_alias]);
 
     $this->assertEquals($new_alias, $this->aliasManager->getAliasByPath($path));
     // Call it twice to test the static cache.
@@ -537,7 +537,7 @@ protected function setUpCurrentLanguage() {
     $this->languageManager->expects($this->any())
       ->method('getCurrentLanguage')
       ->with(LanguageInterface::TYPE_URL)
-      ->will($this->returnValue($language));
+      ->willReturn($language);
 
     return $language;
   }
diff --git a/core/modules/responsive_image/tests/src/Unit/ResponsiveImageStyleConfigEntityUnitTest.php b/core/modules/responsive_image/tests/src/Unit/ResponsiveImageStyleConfigEntityUnitTest.php
index 36ffee7448059c922909168b69523216b6d43b7a..0e6255f6050c7035e072d6240bc04704ba2652e0 100644
--- a/core/modules/responsive_image/tests/src/Unit/ResponsiveImageStyleConfigEntityUnitTest.php
+++ b/core/modules/responsive_image/tests/src/Unit/ResponsiveImageStyleConfigEntityUnitTest.php
@@ -42,13 +42,13 @@ protected function setUp(): void {
     $this->entityType = $this->createMock('\Drupal\Core\Entity\EntityTypeInterface');
     $this->entityType->expects($this->any())
       ->method('getProvider')
-      ->will($this->returnValue('responsive_image'));
+      ->willReturn('responsive_image');
 
     $this->entityTypeManager = $this->createMock(EntityTypeManagerInterface::class);
     $this->entityTypeManager->expects($this->any())
       ->method('getDefinition')
       ->with('responsive_image_style')
-      ->will($this->returnValue($this->entityType));
+      ->willReturn($this->entityType);
 
     $this->breakpointManager = $this->createMock('\Drupal\breakpoint\BreakpointManagerInterface');
 
diff --git a/core/modules/rest/tests/src/Unit/CollectRoutesTest.php b/core/modules/rest/tests/src/Unit/CollectRoutesTest.php
index b5c390d4dc09955dabb2227b9250671a5d670033..8e60baa9b779e3affbdfce53490055194ad567a2 100644
--- a/core/modules/rest/tests/src/Unit/CollectRoutesTest.php
+++ b/core/modules/rest/tests/src/Unit/CollectRoutesTest.php
@@ -85,7 +85,7 @@ protected function setUp(): void {
     $container->set('authentication_collector', $authentication_collector);
     $authentication_collector->expects($this->any())
       ->method('getSortedProviders')
-      ->will($this->returnValue(['basic_auth' => 'data', 'cookie' => 'data']));
+      ->willReturn(['basic_auth' => 'data', 'cookie' => 'data']);
 
     $container->setParameter('serializer.format_providers', ['json']);
 
@@ -105,7 +105,7 @@ protected function setUp(): void {
 
     $display_manager->expects($this->once())
       ->method('getDefinition')
-      ->will($this->returnValue(['id' => 'test', 'provider' => 'test']));
+      ->willReturn(['id' => 'test', 'provider' => 'test']);
 
     $none = $this->getMockBuilder('\Drupal\views\Plugin\views\access\None')
       ->disableOriginalConstructor()
@@ -113,7 +113,7 @@ protected function setUp(): void {
 
     $access_manager->expects($this->once())
       ->method('createInstance')
-      ->will($this->returnValue($none));
+      ->willReturn($none);
 
     $style_plugin = $this->getMockBuilder('\Drupal\rest\Plugin\views\style\Serializer')
       ->onlyMethods(['getFormats', 'init'])
@@ -122,16 +122,16 @@ protected function setUp(): void {
 
     $style_plugin->expects($this->once())
       ->method('getFormats')
-      ->will($this->returnValue(['json']));
+      ->willReturn(['json']);
 
     $style_plugin->expects($this->once())
       ->method('init')
       ->with($view_executable)
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
 
     $style_manager->expects($this->once())
       ->method('createInstance')
-      ->will($this->returnValue($style_plugin));
+      ->willReturn($style_plugin);
 
     $this->routes = new RouteCollection();
     $this->routes->add('test_1', new Route('/test/1'));
diff --git a/core/modules/rest/tests/src/Unit/EntityResourceValidationTraitTest.php b/core/modules/rest/tests/src/Unit/EntityResourceValidationTraitTest.php
index 17d512e41b684e4cc981e9b26e28aec43a7acda7..99bd36db1ea7bf7e8919785379678442a3c84e5e 100644
--- a/core/modules/rest/tests/src/Unit/EntityResourceValidationTraitTest.php
+++ b/core/modules/rest/tests/src/Unit/EntityResourceValidationTraitTest.php
@@ -56,7 +56,7 @@ public function testFailedValidate() {
 
     $violations->expects($this->once())
       ->method('filterByFieldAccess')
-      ->will($this->returnValue([]));
+      ->willReturn([]);
 
     $entity->validate()->willReturn($violations);
 
diff --git a/core/modules/search/tests/src/Unit/SearchPageRepositoryTest.php b/core/modules/search/tests/src/Unit/SearchPageRepositoryTest.php
index d12bd8d3f8abfa9f4d12cd102dbfb6d5a4d3e632..686129b5a661e7ceb60008a99fdaeb992e764af3 100644
--- a/core/modules/search/tests/src/Unit/SearchPageRepositoryTest.php
+++ b/core/modules/search/tests/src/Unit/SearchPageRepositoryTest.php
@@ -55,13 +55,13 @@ protected function setUp(): void {
     $this->storage = $this->createMock('Drupal\Core\Config\Entity\ConfigEntityStorageInterface');
     $this->storage->expects($this->any())
       ->method('getQuery')
-      ->will($this->returnValue($this->query));
+      ->willReturn($this->query);
 
     /** @var \Drupal\Core\Entity\EntityTypeManagerInterface|\PHPUnit\Framework\MockObject\MockObject $entity_type_manager */
     $entity_type_manager = $this->createMock(EntityTypeManagerInterface::class);
     $entity_type_manager->expects($this->any())
       ->method('getStorage')
-      ->will($this->returnValue($this->storage));
+      ->willReturn($this->storage);
 
     $this->configFactory = $this->createMock('Drupal\Core\Config\ConfigFactoryInterface');
     $this->searchPageRepository = new SearchPageRepository($this->configFactory, $entity_type_manager);
@@ -74,10 +74,10 @@ public function testGetActiveSearchPages() {
     $this->query->expects($this->once())
       ->method('condition')
       ->with('status', TRUE)
-      ->will($this->returnValue($this->query));
+      ->willReturn($this->query);
     $this->query->expects($this->once())
       ->method('execute')
-      ->will($this->returnValue(['test' => 'test', 'other_test' => 'other_test']));
+      ->willReturn(['test' => 'test', 'other_test' => 'other_test']);
 
     $entities = [];
     $entities['test'] = $this->createMock('Drupal\search\SearchPageInterface');
@@ -85,7 +85,7 @@ public function testGetActiveSearchPages() {
     $this->storage->expects($this->once())
       ->method('loadMultiple')
       ->with(['test' => 'test', 'other_test' => 'other_test'])
-      ->will($this->returnValue($entities));
+      ->willReturn($entities);
 
     $result = $this->searchPageRepository->getActiveSearchPages();
     $this->assertSame($entities, $result);
@@ -98,14 +98,14 @@ public function testIsSearchActive() {
     $this->query->expects($this->once())
       ->method('condition')
       ->with('status', TRUE)
-      ->will($this->returnValue($this->query));
+      ->willReturn($this->query);
     $this->query->expects($this->once())
       ->method('range')
       ->with(0, 1)
-      ->will($this->returnValue($this->query));
+      ->willReturn($this->query);
     $this->query->expects($this->once())
       ->method('execute')
-      ->will($this->returnValue(['test' => 'test']));
+      ->willReturn(['test' => 'test']);
 
     $this->assertTrue($this->searchPageRepository->isSearchActive());
   }
@@ -117,24 +117,24 @@ public function testGetIndexableSearchPages() {
     $this->query->expects($this->once())
       ->method('condition')
       ->with('status', TRUE)
-      ->will($this->returnValue($this->query));
+      ->willReturn($this->query);
     $this->query->expects($this->once())
       ->method('execute')
-      ->will($this->returnValue(['test' => 'test', 'other_test' => 'other_test']));
+      ->willReturn(['test' => 'test', 'other_test' => 'other_test']);
 
     $entities = [];
     $entities['test'] = $this->createMock('Drupal\search\SearchPageInterface');
     $entities['test']->expects($this->once())
       ->method('isIndexable')
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
     $entities['other_test'] = $this->createMock('Drupal\search\SearchPageInterface');
     $entities['other_test']->expects($this->once())
       ->method('isIndexable')
-      ->will($this->returnValue(FALSE));
+      ->willReturn(FALSE);
     $this->storage->expects($this->once())
       ->method('loadMultiple')
       ->with(['test' => 'test', 'other_test' => 'other_test'])
-      ->will($this->returnValue($entities));
+      ->willReturn($entities);
 
     $result = $this->searchPageRepository->getIndexableSearchPages();
     $this->assertCount(1, $result);
@@ -151,11 +151,11 @@ public function testClearDefaultSearchPage() {
     $config->expects($this->once())
       ->method('clear')
       ->with('default_page')
-      ->will($this->returnValue($config));
+      ->willReturn($config);
     $this->configFactory->expects($this->once())
       ->method('getEditable')
       ->with('search.settings')
-      ->will($this->returnValue($config));
+      ->willReturn($config);
     $this->searchPageRepository->clearDefaultSearchPage();
   }
 
@@ -166,10 +166,10 @@ public function testGetDefaultSearchPageWithActiveDefault() {
     $this->query->expects($this->once())
       ->method('condition')
       ->with('status', TRUE)
-      ->will($this->returnValue($this->query));
+      ->willReturn($this->query);
     $this->query->expects($this->once())
       ->method('execute')
-      ->will($this->returnValue(['test' => 'test', 'other_test' => 'other_test']));
+      ->willReturn(['test' => 'test', 'other_test' => 'other_test']);
 
     $config = $this->getMockBuilder('Drupal\Core\Config\Config')
       ->disableOriginalConstructor()
@@ -177,11 +177,11 @@ public function testGetDefaultSearchPageWithActiveDefault() {
     $config->expects($this->once())
       ->method('get')
       ->with('default_page')
-      ->will($this->returnValue('test'));
+      ->willReturn('test');
     $this->configFactory->expects($this->once())
       ->method('get')
       ->with('search.settings')
-      ->will($this->returnValue($config));
+      ->willReturn($config);
 
     $this->assertSame('test', $this->searchPageRepository->getDefaultSearchPage());
   }
@@ -193,10 +193,10 @@ public function testGetDefaultSearchPageWithInactiveDefault() {
     $this->query->expects($this->once())
       ->method('condition')
       ->with('status', TRUE)
-      ->will($this->returnValue($this->query));
+      ->willReturn($this->query);
     $this->query->expects($this->once())
       ->method('execute')
-      ->will($this->returnValue(['test' => 'test']));
+      ->willReturn(['test' => 'test']);
 
     $config = $this->getMockBuilder('Drupal\Core\Config\Config')
       ->disableOriginalConstructor()
@@ -204,11 +204,11 @@ public function testGetDefaultSearchPageWithInactiveDefault() {
     $config->expects($this->once())
       ->method('get')
       ->with('default_page')
-      ->will($this->returnValue('other_test'));
+      ->willReturn('other_test');
     $this->configFactory->expects($this->once())
       ->method('get')
       ->with('search.settings')
-      ->will($this->returnValue($config));
+      ->willReturn($config);
 
     $this->assertSame('test', $this->searchPageRepository->getDefaultSearchPage());
   }
@@ -224,25 +224,25 @@ public function testSetDefaultSearchPage() {
     $config->expects($this->once())
       ->method('set')
       ->with('default_page', $id)
-      ->will($this->returnValue($config));
+      ->willReturn($config);
     $config->expects($this->once())
       ->method('save')
-      ->will($this->returnValue($config));
+      ->willReturn($config);
     $this->configFactory->expects($this->once())
       ->method('getEditable')
       ->with('search.settings')
-      ->will($this->returnValue($config));
+      ->willReturn($config);
 
     $search_page = $this->createMock('Drupal\search\SearchPageInterface');
     $search_page->expects($this->once())
       ->method('id')
-      ->will($this->returnValue($id));
+      ->willReturn($id);
     $search_page->expects($this->once())
       ->method('enable')
-      ->will($this->returnValue($search_page));
+      ->willReturn($search_page);
     $search_page->expects($this->once())
       ->method('save')
-      ->will($this->returnValue($search_page));
+      ->willReturn($search_page);
     $this->searchPageRepository->setDefaultSearchPage($search_page);
   }
 
@@ -253,10 +253,10 @@ public function testSortSearchPages() {
     $entity_type = $this->createMock('Drupal\Core\Entity\EntityTypeInterface');
     $entity_type->expects($this->any())
       ->method('getClass')
-      ->will($this->returnValue('Drupal\Tests\search\Unit\TestSearchPage'));
+      ->willReturn('Drupal\Tests\search\Unit\TestSearchPage');
     $this->storage->expects($this->once())
       ->method('getEntityType')
-      ->will($this->returnValue($entity_type));
+      ->willReturn($entity_type);
 
     // Declare entities out of their expected order so we can be sure they were
     // sorted. We cannot mock these because of uasort(), see
diff --git a/core/modules/search/tests/src/Unit/SearchPluginCollectionTest.php b/core/modules/search/tests/src/Unit/SearchPluginCollectionTest.php
index 1e6d74adcb303cbc4accab3fd38b41758e5cffeb..0f2369bda5177ed916d05f0ea2f55190f174602a 100644
--- a/core/modules/search/tests/src/Unit/SearchPluginCollectionTest.php
+++ b/core/modules/search/tests/src/Unit/SearchPluginCollectionTest.php
@@ -47,7 +47,7 @@ public function testGet() {
     $plugin = $this->createMock('Drupal\search\Plugin\SearchInterface');
     $this->pluginManager->expects($this->once())
       ->method('createInstance')
-      ->will($this->returnValue($plugin));
+      ->willReturn($plugin);
     $this->assertSame($plugin, $this->searchPluginCollection->get('banana'));
   }
 
@@ -59,11 +59,11 @@ public function testGetWithConfigurablePlugin() {
     $plugin->expects($this->once())
       ->method('setSearchPageId')
       ->with('fruit_stand')
-      ->will($this->returnValue($plugin));
+      ->willReturn($plugin);
 
     $this->pluginManager->expects($this->once())
       ->method('createInstance')
-      ->will($this->returnValue($plugin));
+      ->willReturn($plugin);
 
     $this->assertSame($plugin, $this->searchPluginCollection->get('banana'));
   }
diff --git a/core/modules/serialization/tests/src/Unit/Encoder/XmlEncoderTest.php b/core/modules/serialization/tests/src/Unit/Encoder/XmlEncoderTest.php
index bf5eae028129a91e9962c886701a441fe9e0d4c7..0c8c7df86342e63ef30687a08882ad7345bcb598 100644
--- a/core/modules/serialization/tests/src/Unit/Encoder/XmlEncoderTest.php
+++ b/core/modules/serialization/tests/src/Unit/Encoder/XmlEncoderTest.php
@@ -65,7 +65,7 @@ public function testEncode() {
     $this->baseEncoder->expects($this->once())
       ->method('encode')
       ->with($this->testArray, 'test', [])
-      ->will($this->returnValue('test'));
+      ->willReturn('test');
 
     $this->assertEquals('test', $this->encoder->encode($this->testArray, 'test'));
   }
@@ -77,7 +77,7 @@ public function testDecode() {
     $this->baseEncoder->expects($this->once())
       ->method('decode')
       ->with('test', 'test', [])
-      ->will($this->returnValue($this->testArray));
+      ->willReturn($this->testArray);
 
     $this->assertEquals($this->testArray, $this->encoder->decode('test', 'test'));
   }
diff --git a/core/modules/serialization/tests/src/Unit/EntityResolver/ChainEntityResolverTest.php b/core/modules/serialization/tests/src/Unit/EntityResolver/ChainEntityResolverTest.php
index 76800296df6b27f5714586818899bb253f223fe7..7e85502c7f852e806caf486471af145fe97b5610 100644
--- a/core/modules/serialization/tests/src/Unit/EntityResolver/ChainEntityResolverTest.php
+++ b/core/modules/serialization/tests/src/Unit/EntityResolver/ChainEntityResolverTest.php
@@ -140,7 +140,7 @@ protected function createEntityResolverMock($return = NULL, $called = TRUE) {
       $mock->expects($this->once())
         ->method('resolve')
         ->with($this->testNormalizer, $this->testData, $this->testEntityType)
-        ->will($this->returnValue($return));
+        ->willReturn($return);
     }
     else {
       $mock->expects($this->never())
diff --git a/core/modules/serialization/tests/src/Unit/EntityResolver/UuidResolverTest.php b/core/modules/serialization/tests/src/Unit/EntityResolver/UuidResolverTest.php
index 9094e80609fceee4c8ae16be36ecb5c90e5aac0f..0d6c0a1d36b3b4b35a012e12ad89302a52ab6254 100644
--- a/core/modules/serialization/tests/src/Unit/EntityResolver/UuidResolverTest.php
+++ b/core/modules/serialization/tests/src/Unit/EntityResolver/UuidResolverTest.php
@@ -57,7 +57,7 @@ public function testResolveNoUuid() {
     $normalizer->expects($this->once())
       ->method('getUuid')
       ->with([])
-      ->will($this->returnValue(NULL));
+      ->willReturn(NULL);
     $this->assertNull($this->resolver->resolve($normalizer, [], 'test_type'));
   }
 
@@ -70,13 +70,13 @@ public function testResolveNoEntity() {
     $this->entityRepository->expects($this->once())
       ->method('loadEntityByUuid')
       ->with('test_type')
-      ->will($this->returnValue(NULL));
+      ->willReturn(NULL);
 
     $normalizer = $this->createMock('Drupal\serialization\EntityResolver\UuidReferenceInterface');
     $normalizer->expects($this->once())
       ->method('getUuid')
       ->with([])
-      ->will($this->returnValue($uuid));
+      ->willReturn($uuid);
 
     $this->assertNull($this->resolver->resolve($normalizer, [], 'test_type'));
   }
@@ -90,18 +90,18 @@ public function testResolveWithEntity() {
     $entity = $this->createMock('Drupal\Core\Entity\EntityInterface');
     $entity->expects($this->once())
       ->method('id')
-      ->will($this->returnValue(1));
+      ->willReturn(1);
 
     $this->entityRepository->expects($this->once())
       ->method('loadEntityByUuid')
       ->with('test_type', $uuid)
-      ->will($this->returnValue($entity));
+      ->willReturn($entity);
 
     $normalizer = $this->createMock('Drupal\serialization\EntityResolver\UuidReferenceInterface');
     $normalizer->expects($this->once())
       ->method('getUuid')
       ->with([])
-      ->will($this->returnValue($uuid));
+      ->willReturn($uuid);
     $this->assertSame(1, $this->resolver->resolve($normalizer, [], 'test_type'));
   }
 
diff --git a/core/modules/serialization/tests/src/Unit/Normalizer/ConfigEntityNormalizerTest.php b/core/modules/serialization/tests/src/Unit/Normalizer/ConfigEntityNormalizerTest.php
index c3ff3fc16de10d66ff1f430010a421670c615fb1..69d58a22a88987344a62d642e1b49857b8d56553 100644
--- a/core/modules/serialization/tests/src/Unit/Normalizer/ConfigEntityNormalizerTest.php
+++ b/core/modules/serialization/tests/src/Unit/Normalizer/ConfigEntityNormalizerTest.php
@@ -42,7 +42,7 @@ public function testNormalize() {
     $config_entity = $this->createMock('Drupal\Core\Config\Entity\ConfigEntityInterface');
     $config_entity->expects($this->once())
       ->method('toArray')
-      ->will($this->returnValue($test_export_properties));
+      ->willReturn($test_export_properties);
 
     $this->assertSame(['test' => 'test'], $normalizer->normalize($config_entity));
   }
diff --git a/core/modules/serialization/tests/src/Unit/Normalizer/ContentEntityNormalizerTest.php b/core/modules/serialization/tests/src/Unit/Normalizer/ContentEntityNormalizerTest.php
index 888499c4fd8a997883353c216dc5c0da87ae1fcc..9daf730664300849413703751451156f6dfd2dcc 100644
--- a/core/modules/serialization/tests/src/Unit/Normalizer/ContentEntityNormalizerTest.php
+++ b/core/modules/serialization/tests/src/Unit/Normalizer/ContentEntityNormalizerTest.php
@@ -67,7 +67,7 @@ public function testNormalize() {
     $this->serializer->expects($this->any())
       ->method('normalize')
       ->with($this->containsOnlyInstancesOf('Drupal\Core\Field\FieldItemListInterface'), 'test_format', ['account' => NULL])
-      ->will($this->returnValue('test'));
+      ->willReturn('test');
 
     $definitions = [
       'field_accessible_external' => $this->createMockFieldListItem(TRUE, FALSE),
@@ -101,7 +101,7 @@ public function testNormalizeWithAccountContext() {
     $this->serializer->expects($this->any())
       ->method('normalize')
       ->with($this->containsOnlyInstancesOf('Drupal\Core\Field\FieldItemListInterface'), 'test_format', $context)
-      ->will($this->returnValue('test'));
+      ->willReturn('test');
 
     // The mock account should get passed directly into the access() method on
     // field items from $context['account'].
@@ -137,7 +137,7 @@ public function createMockForContentEntity($definitions) {
       ->shouldBeCalled();
     $content_entity_mock->expects($this->any())
       ->method('getTypedData')
-      ->will($this->returnValue($typed_data->reveal()));
+      ->willReturn($typed_data->reveal());
 
     return $content_entity_mock;
   }
@@ -159,7 +159,7 @@ protected function createMockFieldListItem($access, $internal, AccountInterface
     $mock = $this->createMock('Drupal\Core\Field\FieldItemListInterface');
     $mock->expects($this->once())
       ->method('getDataDefinition')
-      ->will($this->returnValue($data_definition->reveal()));
+      ->willReturn($data_definition->reveal());
     $data_definition->isInternal()
       ->willReturn($internal)
       ->shouldBeCalled();
@@ -167,7 +167,7 @@ protected function createMockFieldListItem($access, $internal, AccountInterface
       $mock->expects($this->once())
         ->method('access')
         ->with('view', $user_context)
-        ->will($this->returnValue($access));
+        ->willReturn($access);
     }
     return $mock;
   }
diff --git a/core/modules/serialization/tests/src/Unit/Normalizer/EntityNormalizerTest.php b/core/modules/serialization/tests/src/Unit/Normalizer/EntityNormalizerTest.php
index 06d280a9bd760bbaf9d5be6fff739ea9e49f5167..453f527579c2387a21772c796de6b5b21cc0a3cf 100644
--- a/core/modules/serialization/tests/src/Unit/Normalizer/EntityNormalizerTest.php
+++ b/core/modules/serialization/tests/src/Unit/Normalizer/EntityNormalizerTest.php
@@ -87,7 +87,7 @@ public function testNormalize() {
       ->getMockForAbstractClass();
     $content_entity->expects($this->once())
       ->method('getFields')
-      ->will($this->returnValue($definitions));
+      ->willReturn($definitions);
 
     $serializer = $this->getMockBuilder('Symfony\Component\Serializer\Serializer')
       ->disableOriginalConstructor()
@@ -137,11 +137,11 @@ public function testDenormalizeWithValidBundle() {
     $entity_type->expects($this->once())
       ->method('hasKey')
       ->with('bundle')
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
     $entity_type->expects($this->once())
       ->method('getKey')
       ->with('bundle')
-      ->will($this->returnValue('test_type'));
+      ->willReturn('test_type');
     $entity_type->expects($this->once())
       ->method('entityClassImplements')
       ->with(FieldableEntityInterface::class)
@@ -149,17 +149,17 @@ public function testDenormalizeWithValidBundle() {
 
     $entity_type->expects($this->once())
       ->method('getBundleEntityType')
-      ->will($this->returnValue('test_bundle'));
+      ->willReturn('test_bundle');
 
     $entity_type_storage_definition = $this->createMock('Drupal\Core\Field\FieldStorageDefinitionInterface');
     $entity_type_storage_definition->expects($this->once())
       ->method('getMainPropertyName')
-      ->will($this->returnValue('name'));
+      ->willReturn('name');
 
     $entity_type_definition = $this->createMock('Drupal\Core\Field\FieldDefinitionInterface');
     $entity_type_definition->expects($this->once())
       ->method('getFieldStorageDefinition')
-      ->will($this->returnValue($entity_type_storage_definition));
+      ->willReturn($entity_type_storage_definition);
 
     $base_definitions = [
       'test_type' => $entity_type_definition,
@@ -168,21 +168,21 @@ public function testDenormalizeWithValidBundle() {
     $this->entityTypeManager->expects($this->once())
       ->method('getDefinition')
       ->with('test')
-      ->will($this->returnValue($entity_type));
+      ->willReturn($entity_type);
     $this->entityFieldManager->expects($this->once())
       ->method('getBaseFieldDefinitions')
       ->with('test')
-      ->will($this->returnValue($base_definitions));
+      ->willReturn($base_definitions);
 
     $entity_query_mock = $this->createMock('Drupal\Core\Entity\Query\QueryInterface');
     $entity_query_mock->expects($this->once())
       ->method('execute')
-      ->will($this->returnValue(['test_bundle' => 'test_bundle']));
+      ->willReturn(['test_bundle' => 'test_bundle']);
 
     $entity_type_storage = $this->createMock('Drupal\Core\Entity\EntityStorageInterface');
     $entity_type_storage->expects($this->once())
       ->method('getQuery')
-      ->will($this->returnValue($entity_query_mock));
+      ->willReturn($entity_query_mock);
 
     $key_1 = $this->createMock(FieldItemListInterface::class);
     $key_2 = $this->createMock(FieldItemListInterface::class);
@@ -204,7 +204,7 @@ public function testDenormalizeWithValidBundle() {
     $storage->expects($this->once())
       ->method('create')
       ->with($expected_test_data)
-      ->will($this->returnValue($entity));
+      ->willReturn($entity);
 
     $this->entityTypeManager->expects($this->exactly(2))
       ->method('getStorage')
@@ -253,11 +253,11 @@ public function testDenormalizeWithInvalidBundle() {
     $entity_type->expects($this->once())
       ->method('hasKey')
       ->with('bundle')
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
     $entity_type->expects($this->once())
       ->method('getKey')
       ->with('bundle')
-      ->will($this->returnValue('test_type'));
+      ->willReturn('test_type');
     $entity_type->expects($this->once())
       ->method('entityClassImplements')
       ->with(FieldableEntityInterface::class)
@@ -265,17 +265,17 @@ public function testDenormalizeWithInvalidBundle() {
 
     $entity_type->expects($this->once())
       ->method('getBundleEntityType')
-      ->will($this->returnValue('test_bundle'));
+      ->willReturn('test_bundle');
 
     $entity_type_storage_definition = $this->createMock('Drupal\Core\Field\FieldStorageDefinitionInterface');
     $entity_type_storage_definition->expects($this->once())
       ->method('getMainPropertyName')
-      ->will($this->returnValue('name'));
+      ->willReturn('name');
 
     $entity_type_definition = $this->createMock('Drupal\Core\Field\FieldDefinitionInterface');
     $entity_type_definition->expects($this->once())
       ->method('getFieldStorageDefinition')
-      ->will($this->returnValue($entity_type_storage_definition));
+      ->willReturn($entity_type_storage_definition);
 
     $base_definitions = [
       'test_type' => $entity_type_definition,
@@ -284,26 +284,26 @@ public function testDenormalizeWithInvalidBundle() {
     $this->entityTypeManager->expects($this->once())
       ->method('getDefinition')
       ->with('test')
-      ->will($this->returnValue($entity_type));
+      ->willReturn($entity_type);
     $this->entityFieldManager->expects($this->once())
       ->method('getBaseFieldDefinitions')
       ->with('test')
-      ->will($this->returnValue($base_definitions));
+      ->willReturn($base_definitions);
 
     $entity_query_mock = $this->createMock('Drupal\Core\Entity\Query\QueryInterface');
     $entity_query_mock->expects($this->once())
       ->method('execute')
-      ->will($this->returnValue(['test_bundle_other' => 'test_bundle_other']));
+      ->willReturn(['test_bundle_other' => 'test_bundle_other']);
 
     $entity_type_storage = $this->createMock('Drupal\Core\Entity\EntityStorageInterface');
     $entity_type_storage->expects($this->once())
       ->method('getQuery')
-      ->will($this->returnValue($entity_query_mock));
+      ->willReturn($entity_query_mock);
 
     $this->entityTypeManager->expects($this->once())
       ->method('getStorage')
       ->with('test_bundle')
-      ->will($this->returnValue($entity_type_storage));
+      ->willReturn($entity_type_storage);
 
     $this->expectException(UnexpectedValueException::class);
     $this->entityNormalizer->denormalize($test_data, 'Drupal\Core\Entity\ContentEntityBase', NULL, ['entity_type' => 'test']);
@@ -328,14 +328,14 @@ public function testDenormalizeWithNoBundle() {
     $entity_type->expects($this->once())
       ->method('hasKey')
       ->with('bundle')
-      ->will($this->returnValue(FALSE));
+      ->willReturn(FALSE);
     $entity_type->expects($this->never())
       ->method('getKey');
 
     $this->entityTypeManager->expects($this->once())
       ->method('getDefinition')
       ->with('test')
-      ->will($this->returnValue($entity_type));
+      ->willReturn($entity_type);
 
     $key_1 = $this->createMock(FieldItemListInterface::class);
     $key_2 = $this->createMock(FieldItemListInterface::class);
@@ -352,12 +352,12 @@ public function testDenormalizeWithNoBundle() {
     $storage->expects($this->once())
       ->method('create')
       ->with([])
-      ->will($this->returnValue($entity));
+      ->willReturn($entity);
 
     $this->entityTypeManager->expects($this->once())
       ->method('getStorage')
       ->with('test')
-      ->will($this->returnValue($storage));
+      ->willReturn($storage);
 
     $this->entityFieldManager->expects($this->never())
       ->method('getBaseFieldDefinitions');
@@ -403,18 +403,18 @@ public function testDenormalizeWithNoFieldableEntityType() {
     $this->entityTypeManager->expects($this->once())
       ->method('getDefinition')
       ->with('test')
-      ->will($this->returnValue($entity_type));
+      ->willReturn($entity_type);
 
     $storage = $this->createMock('Drupal\Core\Entity\EntityStorageInterface');
     $storage->expects($this->once())
       ->method('create')
       ->with($test_data)
-      ->will($this->returnValue($this->createMock('Drupal\Core\Entity\EntityInterface')));
+      ->willReturn($this->createMock('Drupal\Core\Entity\EntityInterface'));
 
     $this->entityTypeManager->expects($this->once())
       ->method('getStorage')
       ->with('test')
-      ->will($this->returnValue($storage));
+      ->willReturn($storage);
 
     $this->entityFieldManager->expects($this->never())
       ->method('getBaseFieldDefinitions');
diff --git a/core/modules/serialization/tests/src/Unit/Normalizer/ListNormalizerTest.php b/core/modules/serialization/tests/src/Unit/Normalizer/ListNormalizerTest.php
index 0fc7936216ca7469b695cf7b36ef450c1e54a21c..f57818f802a771db7ed40831912cb974d9ec2620 100644
--- a/core/modules/serialization/tests/src/Unit/Normalizer/ListNormalizerTest.php
+++ b/core/modules/serialization/tests/src/Unit/Normalizer/ListNormalizerTest.php
@@ -52,7 +52,7 @@ protected function setUp(): void {
     $typed_data_manager = $this->createMock(TypedDataManagerInterface::class);
     $typed_data_manager->expects($this->any())
       ->method('getPropertyInstance')
-      ->will($this->returnValue($this->typedData));
+      ->willReturn($this->typedData);
 
     // Set up a mock container as ItemList() will call for the 'typed_data_manager'
     // service.
@@ -62,7 +62,7 @@ protected function setUp(): void {
     $container->expects($this->any())
       ->method('get')
       ->with($this->equalTo('typed_data_manager'))
-      ->will($this->returnValue($typed_data_manager));
+      ->willReturn($typed_data_manager);
 
     \Drupal::setContainer($container);
 
diff --git a/core/modules/serialization/tests/src/Unit/Normalizer/TypedDataNormalizerTest.php b/core/modules/serialization/tests/src/Unit/Normalizer/TypedDataNormalizerTest.php
index c8088b1c86c2ab6d786340ed6237785e87cf434a..142da8b97f56a7d205a9fe28a91b835734c135a6 100644
--- a/core/modules/serialization/tests/src/Unit/Normalizer/TypedDataNormalizerTest.php
+++ b/core/modules/serialization/tests/src/Unit/Normalizer/TypedDataNormalizerTest.php
@@ -48,7 +48,7 @@ public function testSupportsNormalization() {
   public function testNormalize() {
     $this->typedData->expects($this->once())
       ->method('getValue')
-      ->will($this->returnValue('test'));
+      ->willReturn('test');
 
     $this->assertEquals('test', $this->normalizer->normalize($this->typedData));
   }
diff --git a/core/modules/shortcut/tests/src/Unit/Menu/ShortcutLocalTasksTest.php b/core/modules/shortcut/tests/src/Unit/Menu/ShortcutLocalTasksTest.php
index a26f6c76cdae9c257d8d41e23e8457e42dec9767..1bbe28f2d3f6e2e5820b838b65646e61291fe4b2 100644
--- a/core/modules/shortcut/tests/src/Unit/Menu/ShortcutLocalTasksTest.php
+++ b/core/modules/shortcut/tests/src/Unit/Menu/ShortcutLocalTasksTest.php
@@ -26,7 +26,7 @@ protected function setUp(): void {
     $entity_type_manager = $this->createMock(EntityTypeManagerInterface::class);
     $entity_type_manager->expects($this->any())
       ->method('getDefinitions')
-      ->will($this->returnValue([]));
+      ->willReturn([]);
     $this->container->set('entity_type.manager', $entity_type_manager);
     $this->container->set('string_translation', $this->getStringTranslationStub());
   }
diff --git a/core/modules/system/tests/src/Unit/Breadcrumbs/PathBasedBreadcrumbBuilderTest.php b/core/modules/system/tests/src/Unit/Breadcrumbs/PathBasedBreadcrumbBuilderTest.php
index a0885b34621346d42983ee47a8a402f3600d54be..2f366bfef6af195a813ada4a1aefa7b7561ed427 100644
--- a/core/modules/system/tests/src/Unit/Breadcrumbs/PathBasedBreadcrumbBuilderTest.php
+++ b/core/modules/system/tests/src/Unit/Breadcrumbs/PathBasedBreadcrumbBuilderTest.php
@@ -164,7 +164,7 @@ public function testBuildOnFrontpage() {
   public function testBuildWithOnePathElement() {
     $this->context->expects($this->once())
       ->method('getPathInfo')
-      ->will($this->returnValue('/example'));
+      ->willReturn('/example');
 
     $breadcrumb = $this->builder->build($this->createMock('Drupal\Core\Routing\RouteMatchInterface'));
     $this->assertEquals([0 => new Link('Home', new Url('<front>'))], $breadcrumb->getLinks());
@@ -182,7 +182,7 @@ public function testBuildWithOnePathElement() {
   public function testBuildWithTwoPathElements() {
     $this->context->expects($this->once())
       ->method('getPathInfo')
-      ->will($this->returnValue('/example/baz'));
+      ->willReturn('/example/baz');
     $this->setupStubPathProcessor();
 
     $route_1 = new Route('/example');
@@ -221,7 +221,7 @@ public function testBuildWithTwoPathElements() {
   public function testBuildWithThreePathElements() {
     $this->context->expects($this->once())
       ->method('getPathInfo')
-      ->will($this->returnValue('/example/bar/baz'));
+      ->willReturn('/example/bar/baz');
     $this->setupStubPathProcessor();
 
     $route_1 = new Route('/example/bar');
@@ -279,7 +279,7 @@ public function testBuildWithThreePathElements() {
   public function testBuildWithException($exception_class, $exception_argument) {
     $this->context->expects($this->once())
       ->method('getPathInfo')
-      ->will($this->returnValue('/example/bar'));
+      ->willReturn('/example/bar');
     $this->setupStubPathProcessor();
 
     $this->requestMatcher->expects($this->any())
@@ -320,15 +320,15 @@ public function providerTestBuildWithException() {
   public function testBuildWithNonProcessedPath() {
     $this->context->expects($this->once())
       ->method('getPathInfo')
-      ->will($this->returnValue('/example/bar'));
+      ->willReturn('/example/bar');
 
     $this->pathProcessor->expects($this->once())
       ->method('processInbound')
-      ->will($this->returnValue(FALSE));
+      ->willReturn(FALSE);
 
     $this->requestMatcher->expects($this->any())
       ->method('matchRequest')
-      ->will($this->returnValue([]));
+      ->willReturn([]);
 
     $breadcrumb = $this->builder->build($this->createMock('Drupal\Core\Routing\RouteMatchInterface'));
 
@@ -357,7 +357,7 @@ public function testApplies() {
   public function testBuildWithUserPath() {
     $this->context->expects($this->once())
       ->method('getPathInfo')
-      ->will($this->returnValue('/user/1/edit'));
+      ->willReturn('/user/1/edit');
     $this->setupStubPathProcessor();
 
     $route_1 = new Route('/user/1');
@@ -378,7 +378,7 @@ public function testBuildWithUserPath() {
     $this->titleResolver->expects($this->once())
       ->method('getTitle')
       ->with($this->anything(), $route_1)
-      ->will($this->returnValue('Admin'));
+      ->willReturn('Admin');
 
     $breadcrumb = $this->builder->build($this->createMock('Drupal\Core\Routing\RouteMatchInterface'));
     $this->assertEquals([0 => new Link('Home', new Url('<front>')), 1 => new Link('Admin', new Url('user_page'))], $breadcrumb->getLinks());
diff --git a/core/modules/system/tests/src/Unit/Menu/SystemLocalTasksTest.php b/core/modules/system/tests/src/Unit/Menu/SystemLocalTasksTest.php
index 036c138cdc154c733564003e54e25100bfde479d..55d79ec9fba02f3959ea9620ffdd4b92fb52752f 100644
--- a/core/modules/system/tests/src/Unit/Menu/SystemLocalTasksTest.php
+++ b/core/modules/system/tests/src/Unit/Menu/SystemLocalTasksTest.php
@@ -36,9 +36,9 @@ protected function setUp(): void {
     $theme->info = ['name' => 'olivero'];
     $this->themeHandler->expects($this->any())
       ->method('listInfo')
-      ->will($this->returnValue([
+      ->willReturn([
         'olivero' => $theme,
-      ]));
+      ]);
     $this->themeHandler->expects($this->any())
       ->method('hasUi')
       ->with('olivero')
diff --git a/core/modules/tour/tests/src/Unit/Entity/TourTest.php b/core/modules/tour/tests/src/Unit/Entity/TourTest.php
index 2143175285de8d1d5d4c7f4334d4147e62db2d63..b1f3db0bbc2ebf1de16284492c24dcf6dfa9df6d 100644
--- a/core/modules/tour/tests/src/Unit/Entity/TourTest.php
+++ b/core/modules/tour/tests/src/Unit/Entity/TourTest.php
@@ -34,7 +34,7 @@ public function testHasMatchingRoute($routes, $route_name, $route_params, $resul
 
     $tour->expects($this->any())
       ->method('getRoutes')
-      ->will($this->returnValue($routes));
+      ->willReturn($routes);
 
     $this->assertSame($result, $tour->hasMatchingRoute($route_name, $route_params));
 
diff --git a/core/modules/update/tests/src/Unit/UpdateFetcherTest.php b/core/modules/update/tests/src/Unit/UpdateFetcherTest.php
index 2150e49a6748132aa027dfe13e7406ea22d42453..6dd3f9ef6be5b2c1063d7172270fcbfc63dbcaf3 100644
--- a/core/modules/update/tests/src/Unit/UpdateFetcherTest.php
+++ b/core/modules/update/tests/src/Unit/UpdateFetcherTest.php
@@ -91,7 +91,7 @@ protected function setUp(): void {
     $container->expects($this->any())
       ->method('get')
       ->with('logger.factory')
-      ->will($this->returnValue($logger_factory));
+      ->willReturn($logger_factory);
     \Drupal::setContainer($container);
   }
 
diff --git a/core/modules/user/tests/src/Unit/Menu/UserLocalTasksTest.php b/core/modules/user/tests/src/Unit/Menu/UserLocalTasksTest.php
index 0151392c455003c464caa1d0d84732c13fa48e3b..a6dc74eb8432044441aad73c119ab8cb640beb19 100644
--- a/core/modules/user/tests/src/Unit/Menu/UserLocalTasksTest.php
+++ b/core/modules/user/tests/src/Unit/Menu/UserLocalTasksTest.php
@@ -23,7 +23,7 @@ protected function setUp(): void {
     $entity_type_manager = $this->createMock(EntityTypeManagerInterface::class);
     $entity_type_manager->expects($this->any())
       ->method('getDefinitions')
-      ->will($this->returnValue([]));
+      ->willReturn([]);
     $this->container->set('entity_type.manager', $entity_type_manager);
     $this->container->set('string_translation', $this->getStringTranslationStub());
   }
diff --git a/core/modules/user/tests/src/Unit/Plugin/Action/AddRoleUserTest.php b/core/modules/user/tests/src/Unit/Plugin/Action/AddRoleUserTest.php
index 1f460517dabb3c846751be89159163b4634d0769..a2c91e3027d576d61001bb32a41da15211bcf441 100644
--- a/core/modules/user/tests/src/Unit/Plugin/Action/AddRoleUserTest.php
+++ b/core/modules/user/tests/src/Unit/Plugin/Action/AddRoleUserTest.php
@@ -20,7 +20,7 @@ public function testExecuteAddExistingRole() {
     $this->account->expects($this->any())
       ->method('hasRole')
       ->with($this->equalTo('test_role_1'))
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
 
     $config = ['rid' => 'test_role_1'];
     $add_role_plugin = new AddRoleUser($config, 'user_add_role_action', ['type' => 'user'], $this->userRoleEntityType);
@@ -38,7 +38,7 @@ public function testExecuteAddNonExistingRole() {
     $this->account->expects($this->any())
       ->method('hasRole')
       ->with($this->equalTo('test_role_1'))
-      ->will($this->returnValue(FALSE));
+      ->willReturn(FALSE);
 
     $config = ['rid' => 'test_role_1'];
     $add_role_plugin = new AddRoleUser($config, 'user_add_role_action', ['type' => 'user'], $this->userRoleEntityType);
diff --git a/core/modules/user/tests/src/Unit/Plugin/Action/RemoveRoleUserTest.php b/core/modules/user/tests/src/Unit/Plugin/Action/RemoveRoleUserTest.php
index 878b4baad243f2b5ea7018fd57a096252e4446e9..476afe94d3d877b9ade8546366c5f75099c26416 100644
--- a/core/modules/user/tests/src/Unit/Plugin/Action/RemoveRoleUserTest.php
+++ b/core/modules/user/tests/src/Unit/Plugin/Action/RemoveRoleUserTest.php
@@ -20,7 +20,7 @@ public function testExecuteRemoveExistingRole() {
     $this->account->expects($this->any())
       ->method('hasRole')
       ->with($this->equalTo('test_role_1'))
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
 
     $config = ['rid' => 'test_role_1'];
     $remove_role_plugin = new RemoveRoleUser($config, 'user_remove_role_action', ['type' => 'user'], $this->userRoleEntityType);
@@ -38,7 +38,7 @@ public function testExecuteRemoveNonExistingRole() {
     $this->account->expects($this->any())
       ->method('hasRole')
       ->with($this->equalTo('test_role_1'))
-      ->will($this->returnValue(FALSE));
+      ->willReturn(FALSE);
 
     $config = ['rid' => 'test_role_1'];
     $remove_role_plugin = new RemoveRoleUser($config, 'user_remove_role_action', ['type' => 'user'], $this->userRoleEntityType);
diff --git a/core/modules/user/tests/src/Unit/Plugin/Core/Entity/UserTest.php b/core/modules/user/tests/src/Unit/Plugin/Core/Entity/UserTest.php
index 966276bc426ceec30f7cb7ce5c1ccd4740045f8a..f96d126e683307272baffdc5a101597ab9f16bf8 100644
--- a/core/modules/user/tests/src/Unit/Plugin/Core/Entity/UserTest.php
+++ b/core/modules/user/tests/src/Unit/Plugin/Core/Entity/UserTest.php
@@ -22,7 +22,7 @@ protected function createUserSession(array $rids = [], $authenticated = FALSE) {
     $user->expects($this->any())
       ->method('id')
       // @todo Also test the uid = 1 handling.
-      ->will($this->returnValue($authenticated ? 2 : 0));
+      ->willReturn($authenticated ? 2 : 0);
     $roles = [];
     foreach ($rids as $rid) {
       $roles[] = (object) [
@@ -32,7 +32,7 @@ protected function createUserSession(array $rids = [], $authenticated = FALSE) {
     $user->expects($this->any())
       ->method('get')
       ->with('roles')
-      ->will($this->returnValue($roles));
+      ->willReturn($roles);
     return $user;
   }
 
diff --git a/core/modules/user/tests/src/Unit/Plugin/views/field/UserBulkFormTest.php b/core/modules/user/tests/src/Unit/Plugin/views/field/UserBulkFormTest.php
index cdd6ec685b684e143f00d50df486b8c9310445c4..c530ad7966ad52a80fdb140e0c3796af0be0e116 100644
--- a/core/modules/user/tests/src/Unit/Plugin/views/field/UserBulkFormTest.php
+++ b/core/modules/user/tests/src/Unit/Plugin/views/field/UserBulkFormTest.php
@@ -33,26 +33,26 @@ public function testConstructor() {
       $action = $this->createMock('\Drupal\system\ActionConfigEntityInterface');
       $action->expects($this->any())
         ->method('getType')
-        ->will($this->returnValue('user'));
+        ->willReturn('user');
       $actions[$i] = $action;
     }
 
     $action = $this->createMock('\Drupal\system\ActionConfigEntityInterface');
     $action->expects($this->any())
       ->method('getType')
-      ->will($this->returnValue('node'));
+      ->willReturn('node');
     $actions[] = $action;
 
     $entity_storage = $this->createMock('Drupal\Core\Entity\EntityStorageInterface');
     $entity_storage->expects($this->any())
       ->method('loadMultiple')
-      ->will($this->returnValue($actions));
+      ->willReturn($actions);
 
     $entity_type_manager = $this->createMock(EntityTypeManagerInterface::class);
     $entity_type_manager->expects($this->once())
       ->method('getStorage')
       ->with('action')
-      ->will($this->returnValue($entity_storage));
+      ->willReturn($entity_storage);
 
     $entity_repository = $this->createMock(EntityRepositoryInterface::class);
 
@@ -66,7 +66,7 @@ public function testConstructor() {
     $views_data->expects($this->any())
       ->method('get')
       ->with('users')
-      ->will($this->returnValue(['table' => ['entity type' => 'user']]));
+      ->willReturn(['table' => ['entity type' => 'user']]);
     $container = new ContainerBuilder();
     $container->set('views.views_data', $views_data);
     $container->set('string_translation', $this->getStringTranslationStub());
@@ -76,7 +76,7 @@ public function testConstructor() {
     $storage->expects($this->any())
       ->method('get')
       ->with('base_table')
-      ->will($this->returnValue('users'));
+      ->willReturn('users');
 
     $executable = $this->getMockBuilder('Drupal\views\ViewExecutable')
       ->disableOriginalConstructor()
diff --git a/core/modules/user/tests/src/Unit/UserAccessControlHandlerTest.php b/core/modules/user/tests/src/Unit/UserAccessControlHandlerTest.php
index 0fea2899a1ac25cdfba873513a7b55ed56b56aea..333d7bcff3acae1367fa1be15b0e76a4a7aa63da 100644
--- a/core/modules/user/tests/src/Unit/UserAccessControlHandlerTest.php
+++ b/core/modules/user/tests/src/Unit/UserAccessControlHandlerTest.php
@@ -77,11 +77,11 @@ protected function setUp(): void {
     $this->viewer
       ->expects($this->any())
       ->method('hasPermission')
-      ->will($this->returnValue(FALSE));
+      ->willReturn(FALSE);
     $this->viewer
       ->expects($this->any())
       ->method('id')
-      ->will($this->returnValue(1));
+      ->willReturn(1);
 
     $this->owner = $this->createMock('\Drupal\Core\Session\AccountInterface');
     $this->owner
@@ -95,13 +95,13 @@ protected function setUp(): void {
     $this->owner
       ->expects($this->any())
       ->method('id')
-      ->will($this->returnValue(2));
+      ->willReturn(2);
 
     $this->admin = $this->createMock('\Drupal\Core\Session\AccountInterface');
     $this->admin
       ->expects($this->any())
       ->method('hasPermission')
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
 
     $this->emailViewer = $this->createMock('\Drupal\Core\Session\AccountInterface');
     $this->emailViewer
@@ -113,7 +113,7 @@ protected function setUp(): void {
     $this->emailViewer
       ->expects($this->any())
       ->method('id')
-      ->will($this->returnValue(3));
+      ->willReturn(3);
 
     $entity_type = $this->createMock('Drupal\Core\Entity\EntityTypeInterface');
 
@@ -127,7 +127,7 @@ protected function setUp(): void {
     $this->items
       ->expects($this->any())
       ->method('defaultAccess')
-      ->will($this->returnValue(AccessResult::allowed()));
+      ->willReturn(AccessResult::allowed());
   }
 
   /**
@@ -139,12 +139,12 @@ public function assertFieldAccess(string $field, string $viewer, string $target,
     $field_definition = $this->createMock('Drupal\Core\Field\FieldDefinitionInterface');
     $field_definition->expects($this->any())
       ->method('getName')
-      ->will($this->returnValue($field));
+      ->willReturn($field);
 
     $this->items
       ->expects($this->any())
       ->method('getEntity')
-      ->will($this->returnValue($this->{$target}));
+      ->willReturn($this->{$target});
 
     foreach (['view' => $view, 'edit' => $edit] as $operation => $result) {
       $result_text = !isset($result) ? 'null' : ($result ? 'true' : 'false');
diff --git a/core/modules/user/tests/src/Unit/UserAuthTest.php b/core/modules/user/tests/src/Unit/UserAuthTest.php
index 926d48d4bc266e5b13869d5caa74b01d88ca3e8f..e5ab2bf805363d75711c0857aab6c985be573dfe 100644
--- a/core/modules/user/tests/src/Unit/UserAuthTest.php
+++ b/core/modules/user/tests/src/Unit/UserAuthTest.php
@@ -73,7 +73,7 @@ protected function setUp(): void {
     $entity_type_manager->expects($this->any())
       ->method('getStorage')
       ->with('user')
-      ->will($this->returnValue($this->userStorage));
+      ->willReturn($this->userStorage);
 
     $this->passwordService = $this->createMock('Drupal\Core\Password\PasswordInterface');
 
@@ -122,7 +122,7 @@ public function testAuthenticateWithNoAccountReturned() {
     $this->userStorage->expects($this->once())
       ->method('loadByProperties')
       ->with(['name' => $this->username])
-      ->will($this->returnValue([]));
+      ->willReturn([]);
 
     $this->assertFalse($this->userAuth->authenticate($this->username, $this->password));
   }
@@ -136,12 +136,12 @@ public function testAuthenticateWithIncorrectPassword() {
     $this->userStorage->expects($this->once())
       ->method('loadByProperties')
       ->with(['name' => $this->username])
-      ->will($this->returnValue([$this->testUser]));
+      ->willReturn([$this->testUser]);
 
     $this->passwordService->expects($this->once())
       ->method('check')
       ->with($this->password, $this->testUser->getPassword())
-      ->will($this->returnValue(FALSE));
+      ->willReturn(FALSE);
 
     $this->assertFalse($this->userAuth->authenticate($this->username, $this->password));
   }
@@ -154,17 +154,17 @@ public function testAuthenticateWithIncorrectPassword() {
   public function testAuthenticateWithCorrectPassword() {
     $this->testUser->expects($this->once())
       ->method('id')
-      ->will($this->returnValue(1));
+      ->willReturn(1);
 
     $this->userStorage->expects($this->once())
       ->method('loadByProperties')
       ->with(['name' => $this->username])
-      ->will($this->returnValue([$this->testUser]));
+      ->willReturn([$this->testUser]);
 
     $this->passwordService->expects($this->once())
       ->method('check')
       ->with($this->password, $this->testUser->getPassword())
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
 
     $this->assertSame(1, $this->userAuth->authenticate($this->username, $this->password));
   }
@@ -181,17 +181,17 @@ public function testAuthenticateWithCorrectPassword() {
   public function testAuthenticateWithZeroPassword() {
     $this->testUser->expects($this->once())
       ->method('id')
-      ->will($this->returnValue(2));
+      ->willReturn(2);
 
     $this->userStorage->expects($this->once())
       ->method('loadByProperties')
       ->with(['name' => $this->username])
-      ->will($this->returnValue([$this->testUser]));
+      ->willReturn([$this->testUser]);
 
     $this->passwordService->expects($this->once())
       ->method('check')
       ->with(0, 0)
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
 
     $this->assertSame(2, $this->userAuth->authenticate($this->username, 0));
   }
@@ -204,7 +204,7 @@ public function testAuthenticateWithZeroPassword() {
   public function testAuthenticateWithCorrectPasswordAndNewPasswordHash() {
     $this->testUser->expects($this->once())
       ->method('id')
-      ->will($this->returnValue(1));
+      ->willReturn(1);
     $this->testUser->expects($this->once())
       ->method('setPassword')
       ->with($this->password);
@@ -214,16 +214,16 @@ public function testAuthenticateWithCorrectPasswordAndNewPasswordHash() {
     $this->userStorage->expects($this->once())
       ->method('loadByProperties')
       ->with(['name' => $this->username])
-      ->will($this->returnValue([$this->testUser]));
+      ->willReturn([$this->testUser]);
 
     $this->passwordService->expects($this->once())
       ->method('check')
       ->with($this->password, $this->testUser->getPassword())
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
     $this->passwordService->expects($this->once())
       ->method('needsRehash')
       ->with($this->testUser->getPassword())
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
 
     $this->assertSame(1, $this->userAuth->authenticate($this->username, $this->password));
   }
diff --git a/core/modules/user/tests/src/Unit/Views/Argument/RolesRidTest.php b/core/modules/user/tests/src/Unit/Views/Argument/RolesRidTest.php
index dc1f9eae9cc5dab238c2c9477b8c2d3551990b62..8e18649ee70d9c141e9d4c1360f364d5d21f38d0 100644
--- a/core/modules/user/tests/src/Unit/Views/Argument/RolesRidTest.php
+++ b/core/modules/user/tests/src/Unit/Views/Argument/RolesRidTest.php
@@ -46,19 +46,19 @@ public function testTitleQuery() {
     $entity_type->expects($this->any())
       ->method('getKey')
       ->with('label')
-      ->will($this->returnValue('label'));
+      ->willReturn('label');
 
     $entity_type_manager = $this->createMock(EntityTypeManagerInterface::class);
     $entity_type_manager->expects($this->any())
       ->method('getDefinition')
       ->with($this->equalTo('user_role'))
-      ->will($this->returnValue($entity_type));
+      ->willReturn($entity_type);
 
     $entity_type_manager
       ->expects($this->once())
       ->method('getStorage')
       ->with($this->equalTo('user_role'))
-      ->will($this->returnValue($role_storage));
+      ->willReturn($role_storage);
 
     // Set up a minimal container to satisfy Drupal\Core\Entity\EntityBase's
     // dependency on it.
diff --git a/core/modules/views/tests/src/Unit/Controller/ViewAjaxControllerTest.php b/core/modules/views/tests/src/Unit/Controller/ViewAjaxControllerTest.php
index 429e71e3e6230f6cedc097574c2bb1505833f6cd..07d134ed40c4ee1b947b8abd89cc96fa9b10f75f 100644
--- a/core/modules/views/tests/src/Unit/Controller/ViewAjaxControllerTest.php
+++ b/core/modules/views/tests/src/Unit/Controller/ViewAjaxControllerTest.php
@@ -134,7 +134,7 @@ public function testMissingView() {
     $this->viewStorage->expects($this->once())
       ->method('load')
       ->with('test_view')
-      ->will($this->returnValue(FALSE));
+      ->willReturn(FALSE);
 
     $this->expectException(NotFoundHttpException::class);
     $this->viewAjaxController->ajaxView($request);
@@ -155,19 +155,19 @@ public function testAccessDeniedView() {
     $this->viewStorage->expects($this->once())
       ->method('load')
       ->with('test_view')
-      ->will($this->returnValue($view));
+      ->willReturn($view);
 
     $executable = $this->getMockBuilder('Drupal\views\ViewExecutable')
       ->disableOriginalConstructor()
       ->getMock();
     $executable->expects($this->once())
       ->method('access')
-      ->will($this->returnValue(FALSE));
+      ->willReturn(FALSE);
 
     $this->executableFactory->expects($this->once())
       ->method('get')
       ->with($view)
-      ->will($this->returnValue($executable));
+      ->willReturn($executable);
 
     $this->expectException(AccessDeniedHttpException::class);
     $this->viewAjaxController->ajaxView($request);
@@ -336,7 +336,7 @@ public function testAjaxViewWithPager() {
     $display_collection->expects($this->any())
       ->method('get')
       ->with('page_1')
-      ->will($this->returnValue($display_handler));
+      ->willReturn($display_handler);
     $executable->displayHandlers = $display_collection;
 
     $response = $this->viewAjaxController->ajaxView($request);
@@ -367,25 +367,25 @@ protected function setupValidMocks($use_ajax = self::USE_AJAX) {
     $this->viewStorage->expects($this->once())
       ->method('load')
       ->with('test_view')
-      ->will($this->returnValue($view));
+      ->willReturn($view);
 
     $executable = $this->getMockBuilder('Drupal\views\ViewExecutable')
       ->disableOriginalConstructor()
       ->getMock();
     $executable->expects($this->once())
       ->method('access')
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
     $executable->expects($this->any())
       ->method('setDisplay')
       ->willReturn(TRUE);
     $executable->expects($this->atMost(1))
       ->method('preview')
-      ->will($this->returnValue(['#markup' => 'View result']));
+      ->willReturn(['#markup' => 'View result']);
 
     $this->executableFactory->expects($this->once())
       ->method('get')
       ->with($view)
-      ->will($this->returnValue($executable));
+      ->willReturn($executable);
 
     $display_handler = $this->getMockBuilder('Drupal\views\Plugin\views\display\DisplayPluginBase')
       ->disableOriginalConstructor()
@@ -403,7 +403,7 @@ protected function setupValidMocks($use_ajax = self::USE_AJAX) {
     $display_collection->expects($this->any())
       ->method('get')
       ->with('page_1')
-      ->will($this->returnValue($display_handler));
+      ->willReturn($display_handler);
 
     $executable->display_handler = $display_handler;
     $executable->displayHandlers = $display_collection;
diff --git a/core/modules/views/tests/src/Unit/EventSubscriber/RouteSubscriberTest.php b/core/modules/views/tests/src/Unit/EventSubscriber/RouteSubscriberTest.php
index 3ea49352d6ec31bd1007ae066d17e6ea2191db55..55d9fcf5c0cda9fc151e5b2310674718c405b26d 100644
--- a/core/modules/views/tests/src/Unit/EventSubscriber/RouteSubscriberTest.php
+++ b/core/modules/views/tests/src/Unit/EventSubscriber/RouteSubscriberTest.php
@@ -59,7 +59,7 @@ protected function setUp(): void {
     $this->entityTypeManager->expects($this->any())
       ->method('getStorage')
       ->with('view')
-      ->will($this->returnValue($this->viewStorage));
+      ->willReturn($this->viewStorage);
     $this->state = $this->createMock('\Drupal\Core\State\StateInterface');
     $this->routeSubscriber = new TestRouteSubscriber($this->entityTypeManager, $this->state);
   }
@@ -72,10 +72,10 @@ public function testRouteRebuildFinished() {
 
     $display_1->expects($this->once())
       ->method('collectRoutes')
-      ->will($this->returnValue(['test_id.page_1' => 'views.test_id.page_1']));
+      ->willReturn(['test_id.page_1' => 'views.test_id.page_1']);
     $display_2->expects($this->once())
       ->method('collectRoutes')
-      ->will($this->returnValue(['test_id.page_2' => 'views.test_id.page_2']));
+      ->willReturn(['test_id.page_2' => 'views.test_id.page_2']);
 
     $this->routeSubscriber->routes();
 
@@ -155,14 +155,14 @@ protected function setupMocks() {
       ->getMock();
     $this->viewStorage->expects($this->any())
       ->method('load')
-      ->will($this->returnValue($view));
+      ->willReturn($view);
 
     $view->expects($this->any())
       ->method('getExecutable')
-      ->will($this->returnValue($executable));
+      ->willReturn($executable);
     $view->expects($this->any())
       ->method('id')
-      ->will($this->returnValue('test_id'));
+      ->willReturn('test_id');
     $executable->storage = $view;
 
     $executable->expects($this->any())
diff --git a/core/modules/views/tests/src/Unit/Plugin/Block/ViewsBlockTest.php b/core/modules/views/tests/src/Unit/Plugin/Block/ViewsBlockTest.php
index 446dbc8be73170fc9465072c098e531260951448..796c3c87a3774a6c8c3bf9a8134fc5d76fb28039 100644
--- a/core/modules/views/tests/src/Unit/Plugin/Block/ViewsBlockTest.php
+++ b/core/modules/views/tests/src/Unit/Plugin/Block/ViewsBlockTest.php
@@ -63,7 +63,7 @@ protected function setUp(): void {
     $condition_plugin_manager = $this->createMock('Drupal\Core\Executable\ExecutableManagerInterface');
     $condition_plugin_manager->expects($this->any())
       ->method('getDefinitions')
-      ->will($this->returnValue([]));
+      ->willReturn([]);
     $container = new ContainerBuilder();
     $container->set('plugin.manager.condition', $condition_plugin_manager);
     \Drupal::setContainer($container);
@@ -75,7 +75,7 @@ protected function setUp(): void {
     $this->executable->expects($this->any())
       ->method('setDisplay')
       ->with('block_1')
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
     $this->executable->expects($this->any())
       ->method('getShowAdminLinks')
       ->willReturn(FALSE);
@@ -99,7 +99,7 @@ protected function setUp(): void {
     $this->executableFactory->expects($this->any())
       ->method('get')
       ->with($this->view)
-      ->will($this->returnValue($this->executable));
+      ->willReturn($this->executable);
 
     $this->displayHandler = $this->getMockBuilder('Drupal\views\Plugin\views\display\Block')
       ->disableOriginalConstructor()
@@ -126,7 +126,7 @@ protected function setUp(): void {
     $this->storage->expects($this->any())
       ->method('load')
       ->with('test_view')
-      ->will($this->returnValue($this->view));
+      ->willReturn($this->view);
     $this->account = $this->createMock('Drupal\Core\Session\AccountInterface');
   }
 
diff --git a/core/modules/views/tests/src/Unit/Plugin/Derivative/ViewsLocalTaskTest.php b/core/modules/views/tests/src/Unit/Plugin/Derivative/ViewsLocalTaskTest.php
index 00cc3654863c4ac01f4022fb5857458fbf04ef23..d875c01a02e3ccd85baaebbd8718ae82bb729e42 100644
--- a/core/modules/views/tests/src/Unit/Plugin/Derivative/ViewsLocalTaskTest.php
+++ b/core/modules/views/tests/src/Unit/Plugin/Derivative/ViewsLocalTaskTest.php
@@ -87,7 +87,7 @@ public function testGetDerivativeDefinitionsWithoutLocalTask() {
     $display_plugin->expects($this->once())
       ->method('getOption')
       ->with('menu')
-      ->will($this->returnValue(['type' => 'normal']));
+      ->willReturn(['type' => 'normal']);
     $executable->display_handler = $display_plugin;
 
     $storage = $this->getMockBuilder('Drupal\views\Entity\View')
@@ -95,7 +95,7 @@ public function testGetDerivativeDefinitionsWithoutLocalTask() {
       ->getMock();
     $storage->expects($this->any())
       ->method('id')
-      ->will($this->returnValue('example_view'));
+      ->willReturn('example_view');
     $storage->expects($this->any())
       ->method('getExecutable')
       ->willReturn($executable);
@@ -124,7 +124,7 @@ public function testGetDerivativeDefinitionsWithLocalTask() {
       ->getMock();
     $storage->expects($this->any())
       ->method('id')
-      ->will($this->returnValue('example_view'));
+      ->willReturn('example_view');
     $storage->expects($this->any())
       ->method('getExecutable')
       ->willReturn($executable);
@@ -142,7 +142,11 @@ public function testGetDerivativeDefinitionsWithLocalTask() {
     $display_plugin->expects($this->once())
       ->method('getOption')
       ->with('menu')
-      ->will($this->returnValue(['type' => 'tab', 'weight' => 12, 'title' => 'Example title']));
+      ->willReturn([
+        'type' => 'tab',
+        'weight' => 12,
+        'title' => 'Example title',
+      ]);
     $executable->display_handler = $display_plugin;
 
     $result = [['example_view', 'page_1']];
@@ -154,7 +158,7 @@ public function testGetDerivativeDefinitionsWithLocalTask() {
     $this->state->expects($this->once())
       ->method('get')
       ->with('views.view_route_names')
-      ->will($this->returnValue($view_route_names));
+      ->willReturn($view_route_names);
 
     $definitions = $this->localTaskDerivative->getDerivativeDefinitions($this->baseDefinition);
     $this->assertCount(1, $definitions);
@@ -177,7 +181,7 @@ public function testGetDerivativeDefinitionsWithOverrideRoute() {
       ->getMock();
     $storage->expects($this->any())
       ->method('id')
-      ->will($this->returnValue('example_view'));
+      ->willReturn('example_view');
     $storage->expects($this->any())
       ->method('getExecutable')
       ->willReturn($executable);
@@ -195,7 +199,7 @@ public function testGetDerivativeDefinitionsWithOverrideRoute() {
     $display_plugin->expects($this->once())
       ->method('getOption')
       ->with('menu')
-      ->will($this->returnValue(['type' => 'tab', 'weight' => 12]));
+      ->willReturn(['type' => 'tab', 'weight' => 12]);
     $executable->display_handler = $display_plugin;
 
     $result = [['example_view', 'page_1']];
@@ -208,7 +212,7 @@ public function testGetDerivativeDefinitionsWithOverrideRoute() {
     $this->state->expects($this->once())
       ->method('get')
       ->with('views.view_route_names')
-      ->will($this->returnValue($view_route_names));
+      ->willReturn($view_route_names);
 
     $definitions = $this->localTaskDerivative->getDerivativeDefinitions($this->baseDefinition);
     $this->assertCount(0, $definitions);
@@ -226,7 +230,7 @@ public function testGetDerivativeDefinitionsWithDefaultLocalTask() {
       ->getMock();
     $storage->expects($this->any())
       ->method('id')
-      ->will($this->returnValue('example_view'));
+      ->willReturn('example_view');
     $storage->expects($this->any())
       ->method('getExecutable')
       ->willReturn($executable);
@@ -244,7 +248,11 @@ public function testGetDerivativeDefinitionsWithDefaultLocalTask() {
     $display_plugin->expects($this->exactly(2))
       ->method('getOption')
       ->with('menu')
-      ->will($this->returnValue(['type' => 'default tab', 'weight' => 12, 'title' => 'Example title']));
+      ->willReturn([
+        'type' => 'default tab',
+        'weight' => 12,
+        'title' => 'Example title',
+      ]);
     $executable->display_handler = $display_plugin;
 
     $result = [['example_view', 'page_1']];
@@ -256,7 +264,7 @@ public function testGetDerivativeDefinitionsWithDefaultLocalTask() {
     $this->state->expects($this->exactly(2))
       ->method('get')
       ->with('views.view_route_names')
-      ->will($this->returnValue($view_route_names));
+      ->willReturn($view_route_names);
 
     $definitions = $this->localTaskDerivative->getDerivativeDefinitions($this->baseDefinition);
     $this->assertCount(1, $definitions);
@@ -295,7 +303,7 @@ public function testGetDerivativeDefinitionsWithExistingLocalTask() {
       ->getMock();
     $storage->expects($this->any())
       ->method('id')
-      ->will($this->returnValue('example_view'));
+      ->willReturn('example_view');
     $storage->expects($this->any())
       ->method('getExecutable')
       ->willReturn($executable);
@@ -313,10 +321,14 @@ public function testGetDerivativeDefinitionsWithExistingLocalTask() {
     $display_plugin->expects($this->exactly(2))
       ->method('getOption')
       ->with('menu')
-      ->will($this->returnValue(['type' => 'tab', 'weight' => 12, 'title' => 'Example title']));
+      ->willReturn([
+        'type' => 'tab',
+        'weight' => 12,
+        'title' => 'Example title',
+      ]);
     $display_plugin->expects($this->once())
       ->method('getPath')
-      ->will($this->returnValue('path/example'));
+      ->willReturn('path/example');
     $executable->display_handler = $display_plugin;
 
     $result = [['example_view', 'page_1']];
@@ -328,7 +340,7 @@ public function testGetDerivativeDefinitionsWithExistingLocalTask() {
     $this->state->expects($this->exactly(2))
       ->method('get')
       ->with('views.view_route_names')
-      ->will($this->returnValue($view_route_names));
+      ->willReturn($view_route_names);
 
     // Mock the route provider.
     $route_collection = new RouteCollection();
@@ -336,7 +348,7 @@ public function testGetDerivativeDefinitionsWithExistingLocalTask() {
     $this->routeProvider->expects($this->any())
       ->method('getRoutesByPattern')
       ->with('/path')
-      ->will($this->returnValue($route_collection));
+      ->willReturn($route_collection);
 
     // Setup the existing local task of the test_route.
     $definitions['test_route_tab'] = $other_tab = [
diff --git a/core/modules/views/tests/src/Unit/Plugin/argument_default/RawTest.php b/core/modules/views/tests/src/Unit/Plugin/argument_default/RawTest.php
index a153c09a962ffc8242956d150fdd01ab6179f151..66c5c9772f9ee58aacb9bd08cc2baef1154be911 100644
--- a/core/modules/views/tests/src/Unit/Plugin/argument_default/RawTest.php
+++ b/core/modules/views/tests/src/Unit/Plugin/argument_default/RawTest.php
@@ -33,7 +33,7 @@ public function testGetArgument() {
     $current_path->setPath('/test/example', $request);
     $view->expects($this->any())
       ->method('getRequest')
-      ->will($this->returnValue($request));
+      ->willReturn($request);
     $alias_manager = $this->createMock(AliasManagerInterface::class);
     $alias_manager->expects($this->never())
       ->method('getAliasByPath');
@@ -76,7 +76,7 @@ public function testGetArgument() {
     $alias_manager->expects($this->any())
       ->method('getAliasByPath')
       ->with($this->equalTo('/test/example'))
-      ->will($this->returnValue('/other/example'));
+      ->willReturn('/other/example');
 
     $raw = new Raw([], 'raw', [], $alias_manager, $current_path);
     $options = [
diff --git a/core/modules/views/tests/src/Unit/Plugin/argument_validator/EntityTest.php b/core/modules/views/tests/src/Unit/Plugin/argument_validator/EntityTest.php
index 74eb8d5c478c88950003c47424e355c2b2beac16..b7ccfa001980fd1edc5a4dce8bc91f661bd8b806 100644
--- a/core/modules/views/tests/src/Unit/Plugin/argument_validator/EntityTest.php
+++ b/core/modules/views/tests/src/Unit/Plugin/argument_validator/EntityTest.php
@@ -60,7 +60,7 @@ protected function setUp(): void {
     $mock_entity = $this->getMockForAbstractClass('Drupal\Core\Entity\EntityBase', [], '', FALSE, TRUE, TRUE, ['bundle', 'access']);
     $mock_entity->expects($this->any())
       ->method('bundle')
-      ->will($this->returnValue('test_bundle'));
+      ->willReturn('test_bundle');
     $mock_entity->expects($this->any())
       ->method('access')
       ->willReturnMap([
@@ -72,7 +72,7 @@ protected function setUp(): void {
     $mock_entity_bundle_2 = $this->getMockForAbstractClass('Drupal\Core\Entity\EntityBase', [], '', FALSE, TRUE, TRUE, ['bundle', 'access']);
     $mock_entity_bundle_2->expects($this->any())
       ->method('bundle')
-      ->will($this->returnValue('test_bundle_2'));
+      ->willReturn('test_bundle_2');
     $mock_entity_bundle_2->expects($this->any())
       ->method('access')
       ->willReturnMap([
@@ -100,7 +100,7 @@ protected function setUp(): void {
     $this->entityTypeManager->expects($this->any())
       ->method('getStorage')
       ->with('entity_test')
-      ->will($this->returnValue($storage));
+      ->willReturn($storage);
 
     $this->executable = $this->getMockBuilder('Drupal\views\ViewExecutable')
       ->disableOriginalConstructor()
diff --git a/core/modules/views/tests/src/Unit/Plugin/display/PathPluginBaseTest.php b/core/modules/views/tests/src/Unit/Plugin/display/PathPluginBaseTest.php
index 7cd7f47e9cbda72f61fa1ead21e0af6252eeeaa4..e4a24f61144068f35f10c0e35d6d08da9f7e0789 100644
--- a/core/modules/views/tests/src/Unit/Plugin/display/PathPluginBaseTest.php
+++ b/core/modules/views/tests/src/Unit/Plugin/display/PathPluginBaseTest.php
@@ -546,7 +546,7 @@ protected function setupViewExecutableAccessPlugin() {
       ->getMock();
     $view_entity->expects($this->any())
       ->method('id')
-      ->will($this->returnValue('test_id'));
+      ->willReturn('test_id');
 
     $view = $this->getMockBuilder('Drupal\views\ViewExecutable')
       ->disableOriginalConstructor()
@@ -559,7 +559,7 @@ protected function setupViewExecutableAccessPlugin() {
       ->getMockForAbstractClass();
     $this->accessPluginManager->expects($this->any())
       ->method('createInstance')
-      ->will($this->returnValue($access_plugin));
+      ->willReturn($access_plugin);
 
     return [$view, $view_entity, $access_plugin];
   }
diff --git a/core/modules/views/tests/src/Unit/Plugin/pager/PagerPluginBaseTest.php b/core/modules/views/tests/src/Unit/Plugin/pager/PagerPluginBaseTest.php
index 44317fa37f1274cf3636f847ed551d79b032a9fd..5af77767b36b9ae3136f59de2b575cb72513f4d5 100644
--- a/core/modules/views/tests/src/Unit/Plugin/pager/PagerPluginBaseTest.php
+++ b/core/modules/views/tests/src/Unit/Plugin/pager/PagerPluginBaseTest.php
@@ -213,7 +213,7 @@ public function testExecuteCountQueryWithoutOffset() {
 
     $statement->expects($this->once())
       ->method('fetchField')
-      ->will($this->returnValue(3));
+      ->willReturn(3);
 
     $query = $this->getMockBuilder('\Drupal\Core\Database\Query\Select')
       ->disableOriginalConstructor()
@@ -221,7 +221,7 @@ public function testExecuteCountQueryWithoutOffset() {
 
     $query->expects($this->once())
       ->method('execute')
-      ->will($this->returnValue($statement));
+      ->willReturn($statement);
 
     $this->pager->setOffset(0);
     $this->assertEquals(3, $this->pager->executeCountQuery($query));
@@ -237,7 +237,7 @@ public function testExecuteCountQueryWithOffset() {
 
     $statement->expects($this->once())
       ->method('fetchField')
-      ->will($this->returnValue(3));
+      ->willReturn(3);
 
     $query = $this->getMockBuilder('\Drupal\Core\Database\Query\Select')
       ->disableOriginalConstructor()
@@ -245,7 +245,7 @@ public function testExecuteCountQueryWithOffset() {
 
     $query->expects($this->once())
       ->method('execute')
-      ->will($this->returnValue($statement));
+      ->willReturn($statement);
 
     $this->pager->setOffset(2);
     $this->assertEquals(1, $this->pager->executeCountQuery($query));
@@ -261,7 +261,7 @@ public function testExecuteCountQueryWithOffsetLargerThanResult() {
 
     $statement->expects($this->once())
       ->method('fetchField')
-      ->will($this->returnValue(2));
+      ->willReturn(2);
 
     $query = $this->getMockBuilder(Select::class)
       ->disableOriginalConstructor()
@@ -269,7 +269,7 @@ public function testExecuteCountQueryWithOffsetLargerThanResult() {
 
     $query->expects($this->once())
       ->method('execute')
-      ->will($this->returnValue($statement));
+      ->willReturn($statement);
 
     $this->pager->setOffset(3);
     $this->assertEquals(0, $this->pager->executeCountQuery($query));
diff --git a/core/modules/views/tests/src/Unit/Plugin/views/display/BlockTest.php b/core/modules/views/tests/src/Unit/Plugin/views/display/BlockTest.php
index 5cea3d915fa063e3f1b42918cb1f75d43b8acbfa..bc191018246d2926adec99065ade4ec3476bc821 100644
--- a/core/modules/views/tests/src/Unit/Plugin/views/display/BlockTest.php
+++ b/core/modules/views/tests/src/Unit/Plugin/views/display/BlockTest.php
@@ -44,7 +44,7 @@ protected function setUp(): void {
     $this->executable->expects($this->any())
       ->method('setDisplay')
       ->with('block_1')
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
 
     $this->blockDisplay = $this->executable->display_handler = $this->getMockBuilder('Drupal\views\Plugin\views\display\Block')
       ->disableOriginalConstructor()
@@ -67,7 +67,7 @@ public function testBuildNoOverride() {
 
     $this->blockPlugin->expects($this->once())
       ->method('getConfiguration')
-      ->will($this->returnValue(['items_per_page' => 'none']));
+      ->willReturn(['items_per_page' => 'none']);
 
     $this->blockDisplay->preBlockBuild($this->blockPlugin);
   }
@@ -82,7 +82,7 @@ public function testBuildOverride() {
 
     $this->blockPlugin->expects($this->once())
       ->method('getConfiguration')
-      ->will($this->returnValue(['items_per_page' => 5]));
+      ->willReturn(['items_per_page' => 5]);
 
     $this->blockDisplay->preBlockBuild($this->blockPlugin);
   }
diff --git a/core/modules/views/tests/src/Unit/Plugin/views/field/EntityOperationsUnitTest.php b/core/modules/views/tests/src/Unit/Plugin/views/field/EntityOperationsUnitTest.php
index b5daf4ab1da14eaedb641caea1d31d8ae641b604..8dfa29357dacdb763b971ff9abb391b6b194a6ee 100644
--- a/core/modules/views/tests/src/Unit/Plugin/views/field/EntityOperationsUnitTest.php
+++ b/core/modules/views/tests/src/Unit/Plugin/views/field/EntityOperationsUnitTest.php
@@ -101,7 +101,7 @@ public function testRenderWithDestination() {
       ->getMock();
     $entity->expects($this->any())
       ->method('getEntityTypeId')
-      ->will($this->returnValue($entity_type_id));
+      ->willReturn($entity_type_id);
 
     $operations = [
       'foo' => [
@@ -112,12 +112,12 @@ public function testRenderWithDestination() {
     $list_builder->expects($this->once())
       ->method('getOperations')
       ->with($entity)
-      ->will($this->returnValue($operations));
+      ->willReturn($operations);
 
     $this->entityTypeManager->expects($this->once())
       ->method('getListBuilder')
       ->with($entity_type_id)
-      ->will($this->returnValue($list_builder));
+      ->willReturn($list_builder);
 
     $this->plugin->options['destination'] = TRUE;
 
@@ -143,7 +143,7 @@ public function testRenderWithoutDestination() {
       ->getMock();
     $entity->expects($this->any())
       ->method('getEntityTypeId')
-      ->will($this->returnValue($entity_type_id));
+      ->willReturn($entity_type_id);
 
     $operations = [
       'foo' => [
@@ -154,12 +154,12 @@ public function testRenderWithoutDestination() {
     $list_builder->expects($this->once())
       ->method('getOperations')
       ->with($entity)
-      ->will($this->returnValue($operations));
+      ->willReturn($operations);
 
     $this->entityTypeManager->expects($this->once())
       ->method('getListBuilder')
       ->with($entity_type_id)
-      ->will($this->returnValue($list_builder));
+      ->willReturn($list_builder);
 
     $this->plugin->options['destination'] = FALSE;
 
diff --git a/core/modules/views/tests/src/Unit/ViewsDataHelperTest.php b/core/modules/views/tests/src/Unit/ViewsDataHelperTest.php
index 6dbfd3c94ddae45eed73b78753c5c83ba0e28afe..e481bb3faa77ebd9d98f36cc50a2ea7b92d17cfd 100644
--- a/core/modules/views/tests/src/Unit/ViewsDataHelperTest.php
+++ b/core/modules/views/tests/src/Unit/ViewsDataHelperTest.php
@@ -44,7 +44,7 @@ public function testFetchFields() {
       ->getMock();
     $views_data->expects($this->once())
       ->method('getAll')
-      ->will($this->returnValue($this->viewsData()));
+      ->willReturn($this->viewsData());
 
     $data_helper = new ViewsDataHelper($views_data);
 
diff --git a/core/modules/views/tests/src/Unit/ViewsDataTest.php b/core/modules/views/tests/src/Unit/ViewsDataTest.php
index 30233553ceafdbc049f6410b4ee3d35f9995b908..b30ff6480535a904880ac0bc2166c1e2c5c9bc61 100644
--- a/core/modules/views/tests/src/Unit/ViewsDataTest.php
+++ b/core/modules/views/tests/src/Unit/ViewsDataTest.php
@@ -70,7 +70,7 @@ protected function setUp(): void {
     $this->languageManager = $this->createMock('Drupal\Core\Language\LanguageManagerInterface');
     $this->languageManager->expects($this->any())
       ->method('getCurrentLanguage')
-      ->will($this->returnValue(new Language(['id' => 'en'])));
+      ->willReturn(new Language(['id' => 'en']));
 
     $this->viewsData = new ViewsData($this->cacheBackend, $this->configFactory, $this->moduleHandler, $this->languageManager);
   }
@@ -192,7 +192,7 @@ public function testGetOnFirstCall() {
     $this->cacheBackend->expects($this->once())
       ->method('get')
       ->with("views_data:en")
-      ->will($this->returnValue(FALSE));
+      ->willReturn(FALSE);
 
     $expected_views_data = $this->viewsDataWithProvider();
     $views_data = $this->viewsData->getAll();
@@ -281,7 +281,7 @@ public function testFullGetCache() {
     $this->cacheBackend->expects($this->once())
       ->method('get')
       ->with("views_data:en")
-      ->will($this->returnValue(FALSE));
+      ->willReturn(FALSE);
 
     $views_data = $this->viewsData->getAll();
     $this->assertSame($expected_views_data, $views_data);
@@ -404,7 +404,7 @@ public function testCacheCallsWithSameTableMultipleTimesAndWarmCache() {
     $this->cacheBackend->expects($this->once())
       ->method('get')
       ->with('views_data:views_test_data:en')
-      ->will($this->returnValue((object) ['data' => $expected_views_data['views_test_data']]));
+      ->willReturn((object) ['data' => $expected_views_data['views_test_data']]);
     $this->cacheBackend->expects($this->never())
       ->method('set');
 
@@ -512,7 +512,7 @@ public function testCacheCallsWithWarmCacheForInvalidTable() {
     $this->cacheBackend->expects($this->once())
       ->method('get')
       ->with("views_data:$non_existing_table:en")
-      ->will($this->returnValue((object) ['data' => []]));
+      ->willReturn((object) ['data' => []]);
     $this->cacheBackend->expects($this->never())
       ->method('set');
 
@@ -565,7 +565,7 @@ public function testCacheCallsWithWarmCacheAndGetAllTables() {
     $this->cacheBackend->expects($this->once())
       ->method('get')
       ->with("views_data:en")
-      ->will($this->returnValue((object) ['data' => $expected_views_data]));
+      ->willReturn((object) ['data' => $expected_views_data]);
     $this->cacheBackend->expects($this->never())
       ->method('set');
 
diff --git a/core/modules/views/tests/src/Unit/ViewsTest.php b/core/modules/views/tests/src/Unit/ViewsTest.php
index 813c88d980a49e798057cdb347ef39673955f714..5eb36e4c0de591f95b831126c61631b055b7c270 100644
--- a/core/modules/views/tests/src/Unit/ViewsTest.php
+++ b/core/modules/views/tests/src/Unit/ViewsTest.php
@@ -58,13 +58,13 @@ public function testGetView() {
     $view_storage->expects($this->once())
       ->method('load')
       ->with('test_view')
-      ->will($this->returnValue($view));
+      ->willReturn($view);
 
     $entity_type_manager = $this->createMock('Drupal\Core\Entity\EntityTypeManagerInterface');
     $entity_type_manager->expects($this->once())
       ->method('getStorage')
       ->with('view')
-      ->will($this->returnValue($view_storage));
+      ->willReturn($view_storage);
     $this->container->set('entity_type.manager', $entity_type_manager);
 
     $executable = Views::getView('test_view');
@@ -168,13 +168,17 @@ public function testGetApplicableViews($applicable_type, $expected) {
     $view_storage->expects($this->once())
       ->method('loadMultiple')
       ->with(['test_view_1', 'test_view_2', 'test_view_3'])
-      ->will($this->returnValue(['test_view_1' => $view_1, 'test_view_2' => $view_2, 'test_view_3' => $view_3]));
+      ->willReturn([
+        'test_view_1' => $view_1,
+        'test_view_2' => $view_2,
+        'test_view_3' => $view_3,
+      ]);
 
     $entity_type_manager = $this->createMock(EntityTypeManagerInterface::class);
     $entity_type_manager->expects($this->exactly(2))
       ->method('getStorage')
       ->with('view')
-      ->will($this->returnValue($view_storage));
+      ->willReturn($view_storage);
     $this->container->set('entity_type.manager', $entity_type_manager);
 
     $definitions = [
diff --git a/core/modules/views_ui/tests/src/Unit/ViewListBuilderTest.php b/core/modules/views_ui/tests/src/Unit/ViewListBuilderTest.php
index c0d3eea411c7c9ae317f1835146a1e5d7dec28b2..b576cb7b01a8d42fbbf691c6d62673428286bbd4 100644
--- a/core/modules/views_ui/tests/src/Unit/ViewListBuilderTest.php
+++ b/core/modules/views_ui/tests/src/Unit/ViewListBuilderTest.php
@@ -90,10 +90,11 @@ public function testBuildRowEntityList() {
       ->getMock();
     $page_display->expects($this->any())
       ->method('getPath')
-      ->will($this->onConsecutiveCalls(
-        $this->returnValue('test_page'),
-        $this->returnValue('<object>malformed_path</object>'),
-        $this->returnValue('<script>alert("placeholder_page/%")</script>')));
+      ->willReturnOnConsecutiveCalls(
+        'test_page',
+        '<object>malformed_path</object>',
+        '<script>alert("placeholder_page/%")</script>',
+      );
 
     $embed_display = $this->getMockBuilder('Drupal\views\Plugin\views\display\Embed')
       ->onlyMethods(['initDisplay'])
diff --git a/core/modules/views_ui/tests/src/Unit/ViewUIObjectTest.php b/core/modules/views_ui/tests/src/Unit/ViewUIObjectTest.php
index 17f93a4777d6540844c23b23ee88462b7227ef17..36b4933a6f539da5330390642ad5258d01e3ffae 100644
--- a/core/modules/views_ui/tests/src/Unit/ViewUIObjectTest.php
+++ b/core/modules/views_ui/tests/src/Unit/ViewUIObjectTest.php
@@ -85,7 +85,7 @@ public function testIsLocked() {
     $account = $this->createMock('Drupal\Core\Session\AccountInterface');
     $account->expects($this->exactly(2))
       ->method('id')
-      ->will($this->returnValue(1));
+      ->willReturn(1);
 
     $container = new ContainerBuilder();
     $container->set('current_user', $account);
diff --git a/core/tests/Drupal/KernelTests/Core/Config/ExportStorageManagerTest.php b/core/tests/Drupal/KernelTests/Core/Config/ExportStorageManagerTest.php
index a5e2b3ead40e1aaf81d0b649acaded304c6d972f..cd8486a67c6e2d92de0eb7830f42fccabc9aefcd 100644
--- a/core/tests/Drupal/KernelTests/Core/Config/ExportStorageManagerTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Config/ExportStorageManagerTest.php
@@ -82,7 +82,7 @@ public function testGetStorageLock() {
     $lock->expects($this->exactly(2))
       ->method('acquire')
       ->with(ExportStorageManager::LOCK_NAME)
-      ->will($this->returnValue(FALSE));
+      ->willReturn(FALSE);
     $lock->expects($this->once())
       ->method('wait')
       ->with(ExportStorageManager::LOCK_NAME);
diff --git a/core/tests/Drupal/KernelTests/Core/Config/ImportStorageTransformerTest.php b/core/tests/Drupal/KernelTests/Core/Config/ImportStorageTransformerTest.php
index 9e637c9c7ac6e91f1ecce75046806d38e87a9961..a843e9a38580e2a88885473a5ab2a6b3f46b0d03 100644
--- a/core/tests/Drupal/KernelTests/Core/Config/ImportStorageTransformerTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Config/ImportStorageTransformerTest.php
@@ -69,7 +69,7 @@ public function testTransformLocked() {
     $lock->expects($this->exactly(2))
       ->method('acquire')
       ->with(ImportStorageTransformer::LOCK_NAME)
-      ->will($this->returnValue(FALSE));
+      ->willReturn(FALSE);
     $lock->expects($this->once())
       ->method('wait')
       ->with(ImportStorageTransformer::LOCK_NAME);
@@ -100,7 +100,7 @@ public function testTransformWhileImporting() {
     $lock->expects($this->once())
       ->method('lockMayBeAvailable')
       ->with(ConfigImporter::LOCK_NAME)
-      ->will($this->returnValue(FALSE));
+      ->willReturn(FALSE);
 
     // The import transformer under test.
     $transformer = new ImportStorageTransformer(
diff --git a/core/tests/Drupal/KernelTests/Core/Database/LoggingTest.php b/core/tests/Drupal/KernelTests/Core/Database/LoggingTest.php
index 1badabf54067af99d518190e3dea87a5e66c435c..7858169af18488a6d67f5cccfe0a23147dd84baf 100644
--- a/core/tests/Drupal/KernelTests/Core/Database/LoggingTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Database/LoggingTest.php
@@ -163,7 +163,7 @@ public function testContribDriverLog($driver_namespace, $stack, array $expected_
       ->getMock();
     $log->expects($this->once())
       ->method('getDebugBacktrace')
-      ->will($this->returnValue($stack));
+      ->willReturn($stack);
     Database::addConnectionInfo('test', 'default', ['driver' => 'mysql', 'namespace' => $driver_namespace]);
 
     $result = $log->findCaller($stack);
diff --git a/core/tests/Drupal/Tests/Core/Access/AccessManagerTest.php b/core/tests/Drupal/Tests/Core/Access/AccessManagerTest.php
index 85181be82c13ae68bb9252856df8ef3ae4b5bb7b..8a3a71da0b9b66c101f97f2377640f0d8826bae5 100644
--- a/core/tests/Drupal/Tests/Core/Access/AccessManagerTest.php
+++ b/core/tests/Drupal/Tests/Core/Access/AccessManagerTest.php
@@ -363,7 +363,7 @@ public function testCheckNamedRouteWithUpcastedValues() {
     $this->routeProvider->expects($this->any())
       ->method('getRouteByName')
       ->with('test_route_1')
-      ->will($this->returnValue($route));
+      ->willReturn($route);
 
     $map[] = ['test_route_1', ['value' => 'example'], '/test-route-1/example'];
 
@@ -371,7 +371,7 @@ public function testCheckNamedRouteWithUpcastedValues() {
     $this->paramConverter->expects($this->atLeastOnce())
       ->method('convert')
       ->with(['value' => 'example', RouteObjectInterface::ROUTE_NAME => 'test_route_1', RouteObjectInterface::ROUTE_OBJECT => $route])
-      ->will($this->returnValue(['value' => 'upcasted_value']));
+      ->willReturn(['value' => 'upcasted_value']);
 
     $this->setupAccessArgumentsResolverFactory($this->exactly(2))
       ->with($this->callback(function ($route_match) {
@@ -383,10 +383,10 @@ public function testCheckNamedRouteWithUpcastedValues() {
     $access_check = $this->createMock('Drupal\Tests\Core\Access\TestAccessCheckInterface');
     $access_check->expects($this->atLeastOnce())
       ->method('applies')
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
     $access_check->expects($this->atLeastOnce())
       ->method('access')
-      ->will($this->returnValue(AccessResult::forbidden()));
+      ->willReturn(AccessResult::forbidden());
 
     $this->container->set('test_access', $access_check);
     $this->container->setParameter('dynamic_access_check_services', ['test_access']);
@@ -412,7 +412,7 @@ public function testCheckNamedRouteWithDefaultValue() {
     $this->routeProvider->expects($this->any())
       ->method('getRouteByName')
       ->with('test_route_1')
-      ->will($this->returnValue($route));
+      ->willReturn($route);
 
     $map[] = ['test_route_1', ['value' => 'example'], '/test-route-1/example'];
 
@@ -420,7 +420,7 @@ public function testCheckNamedRouteWithDefaultValue() {
     $this->paramConverter->expects($this->atLeastOnce())
       ->method('convert')
       ->with(['value' => 'example', RouteObjectInterface::ROUTE_NAME => 'test_route_1', RouteObjectInterface::ROUTE_OBJECT => $route])
-      ->will($this->returnValue(['value' => 'upcasted_value']));
+      ->willReturn(['value' => 'upcasted_value']);
 
     $this->setupAccessArgumentsResolverFactory($this->exactly(2))
       ->with($this->callback(function ($route_match) {
@@ -432,10 +432,10 @@ public function testCheckNamedRouteWithDefaultValue() {
     $access_check = $this->createMock('Drupal\Tests\Core\Access\TestAccessCheckInterface');
     $access_check->expects($this->atLeastOnce())
       ->method('applies')
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
     $access_check->expects($this->atLeastOnce())
       ->method('access')
-      ->will($this->returnValue(AccessResult::forbidden()));
+      ->willReturn(AccessResult::forbidden());
 
     $this->container->set('test_access', $access_check);
     $this->container->setParameter('dynamic_access_check_services', ['test_access']);
@@ -482,12 +482,12 @@ public function testCheckException($return_value) {
 
     $route_provider->expects($this->any())
       ->method('getRouteByName')
-      ->will($this->returnValue($route));
+      ->willReturn($route);
 
     $this->paramConverter = $this->createMock('Drupal\Core\ParamConverter\ParamConverterManagerInterface');
     $this->paramConverter->expects($this->any())
       ->method('convert')
-      ->will($this->returnValue([]));
+      ->willReturn([]);
 
     $this->setupAccessArgumentsResolverFactory();
 
@@ -497,7 +497,7 @@ public function testCheckException($return_value) {
     $access_check = $this->createMock('Drupal\Tests\Core\Access\TestAccessCheckInterface');
     $access_check->expects($this->any())
       ->method('access')
-      ->will($this->returnValue($return_value));
+      ->willReturn($return_value);
     $container->set('test_incorrect_value', $access_check);
 
     $access_manager = new AccessManager($route_provider, $this->paramConverter, $this->argumentsResolverFactory, $this->currentUser, $this->checkProvider);
diff --git a/core/tests/Drupal/Tests/Core/Access/AccessResultTest.php b/core/tests/Drupal/Tests/Core/Access/AccessResultTest.php
index dbe8008b00e901823babed3cb4a0094230624b66..24ca0617f9c66ed7c7aaf331304c62775e2cc6cf 100644
--- a/core/tests/Drupal/Tests/Core/Access/AccessResultTest.php
+++ b/core/tests/Drupal/Tests/Core/Access/AccessResultTest.php
@@ -462,7 +462,7 @@ public function testCacheContexts() {
     $account->expects($this->any())
       ->method('hasPermission')
       ->with('may herd llamas')
-      ->will($this->returnValue(FALSE));
+      ->willReturn(FALSE);
     $contexts = ['user.permissions'];
 
     // Verify the object when using the ::allowedIfHasPermission() convenience
@@ -514,7 +514,7 @@ public function testCacheTags() {
     $node = $this->createMock('\Drupal\node\NodeInterface');
     $node->expects($this->any())
       ->method('getCacheTags')
-      ->will($this->returnValue(['node:20011988']));
+      ->willReturn(['node:20011988']);
     $node->expects($this->any())
       ->method('getCacheMaxAge')
       ->willReturn(600);
diff --git a/core/tests/Drupal/Tests/Core/Access/CsrfAccessCheckTest.php b/core/tests/Drupal/Tests/Core/Access/CsrfAccessCheckTest.php
index 470b7f16a5dced84191c0ba612d21000032be1ac..73628aa50bb1a00372a017a16c6000dacc66cb55 100644
--- a/core/tests/Drupal/Tests/Core/Access/CsrfAccessCheckTest.php
+++ b/core/tests/Drupal/Tests/Core/Access/CsrfAccessCheckTest.php
@@ -55,11 +55,11 @@ public function testAccessTokenPass() {
     $this->csrfToken->expects($this->once())
       ->method('validate')
       ->with('test_query', 'test-path/42')
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
 
     $this->routeMatch->expects($this->once())
       ->method('getRawParameters')
-      ->will($this->returnValue(['node' => 42]));
+      ->willReturn(['node' => 42]);
 
     $route = new Route('/test-path/{node}', [], ['_csrf_token' => 'TRUE']);
     $request = Request::create('/test-path/42?token=test_query');
@@ -74,11 +74,11 @@ public function testCsrfTokenInvalid() {
     $this->csrfToken->expects($this->once())
       ->method('validate')
       ->with('test_query', 'test-path')
-      ->will($this->returnValue(FALSE));
+      ->willReturn(FALSE);
 
     $this->routeMatch->expects($this->once())
       ->method('getRawParameters')
-      ->will($this->returnValue([]));
+      ->willReturn([]);
 
     $route = new Route('/test-path', [], ['_csrf_token' => 'TRUE']);
     $request = Request::create('/test-path?token=test_query');
@@ -93,11 +93,11 @@ public function testCsrfTokenMissing() {
     $this->csrfToken->expects($this->once())
       ->method('validate')
       ->with('', 'test-path')
-      ->will($this->returnValue(FALSE));
+      ->willReturn(FALSE);
 
     $this->routeMatch->expects($this->once())
       ->method('getRawParameters')
-      ->will($this->returnValue([]));
+      ->willReturn([]);
 
     $route = new Route('/test-path', [], ['_csrf_token' => 'TRUE']);
     $request = Request::create('/test-path');
diff --git a/core/tests/Drupal/Tests/Core/Access/CsrfTokenGeneratorTest.php b/core/tests/Drupal/Tests/Core/Access/CsrfTokenGeneratorTest.php
index 8db48fe84ffa66196484e5fe3dadfa7f39b08d11..118e5c0413918cb42acd258ae1ca2fb0fe6995e8 100644
--- a/core/tests/Drupal/Tests/Core/Access/CsrfTokenGeneratorTest.php
+++ b/core/tests/Drupal/Tests/Core/Access/CsrfTokenGeneratorTest.php
@@ -67,12 +67,12 @@ protected function setupDefaultExpectations() {
     $key = Crypt::randomBytesBase64();
     $this->privateKey->expects($this->any())
       ->method('get')
-      ->will($this->returnValue($key));
+      ->willReturn($key);
 
     $seed = Crypt::randomBytesBase64();
     $this->sessionMetadata->expects($this->any())
       ->method('getCsrfTokenSeed')
-      ->will($this->returnValue($seed));
+      ->willReturn($seed);
   }
 
   /**
@@ -97,11 +97,11 @@ public function testGenerateSeedOnGet() {
     $key = Crypt::randomBytesBase64();
     $this->privateKey->expects($this->any())
       ->method('get')
-      ->will($this->returnValue($key));
+      ->willReturn($key);
 
     $this->sessionMetadata->expects($this->once())
       ->method('getCsrfTokenSeed')
-      ->will($this->returnValue(NULL));
+      ->willReturn(NULL);
 
     $this->sessionMetadata->expects($this->once())
       ->method('setCsrfTokenSeed')
diff --git a/core/tests/Drupal/Tests/Core/Access/CustomAccessCheckTest.php b/core/tests/Drupal/Tests/Core/Access/CustomAccessCheckTest.php
index 33509635e6425831cb5122b3950e33c3ce6c465e..1218df686cc635b3546899ebc654c0d0223246a9 100644
--- a/core/tests/Drupal/Tests/Core/Access/CustomAccessCheckTest.php
+++ b/core/tests/Drupal/Tests/Core/Access/CustomAccessCheckTest.php
@@ -72,15 +72,15 @@ public function testAccess() {
     $resolver0 = $this->createMock('Drupal\Component\Utility\ArgumentsResolverInterface');
     $resolver0->expects($this->once())
       ->method('getArguments')
-      ->will($this->returnValue([]));
+      ->willReturn([]);
     $resolver1 = $this->createMock('Drupal\Component\Utility\ArgumentsResolverInterface');
     $resolver1->expects($this->once())
       ->method('getArguments')
-      ->will($this->returnValue([]));
+      ->willReturn([]);
     $resolver2 = $this->createMock('Drupal\Component\Utility\ArgumentsResolverInterface');
     $resolver2->expects($this->once())
       ->method('getArguments')
-      ->will($this->returnValue(['parameter' => 'TRUE']));
+      ->willReturn(['parameter' => 'TRUE']);
 
     $this->argumentsResolverFactory->expects($this->exactly(3))
       ->method('getArgumentsResolver')
diff --git a/core/tests/Drupal/Tests/Core/Ajax/AjaxResponseTest.php b/core/tests/Drupal/Tests/Core/Ajax/AjaxResponseTest.php
index 52de1390a626cb665fda2b5237f89a3224df221f..835e53daa2e164d8b63fe83f6cd60b70a2b00b81 100644
--- a/core/tests/Drupal/Tests/Core/Ajax/AjaxResponseTest.php
+++ b/core/tests/Drupal/Tests/Core/Ajax/AjaxResponseTest.php
@@ -39,15 +39,15 @@ public function testCommands() {
     $command_one = $this->createMock('Drupal\Core\Ajax\CommandInterface');
     $command_one->expects($this->once())
       ->method('render')
-      ->will($this->returnValue(['command' => 'one']));
+      ->willReturn(['command' => 'one']);
     $command_two = $this->createMock('Drupal\Core\Ajax\CommandInterface');
     $command_two->expects($this->once())
       ->method('render')
-      ->will($this->returnValue(['command' => 'two']));
+      ->willReturn(['command' => 'two']);
     $command_three = $this->createMock('Drupal\Core\Ajax\CommandInterface');
     $command_three->expects($this->once())
       ->method('render')
-      ->will($this->returnValue(['command' => 'three']));
+      ->willReturn(['command' => 'three']);
 
     $this->ajaxResponse->addCommand($command_one);
     $this->ajaxResponse->addCommand($command_two);
diff --git a/core/tests/Drupal/Tests/Core/Asset/LibraryDependencyResolverTest.php b/core/tests/Drupal/Tests/Core/Asset/LibraryDependencyResolverTest.php
index f9c7ae651d9d50f89ab96e74aaa58edbe69f02ce..f380e385fcf9f5c7aa618258a5f5755dc098e00d 100644
--- a/core/tests/Drupal/Tests/Core/Asset/LibraryDependencyResolverTest.php
+++ b/core/tests/Drupal/Tests/Core/Asset/LibraryDependencyResolverTest.php
@@ -60,7 +60,7 @@ protected function setUp(): void {
     $this->libraryDiscovery->expects($this->any())
       ->method('getLibrariesByExtension')
       ->with('test')
-      ->will($this->returnValue($this->libraryData));
+      ->willReturn($this->libraryData);
     $this->libraryDependencyResolver = new LibraryDependencyResolver($this->libraryDiscovery);
   }
 
diff --git a/core/tests/Drupal/Tests/Core/Asset/LibraryDiscoveryCollectorTest.php b/core/tests/Drupal/Tests/Core/Asset/LibraryDiscoveryCollectorTest.php
index b2d369846518293196be72c9b53ad70de2b3d029..70c22d868196782b138b37321f3bd8ed55447393 100644
--- a/core/tests/Drupal/Tests/Core/Asset/LibraryDiscoveryCollectorTest.php
+++ b/core/tests/Drupal/Tests/Core/Asset/LibraryDiscoveryCollectorTest.php
@@ -150,7 +150,7 @@ public function testDestruct() {
     $this->lock->expects($this->once())
       ->method('acquire')
       ->with($lock_key)
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
     $this->cache->expects($this->exactly(2))
       ->method('get')
       ->with('library_info:kitten_theme')
diff --git a/core/tests/Drupal/Tests/Core/Asset/LibraryDiscoveryParserTest.php b/core/tests/Drupal/Tests/Core/Asset/LibraryDiscoveryParserTest.php
index e355bc053d23b87f4d462d13e254c64271bd5631..e21bf5f47295c136e67e929f18bdfacc3e003e6f 100644
--- a/core/tests/Drupal/Tests/Core/Asset/LibraryDiscoveryParserTest.php
+++ b/core/tests/Drupal/Tests/Core/Asset/LibraryDiscoveryParserTest.php
@@ -119,7 +119,7 @@ public function testBuildByExtensionSimple() {
     $this->moduleHandler->expects($this->atLeastOnce())
       ->method('moduleExists')
       ->with('example_module')
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
 
     $path = __DIR__ . '/library_test_files';
     $path = substr($path, strlen($this->root) + 1);
@@ -149,7 +149,7 @@ public function testBuildByExtensionWithTheme() {
     $this->moduleHandler->expects($this->atLeastOnce())
       ->method('moduleExists')
       ->with('example_theme')
-      ->will($this->returnValue(FALSE));
+      ->willReturn(FALSE);
 
     $path = __DIR__ . '/library_test_files';
     $path = substr($path, strlen($this->root) + 1);
@@ -176,7 +176,7 @@ public function testBuildByExtensionWithMissingLibraryFile() {
     $this->moduleHandler->expects($this->atLeastOnce())
       ->method('moduleExists')
       ->with('example_module')
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
 
     $path = __DIR__ . '/library_test_files_not_existing';
     $path = substr($path, strlen($this->root) + 1);
@@ -197,7 +197,7 @@ public function testInvalidLibrariesFile() {
     $this->moduleHandler->expects($this->atLeastOnce())
       ->method('moduleExists')
       ->with('invalid_file')
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
 
     $path = __DIR__ . '/library_test_files';
     $path = substr($path, strlen($this->root) + 1);
@@ -219,7 +219,7 @@ public function testBuildByExtensionWithOnlyDependencies() {
     $this->moduleHandler->expects($this->atLeastOnce())
       ->method('moduleExists')
       ->with('example_module_only_dependencies')
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
 
     $path = __DIR__ . '/library_test_files';
     $path = substr($path, strlen($this->root) + 1);
@@ -241,7 +241,7 @@ public function testBuildByExtensionWithMissingInformation() {
     $this->moduleHandler->expects($this->atLeastOnce())
       ->method('moduleExists')
       ->with('example_module_missing_information')
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
 
     $path = __DIR__ . '/library_test_files';
     $path = substr($path, strlen($this->root) + 1);
@@ -264,7 +264,7 @@ public function testVersion() {
     $this->moduleHandler->expects($this->atLeastOnce())
       ->method('moduleExists')
       ->with('versions')
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
 
     $path = __DIR__ . '/library_test_files';
     $path = substr($path, strlen($this->root) + 1);
@@ -297,7 +297,7 @@ public function testExternalLibraries() {
     $this->moduleHandler->expects($this->atLeastOnce())
       ->method('moduleExists')
       ->with('external')
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
 
     $path = __DIR__ . '/library_test_files';
     $path = substr($path, strlen($this->root) + 1);
@@ -323,7 +323,7 @@ public function testDefaultCssWeights() {
     $this->moduleHandler->expects($this->atLeastOnce())
       ->method('moduleExists')
       ->with('css_weights')
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
 
     $path = __DIR__ . '/library_test_files';
     $path = substr($path, strlen($this->root) + 1);
@@ -364,7 +364,7 @@ public function testJsWithPositiveWeight() {
     $this->moduleHandler->expects($this->atLeastOnce())
       ->method('moduleExists')
       ->with('js_positive_weight')
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
 
     $path = __DIR__ . '/library_test_files';
     $path = substr($path, strlen($this->root) + 1);
@@ -386,7 +386,7 @@ public function testLibraryWithCssJsSetting() {
     $this->moduleHandler->expects($this->atLeastOnce())
       ->method('moduleExists')
       ->with('css_js_settings')
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
 
     $path = __DIR__ . '/library_test_files';
     $path = substr($path, strlen($this->root) + 1);
@@ -419,7 +419,7 @@ public function testLibraryWithDependencies() {
     $this->moduleHandler->expects($this->atLeastOnce())
       ->method('moduleExists')
       ->with('dependencies')
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
 
     $path = __DIR__ . '/library_test_files';
     $path = substr($path, strlen($this->root) + 1);
@@ -445,10 +445,10 @@ public function testLibraryWithDataTypes() {
     $this->moduleHandler->expects($this->atLeastOnce())
       ->method('moduleExists')
       ->with('data_types')
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
     $this->streamWrapperManager->expects($this->atLeastOnce())
       ->method('isValidUri')
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
 
     $path = __DIR__ . '/library_test_files';
     $path = substr($path, strlen($this->root) + 1);
@@ -483,7 +483,7 @@ public function testLibraryWithJavaScript() {
     $this->moduleHandler->expects($this->atLeastOnce())
       ->method('moduleExists')
       ->with('js')
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
 
     $path = __DIR__ . '/library_test_files';
     $path = substr($path, strlen($this->root) + 1);
@@ -509,7 +509,7 @@ public function testLibraryThirdPartyWithMissingLicense() {
     $this->moduleHandler->expects($this->atLeastOnce())
       ->method('moduleExists')
       ->with('licenses_missing_information')
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
 
     $path = __DIR__ . '/library_test_files';
     $path = substr($path, strlen($this->root) + 1);
@@ -532,7 +532,7 @@ public function testLibraryWithLicenses() {
     $this->moduleHandler->expects($this->atLeastOnce())
       ->method('moduleExists')
       ->with('licenses')
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
 
     $path = __DIR__ . '/library_test_files';
     $path = substr($path, strlen($this->root) + 1);
@@ -651,7 +651,7 @@ public function testLibraryOverride() {
     $this->moduleHandler->expects($this->atLeastOnce())
       ->method('moduleExists')
       ->with('example_module')
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
 
     $libraries = $this->libraryDiscoveryParser->buildByExtension('example_module');
     $library = $libraries['example'];
@@ -704,7 +704,7 @@ public function testLibraryOverrideDeprecated() {
     $this->moduleHandler->expects($this->atLeastOnce())
       ->method('moduleExists')
       ->with('deprecated')
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
 
     $this->libraryDiscoveryParser->buildByExtension('deprecated');
   }
@@ -729,7 +729,7 @@ public function testCssAssert($extension, $exception_message) {
     $this->moduleHandler->expects($this->atLeastOnce())
       ->method('moduleExists')
       ->with($extension)
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
 
     $path = __DIR__ . '/library_test_files';
     $path = substr($path, strlen($this->root) + 1);
@@ -761,7 +761,7 @@ public function testNonCoreLibrariesFound() {
     $this->moduleHandler->expects($this->atLeastOnce())
       ->method('moduleExists')
       ->with('example_contrib_module')
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
 
     $path = __DIR__ . '/library_test_files';
     $path = substr($path, strlen($this->root) + 1);
@@ -773,7 +773,7 @@ public function testNonCoreLibrariesFound() {
     $this->librariesDirectoryFileFinder->expects($this->once())
       ->method('find')
       ->with('third_party_library/css/example.css')
-      ->will($this->returnValue('sites/example.com/libraries/third_party_library/css/example.css'));
+      ->willReturn('sites/example.com/libraries/third_party_library/css/example.css');
 
     $libraries = $this->libraryDiscoveryParser->buildByExtension('example_contrib_module');
     $library = $libraries['third_party_library'];
@@ -792,7 +792,7 @@ public function testNonCoreLibrariesNotFound() {
     $this->moduleHandler->expects($this->atLeastOnce())
       ->method('moduleExists')
       ->with('example_contrib_module')
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
 
     $path = __DIR__ . '/library_test_files';
     $path = substr($path, strlen($this->root) + 1);
@@ -807,7 +807,7 @@ public function testNonCoreLibrariesNotFound() {
     $this->librariesDirectoryFileFinder->expects($this->once())
       ->method('find')
       ->with('third_party_library/css/example.css')
-      ->will($this->returnValue(FALSE));
+      ->willReturn(FALSE);
 
     $libraries = $this->libraryDiscoveryParser->buildByExtension('example_contrib_module');
     $library = $libraries['third_party_library'];
@@ -827,7 +827,7 @@ public function testEmptyLibraryFile() {
     $this->moduleHandler->expects($this->atLeastOnce())
       ->method('moduleExists')
       ->with('empty')
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
 
     $path = __DIR__ . '/library_test_files';
     $path = substr($path, strlen($this->root) + 1);
diff --git a/core/tests/Drupal/Tests/Core/Breadcrumb/BreadcrumbManagerTest.php b/core/tests/Drupal/Tests/Core/Breadcrumb/BreadcrumbManagerTest.php
index 234434f54c64255ba657c4eabae26cc9e127b109..b0e600c0b419b12e8999fa6836e4da1393bbd520 100644
--- a/core/tests/Drupal/Tests/Core/Breadcrumb/BreadcrumbManagerTest.php
+++ b/core/tests/Drupal/Tests/Core/Breadcrumb/BreadcrumbManagerTest.php
@@ -86,7 +86,7 @@ public function testBuildWithSingleBuilder() {
 
     $builder->expects($this->once())
       ->method('applies')
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
 
     $builder->expects($this->once())
       ->method('build')
@@ -122,7 +122,7 @@ public function testBuildWithMultipleApplyingBuilders() {
     $this->breadcrumb->addCacheContexts(['baz'])->addCacheTags(['qux']);
     $builder2->expects($this->once())
       ->method('applies')
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
     $builder2->expects($this->once())
       ->method('build')
       ->willReturn($this->breadcrumb);
@@ -150,7 +150,7 @@ public function testBuildWithOneNotApplyingBuilders() {
     $builder1 = $this->createMock('Drupal\Core\Breadcrumb\BreadcrumbBuilderInterface');
     $builder1->expects($this->once())
       ->method('applies')
-      ->will($this->returnValue(FALSE));
+      ->willReturn(FALSE);
     $builder1->expects($this->never())
       ->method('build');
 
@@ -160,7 +160,7 @@ public function testBuildWithOneNotApplyingBuilders() {
     $this->breadcrumb->addCacheContexts(['baz'])->addCacheTags(['qux']);
     $builder2->expects($this->once())
       ->method('applies')
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
     $builder2->expects($this->once())
       ->method('build')
       ->willReturn($this->breadcrumb);
@@ -188,10 +188,10 @@ public function testBuildWithInvalidBreadcrumbResult() {
     $builder = $this->createMock('Drupal\Core\Breadcrumb\BreadcrumbBuilderInterface');
     $builder->expects($this->once())
       ->method('applies')
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
     $builder->expects($this->once())
       ->method('build')
-      ->will($this->returnValue('invalid_result'));
+      ->willReturn('invalid_result');
 
     $this->breadcrumbManager->addBuilder($builder, 0);
     $this->expectException(\UnexpectedValueException::class);
diff --git a/core/tests/Drupal/Tests/Core/Cache/CacheCollectorTest.php b/core/tests/Drupal/Tests/Core/Cache/CacheCollectorTest.php
index 2c7c041a6d9a3024a2cf517ed5d8eea51be6aa1d..4debf2836a019a26d623f743b1170897431f0e31 100644
--- a/core/tests/Drupal/Tests/Core/Cache/CacheCollectorTest.php
+++ b/core/tests/Drupal/Tests/Core/Cache/CacheCollectorTest.php
@@ -119,7 +119,7 @@ public function testGetFromCache() {
     $this->cacheBackend->expects($this->once())
       ->method('get')
       ->with($this->cid)
-      ->will($this->returnValue($cache));
+      ->willReturn($cache);
     $this->assertTrue($this->collector->has($key));
     $this->assertEquals($value, $this->collector->get($key));
     $this->assertEquals(0, $this->collector->getCacheMisses());
@@ -175,7 +175,7 @@ public function testUpdateCache() {
     $this->lock->expects($this->once())
       ->method('acquire')
       ->with($this->cid . ':Drupal\Core\Cache\CacheCollector')
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
     $this->cacheBackend->expects($this->once())
       ->method('get')
       ->with($this->cid, FALSE);
@@ -204,7 +204,7 @@ public function testUpdateCacheLockFail() {
     $this->lock->expects($this->once())
       ->method('acquire')
       ->with($this->cid . ':Drupal\Core\Cache\CacheCollector')
-      ->will($this->returnValue(FALSE));
+      ->willReturn(FALSE);
     $this->cacheBackend->expects($this->never())
       ->method('set');
 
@@ -244,7 +244,7 @@ public function testUpdateCacheInvalidatedConflict() {
     $this->lock->expects($this->once())
       ->method('acquire')
       ->with($this->cid . ':Drupal\Core\Cache\CacheCollector')
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
     $this->cacheBackend->expects($this->once())
       ->method('delete')
       ->with($this->cid);
@@ -272,7 +272,7 @@ public function testUpdateCacheMerge() {
     $this->lock->expects($this->once())
       ->method('acquire')
       ->with($this->cid . ':Drupal\Core\Cache\CacheCollector')
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
     $cache = (object) [
       'data' => ['other key' => 'other value'],
       'created' => (int) $_SERVER['REQUEST_TIME'] + 1,
@@ -280,7 +280,7 @@ public function testUpdateCacheMerge() {
     $this->cacheBackend->expects($this->once())
       ->method('get')
       ->with($this->cid)
-      ->will($this->returnValue($cache));
+      ->willReturn($cache);
     $this->cacheBackend->expects($this->once())
       ->method('set')
       ->with($this->cid, ['other key' => 'other value', $key => $value], Cache::PERMANENT, []);
@@ -311,7 +311,7 @@ public function testUpdateCacheDelete() {
         [$this->cid],
         [$this->cid, TRUE],
       )
-      ->will($this->returnValue($cache));
+      ->willReturn($cache);
 
     $this->collector->delete($key);
 
@@ -320,7 +320,7 @@ public function testUpdateCacheDelete() {
     $this->lock->expects($this->once())
       ->method('acquire')
       ->with($this->cid . ':Drupal\Core\Cache\CacheCollector')
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
     $this->cacheBackend->expects($this->once())
       ->method('set')
       ->with($this->cid, [], Cache::PERMANENT, []);
diff --git a/core/tests/Drupal/Tests/Core/Cache/CacheFactoryTest.php b/core/tests/Drupal/Tests/Core/Cache/CacheFactoryTest.php
index 2876d7177b3628314ebd71fa4b4dad171a056994..c67dc843dd589dd2edab9b0250149650ba9e940b 100644
--- a/core/tests/Drupal/Tests/Core/Cache/CacheFactoryTest.php
+++ b/core/tests/Drupal/Tests/Core/Cache/CacheFactoryTest.php
@@ -33,7 +33,7 @@ public function testCacheFactoryWithDefaultSettings() {
     $builtin_default_backend_factory->expects($this->once())
       ->method('get')
       ->with('render')
-      ->will($this->returnValue($render_bin));
+      ->willReturn($render_bin);
 
     $actual_bin = $cache_factory->get('render');
     $this->assertSame($render_bin, $actual_bin);
@@ -63,7 +63,7 @@ public function testCacheFactoryWithCustomizedDefaultBackend() {
     $custom_default_backend_factory->expects($this->once())
       ->method('get')
       ->with('render')
-      ->will($this->returnValue($render_bin));
+      ->willReturn($render_bin);
 
     $actual_bin = $cache_factory->get('render');
     $this->assertSame($render_bin, $actual_bin);
@@ -99,7 +99,7 @@ public function testCacheFactoryWithDefaultBinBackend() {
     $custom_default_backend_factory->expects($this->once())
       ->method('get')
       ->with('render')
-      ->will($this->returnValue($render_bin));
+      ->willReturn($render_bin);
 
     $actual_bin = $cache_factory->get('render');
     $this->assertSame($render_bin, $actual_bin);
@@ -139,7 +139,7 @@ public function testCacheFactoryWithSpecifiedPerBinBackend() {
     $custom_render_backend_factory->expects($this->once())
       ->method('get')
       ->with('render')
-      ->will($this->returnValue($render_bin));
+      ->willReturn($render_bin);
 
     $actual_bin = $cache_factory->get('render');
     $this->assertSame($render_bin, $actual_bin);
diff --git a/core/tests/Drupal/Tests/Core/Cache/ChainedFastBackendTest.php b/core/tests/Drupal/Tests/Core/Cache/ChainedFastBackendTest.php
index 8f203b0f165905e9940e8e69abd7633ac541162c..ac5fb40a3b9e631ec618a04840d8f2758ca997fc 100644
--- a/core/tests/Drupal/Tests/Core/Cache/ChainedFastBackendTest.php
+++ b/core/tests/Drupal/Tests/Core/Cache/ChainedFastBackendTest.php
@@ -43,7 +43,7 @@ public function testGetDoesNotHitConsistentBackend() {
     $timestamp_item = (object) ['cid' => $timestamp_cid, 'data' => (int) $_SERVER['REQUEST_TIME'] - 60];
     $consistent_cache->expects($this->once())
       ->method('get')->with($timestamp_cid)
-      ->will($this->returnValue($timestamp_item));
+      ->willReturn($timestamp_item);
     $consistent_cache->expects($this->never())
       ->method('getMultiple');
 
@@ -82,19 +82,19 @@ public function testFallThroughToConsistentCache() {
     $consistent_cache->expects($this->once())
       ->method('get')
       ->with($timestamp_item->cid)
-      ->will($this->returnValue($timestamp_item));
+      ->willReturn($timestamp_item);
 
     // We should get a call for the cache item on the consistent backend.
     $consistent_cache->expects($this->once())
       ->method('getMultiple')
       ->with([$cache_item->cid])
-      ->will($this->returnValue([$cache_item->cid => $cache_item]));
+      ->willReturn([$cache_item->cid => $cache_item]);
 
     // We should get a call for the cache item on the fast backend.
     $fast_cache->expects($this->once())
       ->method('getMultiple')
       ->with([$cache_item->cid])
-      ->will($this->returnValue([$cache_item->cid => $cache_item]));
+      ->willReturn([$cache_item->cid => $cache_item]);
 
     // We should get a call to set the cache item on the fast backend.
     $fast_cache->expects($this->once())
diff --git a/core/tests/Drupal/Tests/Core/Cache/Context/SessionCacheContextTest.php b/core/tests/Drupal/Tests/Core/Cache/Context/SessionCacheContextTest.php
index 9be59d1c305438d7b2dbe92c9d2b083173aa7fbb..50219f31d2f85b545a95295ba74c9cb2e12c684f 100644
--- a/core/tests/Drupal/Tests/Core/Cache/Context/SessionCacheContextTest.php
+++ b/core/tests/Drupal/Tests/Core/Cache/Context/SessionCacheContextTest.php
@@ -57,7 +57,7 @@ public function testSameContextForSameSession() {
     $session_id = 'aSebeZ52bbM6SvADurQP89SFnEpxY6j8';
     $this->session->expects($this->exactly(2))
       ->method('getId')
-      ->will($this->returnValue($session_id));
+      ->willReturn($session_id);
 
     $context1 = $cache_context->getContext();
     $context2 = $cache_context->getContext();
diff --git a/core/tests/Drupal/Tests/Core/Condition/ConditionAccessResolverTraitTest.php b/core/tests/Drupal/Tests/Core/Condition/ConditionAccessResolverTraitTest.php
index 825b74b61e0ebda50c02f58a8e4818172257aff3..053d30fa6f02a44594e4cbc0729afd325a864c59 100644
--- a/core/tests/Drupal/Tests/Core/Condition/ConditionAccessResolverTraitTest.php
+++ b/core/tests/Drupal/Tests/Core/Condition/ConditionAccessResolverTraitTest.php
@@ -34,25 +34,25 @@ public function providerTestResolveConditions() {
     $condition_true = $this->createMock('Drupal\Core\Condition\ConditionInterface');
     $condition_true->expects($this->any())
       ->method('execute')
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
     $condition_false = $this->createMock('Drupal\Core\Condition\ConditionInterface');
     $condition_false->expects($this->any())
       ->method('execute')
-      ->will($this->returnValue(FALSE));
+      ->willReturn(FALSE);
     $condition_exception = $this->createMock('Drupal\Core\Condition\ConditionInterface');
     $condition_exception->expects($this->any())
       ->method('execute')
       ->will($this->throwException(new ContextException()));
     $condition_exception->expects($this->atLeastOnce())
       ->method('isNegated')
-      ->will($this->returnValue(FALSE));
+      ->willReturn(FALSE);
     $condition_negated = $this->createMock('Drupal\Core\Condition\ConditionInterface');
     $condition_negated->expects($this->any())
       ->method('execute')
       ->will($this->throwException(new ContextException()));
     $condition_negated->expects($this->atLeastOnce())
       ->method('isNegated')
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
 
     $conditions = [];
     $data[] = [$conditions, 'and', TRUE];
diff --git a/core/tests/Drupal/Tests/Core/Config/CachedStorageTest.php b/core/tests/Drupal/Tests/Core/Config/CachedStorageTest.php
index 8c1b18dbcef560867482f21530fad8d8b5dc6ef3..a33c05187e56a26e36e9548efd0093b828fa4ac6 100644
--- a/core/tests/Drupal/Tests/Core/Config/CachedStorageTest.php
+++ b/core/tests/Drupal/Tests/Core/Config/CachedStorageTest.php
@@ -29,7 +29,7 @@ public function testListAllStaticCache() {
     $storage->expects($this->once())
       ->method('listAll')
       ->with($prefix)
-      ->will($this->returnValue($response));
+      ->willReturn($response);
 
     $cache = new NullBackend(__FUNCTION__);
 
diff --git a/core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityBaseUnitTest.php b/core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityBaseUnitTest.php
index b54150a0a98cca74828b51ab660317378d6e341e..dcb0e2b313522957393f7b6b0b5cb8ebcd28dce9 100644
--- a/core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityBaseUnitTest.php
+++ b/core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityBaseUnitTest.php
@@ -124,7 +124,7 @@ protected function setUp(): void {
     $this->entityType = $this->createMock('\Drupal\Core\Config\Entity\ConfigEntityTypeInterface');
     $this->entityType->expects($this->any())
       ->method('getProvider')
-      ->will($this->returnValue($this->provider));
+      ->willReturn($this->provider);
     $this->entityType->expects($this->any())
       ->method('getConfigPrefix')
       ->willReturn('test_provider.' . $this->entityTypeId);
@@ -133,7 +133,7 @@ protected function setUp(): void {
     $this->entityTypeManager->expects($this->any())
       ->method('getDefinition')
       ->with($this->entityTypeId)
-      ->will($this->returnValue($this->entityType));
+      ->willReturn($this->entityType);
 
     $this->uuid = $this->createMock('\Drupal\Component\Uuid\UuidInterface');
 
@@ -141,7 +141,7 @@ protected function setUp(): void {
     $this->languageManager->expects($this->any())
       ->method('getLanguage')
       ->with('en')
-      ->will($this->returnValue(new Language(['id' => 'en'])));
+      ->willReturn(new Language(['id' => 'en']));
 
     $this->cacheTagsInvalidator = $this->createMock('Drupal\Core\Cache\CacheTagsInvalidatorInterface');
 
@@ -191,16 +191,16 @@ public function testPreSaveDuringSync() {
 
     $query->expects($this->any())
       ->method('execute')
-      ->will($this->returnValue([]));
+      ->willReturn([]);
     $query->expects($this->any())
       ->method('condition')
-      ->will($this->returnValue($query));
+      ->willReturn($query);
     $storage->expects($this->any())
       ->method('getQuery')
-      ->will($this->returnValue($query));
+      ->willReturn($query);
     $storage->expects($this->any())
       ->method('loadUnchanged')
-      ->will($this->returnValue($this->entity));
+      ->willReturn($this->entity);
 
     // Saving an entity will not reset the dependencies array during config
     // synchronization.
@@ -271,13 +271,13 @@ public function testCalculateDependenciesWithPluginCollections($definition, $exp
     $pluginCollection->expects($this->atLeastOnce())
       ->method('get')
       ->with($instance_id)
-      ->will($this->returnValue($instance));
+      ->willReturn($instance);
     $pluginCollection->addInstanceId($instance_id);
 
     // Return the mocked plugin collection.
     $this->entity->expects($this->once())
       ->method('getPluginCollections')
-      ->will($this->returnValue([$pluginCollection]));
+      ->willReturn([$pluginCollection]);
 
     $this->assertEquals($expected_dependencies, $this->entity->calculateDependencies()->getDependencies());
   }
@@ -486,12 +486,12 @@ public function testCreateDuplicate() {
     $this->entityType->expects($this->once())
       ->method('hasKey')
       ->with('uuid')
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
 
     $new_uuid = '8607ef21-42bc-4913-978f-8c06207b0395';
     $this->uuid->expects($this->once())
       ->method('generate')
-      ->will($this->returnValue($new_uuid));
+      ->willReturn($new_uuid);
 
     $duplicate = $this->entity->createDuplicate();
     $this->assertInstanceOf('\Drupal\Core\Entity\EntityBase', $duplicate);
@@ -511,11 +511,11 @@ public function testSort() {
     $this->entityTypeManager->expects($this->any())
       ->method('getDefinition')
       ->with($this->entityTypeId)
-      ->will($this->returnValue([
+      ->willReturn([
         'entity_keys' => [
           'label' => 'label',
         ],
-      ]));
+      ]);
 
     $entity_a = $this->createMock('\Drupal\Core\Config\Entity\ConfigEntityInterface');
     $entity_a->expects($this->atLeastOnce())
diff --git a/core/tests/Drupal/Tests/Core/Config/Entity/EntityDisplayModeBaseUnitTest.php b/core/tests/Drupal/Tests/Core/Config/Entity/EntityDisplayModeBaseUnitTest.php
index 03ec70375ad2f8f458e070887328c76ff7dc7df2..0d411f915692466af28f53e01db534fd4e8924eb 100644
--- a/core/tests/Drupal/Tests/Core/Config/Entity/EntityDisplayModeBaseUnitTest.php
+++ b/core/tests/Drupal/Tests/Core/Config/Entity/EntityDisplayModeBaseUnitTest.php
@@ -56,7 +56,7 @@ protected function setUp(): void {
     $this->entityInfo = $this->createMock('\Drupal\Core\Entity\EntityTypeInterface');
     $this->entityInfo->expects($this->any())
       ->method('getProvider')
-      ->will($this->returnValue('entity'));
+      ->willReturn('entity');
 
     $this->entityTypeManager = $this->createMock(EntityTypeManagerInterface::class);
 
@@ -78,7 +78,7 @@ public function testCalculateDependencies() {
     $target_entity_type = $this->createMock('\Drupal\Core\Entity\EntityTypeInterface');
     $target_entity_type->expects($this->any())
       ->method('getProvider')
-      ->will($this->returnValue('test_module'));
+      ->willReturn('test_module');
     $values = ['targetEntityType' => $target_entity_type_id];
 
     $this->entityTypeManager->expects($this->exactly(2))
diff --git a/core/tests/Drupal/Tests/Core/Config/StorageComparerTest.php b/core/tests/Drupal/Tests/Core/Config/StorageComparerTest.php
index a53d75009a75cfd8b7c9966524ea34caf9c9073a..6d85e64e3743b87d815dd87b2b09fe15c06a0f44 100644
--- a/core/tests/Drupal/Tests/Core/Config/StorageComparerTest.php
+++ b/core/tests/Drupal/Tests/Core/Config/StorageComparerTest.php
@@ -101,22 +101,22 @@ public function testCreateChangelistNoChange() {
     $config_files = array_keys($config_data);
     $this->sourceStorage->expects($this->once())
       ->method('listAll')
-      ->will($this->returnValue($config_files));
+      ->willReturn($config_files);
     $this->targetStorage->expects($this->once())
       ->method('listAll')
-      ->will($this->returnValue($config_files));
+      ->willReturn($config_files);
     $this->sourceStorage->expects($this->once())
       ->method('readMultiple')
-      ->will($this->returnValue($config_data));
+      ->willReturn($config_data);
     $this->targetStorage->expects($this->once())
       ->method('readMultiple')
-      ->will($this->returnValue($config_data));
+      ->willReturn($config_data);
     $this->sourceStorage->expects($this->once())
       ->method('getAllCollectionNames')
-      ->will($this->returnValue([]));
+      ->willReturn([]);
     $this->targetStorage->expects($this->once())
       ->method('getAllCollectionNames')
-      ->will($this->returnValue([]));
+      ->willReturn([]);
 
     $this->storageComparer->createChangelist();
     $this->assertEmpty($this->storageComparer->getChangelist('create'));
@@ -135,22 +135,22 @@ public function testCreateChangelistCreate() {
 
     $this->sourceStorage->expects($this->once())
       ->method('listAll')
-      ->will($this->returnValue(array_keys($source_data)));
+      ->willReturn(array_keys($source_data));
     $this->targetStorage->expects($this->once())
       ->method('listAll')
-      ->will($this->returnValue(array_keys($target_data)));
+      ->willReturn(array_keys($target_data));
     $this->sourceStorage->expects($this->once())
       ->method('readMultiple')
-      ->will($this->returnValue($source_data));
+      ->willReturn($source_data);
     $this->targetStorage->expects($this->once())
       ->method('readMultiple')
-      ->will($this->returnValue($target_data));
+      ->willReturn($target_data);
     $this->sourceStorage->expects($this->once())
       ->method('getAllCollectionNames')
-      ->will($this->returnValue([]));
+      ->willReturn([]);
     $this->targetStorage->expects($this->once())
       ->method('getAllCollectionNames')
-      ->will($this->returnValue([]));
+      ->willReturn([]);
 
     $this->storageComparer->createChangelist();
     $expected = [
@@ -174,22 +174,22 @@ public function testCreateChangelistDelete() {
 
     $this->sourceStorage->expects($this->once())
       ->method('listAll')
-      ->will($this->returnValue(array_keys($source_data)));
+      ->willReturn(array_keys($source_data));
     $this->targetStorage->expects($this->once())
       ->method('listAll')
-      ->will($this->returnValue(array_keys($target_data)));
+      ->willReturn(array_keys($target_data));
     $this->sourceStorage->expects($this->once())
       ->method('readMultiple')
-      ->will($this->returnValue($source_data));
+      ->willReturn($source_data);
     $this->targetStorage->expects($this->once())
       ->method('readMultiple')
-      ->will($this->returnValue($target_data));
+      ->willReturn($target_data);
     $this->sourceStorage->expects($this->once())
       ->method('getAllCollectionNames')
-      ->will($this->returnValue([]));
+      ->willReturn([]);
     $this->targetStorage->expects($this->once())
       ->method('getAllCollectionNames')
-      ->will($this->returnValue([]));
+      ->willReturn([]);
 
     $this->storageComparer->createChangelist();
     $expected = [
@@ -213,22 +213,22 @@ public function testCreateChangelistUpdate() {
 
     $this->sourceStorage->expects($this->once())
       ->method('listAll')
-      ->will($this->returnValue(array_keys($source_data)));
+      ->willReturn(array_keys($source_data));
     $this->targetStorage->expects($this->once())
       ->method('listAll')
-      ->will($this->returnValue(array_keys($target_data)));
+      ->willReturn(array_keys($target_data));
     $this->sourceStorage->expects($this->once())
       ->method('readMultiple')
-      ->will($this->returnValue($source_data));
+      ->willReturn($source_data);
     $this->targetStorage->expects($this->once())
       ->method('readMultiple')
-      ->will($this->returnValue($target_data));
+      ->willReturn($target_data);
     $this->sourceStorage->expects($this->once())
       ->method('getAllCollectionNames')
-      ->will($this->returnValue([]));
+      ->willReturn([]);
     $this->targetStorage->expects($this->once())
       ->method('getAllCollectionNames')
-      ->will($this->returnValue([]));
+      ->willReturn([]);
 
     $this->storageComparer->createChangelist();
     $expected = [
diff --git a/core/tests/Drupal/Tests/Core/Controller/ControllerBaseTest.php b/core/tests/Drupal/Tests/Core/Controller/ControllerBaseTest.php
index 6c2df37db87399e6b3a0225913b4248706ef9888..89c22fa21ddf2ea4208d1c27ee66e82df0d50dc1 100644
--- a/core/tests/Drupal/Tests/Core/Controller/ControllerBaseTest.php
+++ b/core/tests/Drupal/Tests/Core/Controller/ControllerBaseTest.php
@@ -42,7 +42,7 @@ public function testGetConfig() {
     $container->expects($this->once())
       ->method('get')
       ->with('config.factory')
-      ->will($this->returnValue($config_factory));
+      ->willReturn($config_factory);
     \Drupal::setContainer($container);
 
     $config_method = new \ReflectionMethod('Drupal\Core\Controller\ControllerBase', 'config');
diff --git a/core/tests/Drupal/Tests/Core/Controller/TitleResolverTest.php b/core/tests/Drupal/Tests/Core/Controller/TitleResolverTest.php
index f5d4a980cbb6ce6b7825cc904a9b32d0388c29ec..2eb2e20de1a950a3fc6c031a27d404eb11f15f8e 100644
--- a/core/tests/Drupal/Tests/Core/Controller/TitleResolverTest.php
+++ b/core/tests/Drupal/Tests/Core/Controller/TitleResolverTest.php
@@ -136,11 +136,11 @@ public function testDynamicTitle() {
     $this->controllerResolver->expects($this->once())
       ->method('getControllerFromDefinition')
       ->with('Drupal\Tests\Core\Controller\TitleCallback::example')
-      ->will($this->returnValue($callable));
+      ->willReturn($callable);
     $this->argumentResolver->expects($this->once())
       ->method('getArguments')
       ->with($request, $callable)
-      ->will($this->returnValue(['example']));
+      ->willReturn(['example']);
 
     $this->assertEquals('test example', $this->titleResolver->getTitle($request, $route));
   }
diff --git a/core/tests/Drupal/Tests/Core/DrupalTest.php b/core/tests/Drupal/Tests/Core/DrupalTest.php
index 052af81346ed9446bdd116414d0bc032be3d8b19..38c59dfa0824d24dfeacf59258287b5eac2418d9 100644
--- a/core/tests/Drupal/Tests/Core/DrupalTest.php
+++ b/core/tests/Drupal/Tests/Core/DrupalTest.php
@@ -140,7 +140,7 @@ public function testKeyValueExpirable() {
     $keyvalue->expects($this->once())
       ->method('get')
       ->with('test_collection')
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
     $this->setMockContainerService('keyvalue.expirable', $keyvalue);
 
     $this->assertNotNull(\Drupal::keyValueExpirable('test_collection'));
@@ -166,7 +166,7 @@ public function testConfig() {
     $config->expects($this->once())
       ->method('get')
       ->with('test_config')
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
     $this->setMockContainerService('config.factory', $config);
 
     // Test \Drupal::config(), not $this->config().
@@ -185,7 +185,7 @@ public function testQueue() {
     $queue->expects($this->once())
       ->method('get')
       ->with('test_queue', TRUE)
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
     $this->setMockContainerService('queue', $queue);
 
     $this->assertNotNull(\Drupal::queue('test_queue', TRUE));
@@ -215,7 +215,7 @@ public function testKeyValue() {
     $keyvalue->expects($this->once())
       ->method('get')
       ->with('test_collection')
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
     $this->setMockContainerService('keyvalue', $keyvalue);
 
     $this->assertNotNull(\Drupal::keyValue('test_collection'));
diff --git a/core/tests/Drupal/Tests/Core/Enhancer/ParamConversionEnhancerTest.php b/core/tests/Drupal/Tests/Core/Enhancer/ParamConversionEnhancerTest.php
index 20d07c28504065f39b73c4fe1f8b6845a325f1ce..ce67c40e62b67ce4773e564dac2c31bb4997ecd1 100644
--- a/core/tests/Drupal/Tests/Core/Enhancer/ParamConversionEnhancerTest.php
+++ b/core/tests/Drupal/Tests/Core/Enhancer/ParamConversionEnhancerTest.php
@@ -57,7 +57,7 @@ public function testEnhance() {
     $this->paramConverterManager->expects($this->once())
       ->method('convert')
       ->with($this->isType('array'))
-      ->will($this->returnValue($expected));
+      ->willReturn($expected);
 
     $result = $this->paramConversionEnhancer->enhance($defaults, new Request());
 
diff --git a/core/tests/Drupal/Tests/Core/Entity/Access/EntityFormDisplayAccessControlHandlerTest.php b/core/tests/Drupal/Tests/Core/Entity/Access/EntityFormDisplayAccessControlHandlerTest.php
index 56a4b27af49b683683288aaf0d87517cf7b0e9ce..1b6e6646b6416591b4bfa68d358160654e017e9e 100644
--- a/core/tests/Drupal/Tests/Core/Entity/Access/EntityFormDisplayAccessControlHandlerTest.php
+++ b/core/tests/Drupal/Tests/Core/Entity/Access/EntityFormDisplayAccessControlHandlerTest.php
@@ -89,11 +89,11 @@ protected function setUp(): void {
     $this->anon
       ->expects($this->any())
       ->method('hasPermission')
-      ->will($this->returnValue(FALSE));
+      ->willReturn(FALSE);
     $this->anon
       ->expects($this->any())
       ->method('id')
-      ->will($this->returnValue(0));
+      ->willReturn(0);
 
     $this->member = $this->createMock(AccountInterface::class);
     $this->member
@@ -105,7 +105,7 @@ protected function setUp(): void {
     $this->member
       ->expects($this->any())
       ->method('id')
-      ->will($this->returnValue(2));
+      ->willReturn(2);
 
     $this->parent_member = $this->createMock(AccountInterface::class);
     $this->parent_member
@@ -117,12 +117,12 @@ protected function setUp(): void {
     $this->parent_member
       ->expects($this->any())
       ->method('id')
-      ->will($this->returnValue(3));
+      ->willReturn(3);
 
     $entity_form_display_entity_type = $this->createMock(ConfigEntityTypeInterface::class);
     $entity_form_display_entity_type->expects($this->any())
       ->method('getAdminPermission')
-      ->will($this->returnValue('Llama'));
+      ->willReturn('Llama');
     $entity_form_display_entity_type
       ->expects($this->any())
       ->method('getKey')
@@ -131,20 +131,16 @@ protected function setUp(): void {
       ]);
     $entity_form_display_entity_type->expects($this->any())
       ->method('entityClassImplements')
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
     $entity_form_display_entity_type->expects($this->any())
       ->method('getConfigPrefix')
       ->willReturn('');
 
     $this->moduleHandler = $this->createMock(ModuleHandlerInterface::class);
-    $this->moduleHandler
-      ->expects($this->any())
-      ->method('invokeAllWith')
-      ->will($this->returnValue([]));
     $this->moduleHandler
       ->expects($this->any())
       ->method('invokeAll')
-      ->will($this->returnValue([]));
+      ->willReturn([]);
 
     $storage_access_control_handler = new EntityFormDisplayAccessControlHandler($entity_form_display_entity_type);
     $storage_access_control_handler->setModuleHandler($this->moduleHandler);
@@ -165,12 +161,12 @@ protected function setUp(): void {
     $entity_type_manager
       ->expects($this->any())
       ->method('getDefinition')
-      ->will($this->returnValue($entity_form_display_entity_type));
+      ->willReturn($entity_form_display_entity_type);
 
     $entity_field_manager = $this->createMock(EntityFieldManagerInterface::class);
     $entity_field_manager->expects($this->any())
       ->method('getFieldDefinitions')
-      ->will($this->returnValue([]));
+      ->willReturn([]);
 
     $container = new Container();
     $container->set('entity_type.manager', $entity_type_manager);
diff --git a/core/tests/Drupal/Tests/Core/Entity/Access/EntityViewDisplayAccessControlHandlerTest.php b/core/tests/Drupal/Tests/Core/Entity/Access/EntityViewDisplayAccessControlHandlerTest.php
index c31a9458798f45fe2a8d05b9fbc59140624d3c6e..2d3c3bab6306980b6885ccafdfb38bc5ef68ff6f 100644
--- a/core/tests/Drupal/Tests/Core/Entity/Access/EntityViewDisplayAccessControlHandlerTest.php
+++ b/core/tests/Drupal/Tests/Core/Entity/Access/EntityViewDisplayAccessControlHandlerTest.php
@@ -28,7 +28,7 @@ protected function setUp(): void {
     $this->member
       ->expects($this->any())
       ->method('id')
-      ->will($this->returnValue(2));
+      ->willReturn(2);
 
     $this->entity = new EntityViewDisplay([
       'targetEntityType' => 'foobar',
diff --git a/core/tests/Drupal/Tests/Core/Entity/BaseFieldDefinitionTest.php b/core/tests/Drupal/Tests/Core/Entity/BaseFieldDefinitionTest.php
index ebcd518338780427f76e503d99d4d9af78bd6145..aae62e0e01442056835f0375766a420dedfd2f67 100644
--- a/core/tests/Drupal/Tests/Core/Entity/BaseFieldDefinitionTest.php
+++ b/core/tests/Drupal/Tests/Core/Entity/BaseFieldDefinitionTest.php
@@ -51,19 +51,19 @@ protected function setUp(): void {
 
     $field_type_manager->expects($this->any())
       ->method('getDefinitions')
-      ->will($this->returnValue([$this->fieldType => $this->fieldTypeDefinition]));
+      ->willReturn([$this->fieldType => $this->fieldTypeDefinition]);
     $field_type_manager->expects($this->any())
       ->method('getDefinition')
       ->with($this->fieldType)
-      ->will($this->returnValue($this->fieldTypeDefinition));
+      ->willReturn($this->fieldTypeDefinition);
     $field_type_manager->expects($this->any())
       ->method('getDefaultStorageSettings')
       ->with($this->fieldType)
-      ->will($this->returnValue($this->fieldTypeDefinition['storage_settings']));
+      ->willReturn($this->fieldTypeDefinition['storage_settings']);
     $field_type_manager->expects($this->any())
       ->method('getDefaultFieldSettings')
       ->with($this->fieldType)
-      ->will($this->returnValue($this->fieldTypeDefinition['field_settings']));
+      ->willReturn($this->fieldTypeDefinition['field_settings']);
 
     $container = new ContainerBuilder();
     $container->set('plugin.manager.field.field_type', $field_type_manager);
@@ -176,7 +176,7 @@ public function testFieldDefaultValue() {
       ->getMock();
     $data_definition->expects($this->any())
       ->method('getClass')
-      ->will($this->returnValue('Drupal\Core\Field\FieldItemBase'));
+      ->willReturn('Drupal\Core\Field\FieldItemBase');
     $definition->setItemDefinition($data_definition);
 
     // Set default value only with a literal.
@@ -223,7 +223,7 @@ public function testFieldInitialValue() {
       ->getMock();
     $data_definition->expects($this->any())
       ->method('getClass')
-      ->will($this->returnValue('Drupal\Core\Field\FieldItemBase'));
+      ->willReturn('Drupal\Core\Field\FieldItemBase');
     $definition->setItemDefinition($data_definition);
 
     // Set default value only with a literal.
diff --git a/core/tests/Drupal/Tests/Core/Entity/ContentEntityBaseUnitTest.php b/core/tests/Drupal/Tests/Core/Entity/ContentEntityBaseUnitTest.php
index 6d078c8c3c87061d7aa6ac08546a2460f3a901d3..f3060f6c38da4d86df365f7dd34325b7ac1a77bd 100644
--- a/core/tests/Drupal/Tests/Core/Entity/ContentEntityBaseUnitTest.php
+++ b/core/tests/Drupal/Tests/Core/Entity/ContentEntityBaseUnitTest.php
@@ -139,16 +139,16 @@ protected function setUp(): void {
     $this->entityType = $this->createMock('\Drupal\Core\Entity\EntityTypeInterface');
     $this->entityType->expects($this->any())
       ->method('getKeys')
-      ->will($this->returnValue([
+      ->willReturn([
         'id' => 'id',
         'uuid' => 'uuid',
-      ]));
+      ]);
 
     $this->entityTypeManager = $this->createMock(EntityTypeManagerInterface::class);
     $this->entityTypeManager->expects($this->any())
       ->method('getDefinition')
       ->with($this->entityTypeId)
-      ->will($this->returnValue($this->entityType));
+      ->willReturn($this->entityType);
 
     $this->entityFieldManager = $this->createMock(EntityFieldManagerInterface::class);
 
@@ -159,35 +159,38 @@ protected function setUp(): void {
     $this->typedDataManager = $this->createMock(TypedDataManagerInterface::class);
     $this->typedDataManager->expects($this->any())
       ->method('getDefinition')
-      ->will($this->returnValue(['class' => '\Drupal\Core\Entity\Plugin\DataType\EntityAdapter']));
+      ->willReturn(['class' => '\Drupal\Core\Entity\Plugin\DataType\EntityAdapter']);
 
     $english = new Language(['id' => 'en']);
     $not_specified = new Language(['id' => LanguageInterface::LANGCODE_NOT_SPECIFIED, 'locked' => TRUE]);
     $this->languageManager = $this->createMock('\Drupal\Core\Language\LanguageManagerInterface');
     $this->languageManager->expects($this->any())
       ->method('getLanguages')
-      ->will($this->returnValue(['en' => $english, LanguageInterface::LANGCODE_NOT_SPECIFIED => $not_specified]));
+      ->willReturn([
+        'en' => $english,
+        LanguageInterface::LANGCODE_NOT_SPECIFIED => $not_specified,
+      ]);
     $this->languageManager->expects($this->any())
       ->method('getLanguage')
       ->with('en')
-      ->will($this->returnValue($english));
+      ->willReturn($english);
     $this->languageManager->expects($this->any())
       ->method('getLanguage')
       ->with(LanguageInterface::LANGCODE_NOT_SPECIFIED)
-      ->will($this->returnValue($not_specified));
+      ->willReturn($not_specified);
 
     $this->fieldTypePluginManager = $this->getMockBuilder('\Drupal\Core\Field\FieldTypePluginManager')
       ->disableOriginalConstructor()
       ->getMock();
     $this->fieldTypePluginManager->expects($this->any())
       ->method('getDefaultStorageSettings')
-      ->will($this->returnValue([]));
+      ->willReturn([]);
     $this->fieldTypePluginManager->expects($this->any())
       ->method('getDefaultFieldSettings')
-      ->will($this->returnValue([]));
+      ->willReturn([]);
     $this->fieldTypePluginManager->expects($this->any())
       ->method('createFieldItemList')
-      ->will($this->returnValue($this->createMock('Drupal\Core\Field\FieldItemListInterface')));
+      ->willReturn($this->createMock('Drupal\Core\Field\FieldItemListInterface'));
 
     $container = new ContainerBuilder();
     $container->set('entity_field.manager', $this->entityFieldManager);
@@ -207,7 +210,7 @@ protected function setUp(): void {
     $this->entityFieldManager->expects($this->any())
       ->method('getFieldDefinitions')
       ->with($this->entityTypeId, $this->bundle)
-      ->will($this->returnValue($this->fieldDefinitions));
+      ->willReturn($this->fieldDefinitions);
 
     $this->entity = $this->getMockForAbstractClass(ContentEntityBase::class, [$values, $this->entityTypeId, $this->bundle], '', TRUE, TRUE, TRUE, ['isNew']);
     $values['defaultLangcode'] = [LanguageInterface::LANGCODE_DEFAULT => LanguageInterface::LANGCODE_NOT_SPECIFIED];
@@ -228,7 +231,7 @@ public function testIsNewRevision() {
     $this->entityType->expects($this->exactly(2))
       ->method('getKey')
       ->with('revision')
-      ->will($this->returnValue('revision_id'));
+      ->willReturn('revision_id');
 
     $field_item_list = $this->getMockBuilder('\Drupal\Core\Field\FieldItemList')
       ->disableOriginalConstructor()
@@ -240,7 +243,7 @@ public function testIsNewRevision() {
     $this->fieldTypePluginManager->expects($this->any())
       ->method('createFieldItemList')
       ->with($this->entity, 'revision_id', NULL)
-      ->will($this->returnValue($field_item_list));
+      ->willReturn($field_item_list);
 
     $this->fieldDefinitions['revision_id']->getItemDefinition()->setClass(get_class($field_item));
 
@@ -257,7 +260,7 @@ public function testSetNewRevisionException() {
     $this->entityType->expects($this->once())
       ->method('hasKey')
       ->with('revision')
-      ->will($this->returnValue(FALSE));
+      ->willReturn(FALSE);
     $this->expectException('LogicException');
     $this->expectExceptionMessage('Entity type ' . $this->entityTypeId . ' does not support revisions.');
     $this->entity->setNewRevision();
@@ -276,7 +279,7 @@ public function testIsDefaultRevision() {
     // The revision for a new entity should always be the default revision.
     $this->entity->expects($this->any())
       ->method('isNew')
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
     $this->entity->isDefaultRevision(FALSE);
     $this->assertTrue($this->entity->isDefaultRevision());
   }
@@ -296,14 +299,14 @@ public function testIsTranslatable() {
     $this->entityTypeBundleInfo->expects($this->any())
       ->method('getBundleInfo')
       ->with($this->entityTypeId)
-      ->will($this->returnValue([
+      ->willReturn([
         $this->bundle => [
           'translatable' => TRUE,
         ],
-      ]));
+      ]);
     $this->languageManager->expects($this->any())
       ->method('isMultilingual')
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
     $this->assertSame('en', $this->entity->language()->getId());
     $this->assertFalse($this->entity->language()->isLocked());
     $this->assertTrue($this->entity->isTranslatable());
@@ -319,7 +322,7 @@ public function testIsTranslatable() {
   public function testIsTranslatableForMonolingual() {
     $this->languageManager->expects($this->any())
       ->method('isMultilingual')
-      ->will($this->returnValue(FALSE));
+      ->willReturn(FALSE);
     $this->assertFalse($this->entity->isTranslatable());
   }
 
@@ -429,7 +432,7 @@ public function testValidate() {
       ->willReturnOnConsecutiveCalls($empty_violation_list, $non_empty_violation_list);
     $this->typedDataManager->expects($this->exactly(2))
       ->method('getValidator')
-      ->will($this->returnValue($validator));
+      ->willReturn($validator);
     $this->assertCount(0, $this->entity->validate());
     $this->assertCount(1, $this->entity->validate());
   }
@@ -450,10 +453,10 @@ public function testRequiredValidation() {
     $validator->expects($this->once())
       ->method('validate')
       ->with($this->entity->getTypedData())
-      ->will($this->returnValue($empty_violation_list));
+      ->willReturn($empty_violation_list);
     $this->typedDataManager->expects($this->any())
       ->method('getValidator')
-      ->will($this->returnValue($validator));
+      ->willReturn($validator);
 
     /** @var \Drupal\Core\Entity\EntityStorageInterface|\PHPUnit\Framework\MockObject\MockObject $storage */
     $storage = $this->createMock('\Drupal\Core\Entity\EntityStorageInterface');
@@ -466,7 +469,7 @@ public function testRequiredValidation() {
     $this->entityTypeManager->expects($this->any())
       ->method('getStorage')
       ->with($this->entityTypeId)
-      ->will($this->returnValue($storage));
+      ->willReturn($storage);
 
     // Check that entities can be saved normally when validation is not
     // required.
@@ -511,7 +514,7 @@ public function testAccess() {
       ->willReturnOnConsecutiveCalls(TRUE, AccessResult::allowed());
     $this->entityTypeManager->expects($this->exactly(4))
       ->method('getAccessControlHandler')
-      ->will($this->returnValue($access));
+      ->willReturn($access);
     $this->assertTrue($this->entity->access($operation));
     $this->assertEquals(AccessResult::allowed(), $this->entity->access($operation, NULL, TRUE));
     $this->assertTrue($this->entity->access('create'));
diff --git a/core/tests/Drupal/Tests/Core/Entity/EntityCreateAccessCheckTest.php b/core/tests/Drupal/Tests/Core/Entity/EntityCreateAccessCheckTest.php
index f4999533532e0491abfd2af651150112aa7d4bc9..4496499df88b47e9ce01b705f8d82281649a3cf7 100644
--- a/core/tests/Drupal/Tests/Core/Entity/EntityCreateAccessCheckTest.php
+++ b/core/tests/Drupal/Tests/Core/Entity/EntityCreateAccessCheckTest.php
@@ -87,11 +87,11 @@ public function testAccess($entity_bundle, $requirement, $access, $expected, $ex
       $access_control_handler->expects($this->once())
         ->method('createAccess')
         ->with($entity_bundle)
-        ->will($this->returnValue($access_result));
+        ->willReturn($access_result);
 
       $this->entityTypeManager->expects($this->any())
         ->method('getAccessControlHandler')
-        ->will($this->returnValue($access_control_handler));
+        ->willReturn($access_control_handler);
     }
 
     $applies_check = new EntityCreateAccessCheck($this->entityTypeManager);
@@ -102,7 +102,7 @@ public function testAccess($entity_bundle, $requirement, $access, $expected, $ex
     $route->expects($this->any())
       ->method('getRequirement')
       ->with('_entity_create_access')
-      ->will($this->returnValue($requirement));
+      ->willReturn($requirement);
 
     $raw_variables = new InputBag();
     if ($entity_bundle) {
@@ -112,7 +112,7 @@ public function testAccess($entity_bundle, $requirement, $access, $expected, $ex
     $route_match = $this->createMock('Drupal\Core\Routing\RouteMatchInterface');
     $route_match->expects($this->any())
       ->method('getRawParameters')
-      ->will($this->returnValue($raw_variables));
+      ->willReturn($raw_variables);
 
     $account = $this->createMock('Drupal\Core\Session\AccountInterface');
     $this->assertEquals($expected_access_result, $applies_check->access($route, $route_match, $account));
diff --git a/core/tests/Drupal/Tests/Core/Entity/EntityFormBuilderTest.php b/core/tests/Drupal/Tests/Core/Entity/EntityFormBuilderTest.php
index 95a5809a6f112679a7b04015af99fc838ddf7d1c..56ae73b6fbf5470cbc0757f07191aa13621b3320 100644
--- a/core/tests/Drupal/Tests/Core/Entity/EntityFormBuilderTest.php
+++ b/core/tests/Drupal/Tests/Core/Entity/EntityFormBuilderTest.php
@@ -52,21 +52,21 @@ public function testGetForm() {
     $form_controller = $this->createMock('Drupal\Core\Entity\EntityFormInterface');
     $form_controller->expects($this->any())
       ->method('getFormId')
-      ->will($this->returnValue('the_form_id'));
+      ->willReturn('the_form_id');
     $this->entityTypeManager->expects($this->any())
       ->method('getFormObject')
       ->with('the_entity_type', 'default')
-      ->will($this->returnValue($form_controller));
+      ->willReturn($form_controller);
 
     $this->formBuilder->expects($this->once())
       ->method('buildForm')
       ->with($form_controller, $this->isInstanceOf('Drupal\Core\Form\FormStateInterface'))
-      ->will($this->returnValue('the form contents'));
+      ->willReturn('the form contents');
 
     $entity = $this->createMock('Drupal\Core\Entity\EntityInterface');
     $entity->expects($this->once())
       ->method('getEntityTypeId')
-      ->will($this->returnValue('the_entity_type'));
+      ->willReturn('the_entity_type');
 
     $this->assertSame('the form contents', $this->entityFormBuilder->getForm($entity));
   }
diff --git a/core/tests/Drupal/Tests/Core/Entity/EntityFormTest.php b/core/tests/Drupal/Tests/Core/Entity/EntityFormTest.php
index 844fa01e25132d93d6e148c604a6457a7e111441..b4cd603777af1050f1574ab151f2375a52191228 100644
--- a/core/tests/Drupal/Tests/Core/Entity/EntityFormTest.php
+++ b/core/tests/Drupal/Tests/Core/Entity/EntityFormTest.php
@@ -56,10 +56,10 @@ public function testFormId($expected, $definition) {
 
     $entity->expects($this->any())
       ->method('getEntityType')
-      ->will($this->returnValue($this->entityType));
+      ->willReturn($this->entityType);
     $entity->expects($this->any())
       ->method('bundle')
-      ->will($this->returnValue($definition['bundle']));
+      ->willReturn($definition['bundle']);
 
     $this->entityForm->setEntity($entity);
     $this->entityForm->setOperation($definition['operation']);
diff --git a/core/tests/Drupal/Tests/Core/Entity/EntityLinkTest.php b/core/tests/Drupal/Tests/Core/Entity/EntityLinkTest.php
index 20624988f8d60a6f07658fdfc6d058787239553f..757d5fbfbc149c91f17e7e1fd9bccbb82fb30d0f 100644
--- a/core/tests/Drupal/Tests/Core/Entity/EntityLinkTest.php
+++ b/core/tests/Drupal/Tests/Core/Entity/EntityLinkTest.php
@@ -90,7 +90,7 @@ public function testToLink($entity_label, $link_text, $expected_text, $link_rel
       ->expects($this->any())
       ->method('getDefinition')
       ->with($entity_type_id)
-      ->will($this->returnValue($entity_type));
+      ->willReturn($entity_type);
 
     /** @var \Drupal\Core\Entity\Entity $entity */
     $entity = $this->getMockForAbstractClass('Drupal\Core\Entity\EntityBase', [
diff --git a/core/tests/Drupal/Tests/Core/Entity/EntityListBuilderTest.php b/core/tests/Drupal/Tests/Core/Entity/EntityListBuilderTest.php
index af87b302fe76e7590e37ce75085622b4fb39bc21..470a2cd69573252d58152a5535afe5ea5a871149 100644
--- a/core/tests/Drupal/Tests/Core/Entity/EntityListBuilderTest.php
+++ b/core/tests/Drupal/Tests/Core/Entity/EntityListBuilderTest.php
@@ -107,7 +107,7 @@ public function testGetOperations() {
     $this->moduleHandler->expects($this->once())
       ->method('invokeAll')
       ->with('entity_operation', [$this->role])
-      ->will($this->returnValue($operations));
+      ->willReturn($operations);
     $this->moduleHandler->expects($this->once())
       ->method('alter')
       ->with('entity_operation');
@@ -116,10 +116,10 @@ public function testGetOperations() {
 
     $this->role->expects($this->any())
       ->method('access')
-      ->will($this->returnValue(AccessResult::allowed()));
+      ->willReturn(AccessResult::allowed());
     $this->role->expects($this->any())
       ->method('hasLinkTemplate')
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
     $url = $this->getMockBuilder('\Drupal\Core\Url')
       ->disableOriginalConstructor()
       ->getMock();
@@ -128,7 +128,7 @@ public function testGetOperations() {
       ->with(['query' => ['destination' => '/foo/bar']]);
     $this->role->expects($this->any())
       ->method('toUrl')
-      ->will($this->returnValue($url));
+      ->willReturn($url);
 
     $this->redirectDestination->expects($this->atLeastOnce())
       ->method('getAsArray')
diff --git a/core/tests/Drupal/Tests/Core/Entity/EntityResolverManagerTest.php b/core/tests/Drupal/Tests/Core/Entity/EntityResolverManagerTest.php
index ad3452f63886fcb93ce5dd4ecb546b9e930492c8..e01e0b57f5fdebd2ef202b7904b0b75277a2f0a3 100644
--- a/core/tests/Drupal/Tests/Core/Entity/EntityResolverManagerTest.php
+++ b/core/tests/Drupal/Tests/Core/Entity/EntityResolverManagerTest.php
@@ -444,23 +444,23 @@ protected function setupEntityTypes() {
     $definition = $this->createMock('Drupal\Core\Entity\EntityTypeInterface');
     $definition->expects($this->any())
       ->method('getClass')
-      ->will($this->returnValue('Drupal\Tests\Core\Entity\TestEntity'));
+      ->willReturn('Drupal\Tests\Core\Entity\TestEntity');
     $definition->expects($this->any())
       ->method('isRevisionable')
       ->willReturn(FALSE);
     $revisionable_definition = $this->createMock('Drupal\Core\Entity\EntityTypeInterface');
     $revisionable_definition->expects($this->any())
       ->method('getClass')
-      ->will($this->returnValue('Drupal\Tests\Core\Entity\TestEntity'));
+      ->willReturn('Drupal\Tests\Core\Entity\TestEntity');
     $revisionable_definition->expects($this->any())
       ->method('isRevisionable')
       ->willReturn(TRUE);
     $this->entityTypeManager->expects($this->any())
       ->method('getDefinitions')
-      ->will($this->returnValue([
+      ->willReturn([
         'entity_test' => $definition,
         'entity_test_rev' => $revisionable_definition,
-      ]));
+      ]);
     $this->entityTypeManager->expects($this->any())
       ->method('getDefinition')
       ->willReturnCallback(function ($entity_type) use ($definition, $revisionable_definition) {
diff --git a/core/tests/Drupal/Tests/Core/Entity/EntityUnitTest.php b/core/tests/Drupal/Tests/Core/Entity/EntityUnitTest.php
index b37c34a3470217d8b2308d01594f1e9a2753ffad..ede995aa5f95efb3a538fab7da4f78f680f27735 100644
--- a/core/tests/Drupal/Tests/Core/Entity/EntityUnitTest.php
+++ b/core/tests/Drupal/Tests/Core/Entity/EntityUnitTest.php
@@ -102,7 +102,7 @@ protected function setUp(): void {
     $this->entityTypeManager->expects($this->any())
       ->method('getDefinition')
       ->with($this->entityTypeId)
-      ->will($this->returnValue($this->entityType));
+      ->willReturn($this->entityType);
 
     $this->uuid = $this->createMock('\Drupal\Component\Uuid\UuidInterface');
 
@@ -110,7 +110,7 @@ protected function setUp(): void {
     $this->languageManager->expects($this->any())
       ->method('getLanguage')
       ->with('en')
-      ->will($this->returnValue(new Language(['id' => 'en'])));
+      ->willReturn(new Language(['id' => 'en']));
 
     $this->cacheTagsInvalidator = $this->createMock('Drupal\Core\Cache\CacheTagsInvalidator');
 
@@ -172,18 +172,18 @@ public function testLabel() {
     $this->entityType->expects($this->atLeastOnce())
       ->method('getKey')
       ->with('label')
-      ->will($this->returnValue('label'));
+      ->willReturn('label');
 
     // Set a dummy property on the entity under test to test that the label can
     // be returned form a property if there is no callback.
     $this->entityTypeManager->expects($this->atLeastOnce())
       ->method('getDefinition')
       ->with($this->entityTypeId)
-      ->will($this->returnValue([
+      ->willReturn([
         'entity_keys' => [
           'label' => 'label',
         ],
-      ]));
+      ]);
     $this->entity->label = $property_label;
 
     $this->assertSame($property_label, $this->entity->label());
@@ -198,13 +198,13 @@ public function testAccess() {
     $access->expects($this->once())
       ->method('access')
       ->with($this->entity, $operation)
-      ->will($this->returnValue(AccessResult::allowed()));
+      ->willReturn(AccessResult::allowed());
     $access->expects($this->once())
       ->method('createAccess')
-      ->will($this->returnValue(AccessResult::allowed()));
+      ->willReturn(AccessResult::allowed());
     $this->entityTypeManager->expects($this->exactly(2))
       ->method('getAccessControlHandler')
-      ->will($this->returnValue($access));
+      ->willReturn($access);
 
     $this->assertEquals(AccessResult::allowed(), $this->entity->access($operation));
     $this->assertEquals(AccessResult::allowed(), $this->entity->access('create'));
@@ -260,12 +260,12 @@ public function testLoad() {
     $storage->expects($this->once())
       ->method('load')
       ->with(1)
-      ->will($this->returnValue($this->entity));
+      ->willReturn($this->entity);
 
     $this->entityTypeManager->expects($this->once())
       ->method('getStorage')
       ->with($this->entityTypeId)
-      ->will($this->returnValue($storage));
+      ->willReturn($storage);
 
     \Drupal::getContainer()->set('entity_type.repository', $entity_type_repository);
 
@@ -294,12 +294,12 @@ public function testLoadMultiple() {
     $storage->expects($this->once())
       ->method('loadMultiple')
       ->with([1])
-      ->will($this->returnValue([1 => $this->entity]));
+      ->willReturn([1 => $this->entity]);
 
     $this->entityTypeManager->expects($this->once())
       ->method('getStorage')
       ->with($this->entityTypeId)
-      ->will($this->returnValue($storage));
+      ->willReturn($storage);
 
     \Drupal::getContainer()->set('entity_type.repository', $entity_type_repository);
 
@@ -326,12 +326,12 @@ public function testCreate() {
     $storage->expects($this->once())
       ->method('create')
       ->with([])
-      ->will($this->returnValue($this->entity));
+      ->willReturn($this->entity);
 
     $this->entityTypeManager->expects($this->once())
       ->method('getStorage')
       ->with($this->entityTypeId)
-      ->will($this->returnValue($storage));
+      ->willReturn($storage);
 
     \Drupal::getContainer()->set('entity_type.repository', $entity_type_repository);
 
@@ -352,7 +352,7 @@ public function testSave() {
     $this->entityTypeManager->expects($this->once())
       ->method('getStorage')
       ->with($this->entityTypeId)
-      ->will($this->returnValue($storage));
+      ->willReturn($storage);
 
     $this->entity->save();
   }
@@ -370,7 +370,7 @@ public function testDelete() {
     $this->entityTypeManager->expects($this->once())
       ->method('getStorage')
       ->with($this->entityTypeId)
-      ->will($this->returnValue($storage));
+      ->willReturn($storage);
 
     $this->entity->delete();
   }
diff --git a/core/tests/Drupal/Tests/Core/Entity/FieldDefinitionTest.php b/core/tests/Drupal/Tests/Core/Entity/FieldDefinitionTest.php
index a857c6f25348a18bda27ef915b264a49d80fdc44..1343dd9abd55224b7be8b8c30579e3f5b3443263 100644
--- a/core/tests/Drupal/Tests/Core/Entity/FieldDefinitionTest.php
+++ b/core/tests/Drupal/Tests/Core/Entity/FieldDefinitionTest.php
@@ -205,7 +205,7 @@ public function testFieldDefaultValue($factory_name) {
       ->getMock();
     $data_definition->expects($this->any())
       ->method('getClass')
-      ->will($this->returnValue('Drupal\Core\Field\FieldItemBase'));
+      ->willReturn('Drupal\Core\Field\FieldItemBase');
     $definition->setItemDefinition($data_definition);
 
     // Set default value only with a literal.
diff --git a/core/tests/Drupal/Tests/Core/Entity/KeyValueStore/KeyValueEntityStorageTest.php b/core/tests/Drupal/Tests/Core/Entity/KeyValueStore/KeyValueEntityStorageTest.php
index 9eb2970664037fb33f51c933a95e0a7525de2b8c..90b0f1c6ce904ee8d8ac20af7c6b380f1d119ffc 100644
--- a/core/tests/Drupal/Tests/Core/Entity/KeyValueStore/KeyValueEntityStorageTest.php
+++ b/core/tests/Drupal/Tests/Core/Entity/KeyValueStore/KeyValueEntityStorageTest.php
@@ -107,7 +107,7 @@ protected function setUpKeyValueEntityStorage($uuid_key = 'uuid') {
       ]);
     $this->entityType->expects($this->atLeastOnce())
       ->method('id')
-      ->will($this->returnValue('test_entity_type'));
+      ->willReturn('test_entity_type');
     $this->entityType->expects($this->any())
       ->method('getListCacheTags')
       ->willReturn(['test_entity_type_list']);
@@ -116,7 +116,7 @@ protected function setUpKeyValueEntityStorage($uuid_key = 'uuid') {
     $this->entityTypeManager->expects($this->any())
       ->method('getDefinition')
       ->with('test_entity_type')
-      ->will($this->returnValue($this->entityType));
+      ->willReturn($this->entityType);
 
     $this->entityFieldManager = $this->createMock(EntityFieldManagerInterface::class);
 
@@ -129,10 +129,10 @@ protected function setUpKeyValueEntityStorage($uuid_key = 'uuid') {
     $language = new Language(['langcode' => 'en']);
     $this->languageManager->expects($this->any())
       ->method('getDefaultLanguage')
-      ->will($this->returnValue($language));
+      ->willReturn($language);
     $this->languageManager->expects($this->any())
       ->method('getCurrentLanguage')
-      ->will($this->returnValue($language));
+      ->willReturn($language);
 
     $this->entityStorage = new KeyValueEntityStorage($this->entityType, $this->keyValueStore, $this->uuidService, $this->languageManager, new MemoryCache());
     $this->entityStorage->setModuleHandler($this->moduleHandler);
@@ -152,7 +152,7 @@ protected function setUpKeyValueEntityStorage($uuid_key = 'uuid') {
   public function testCreateWithPredefinedUuid() {
     $this->entityType->expects($this->once())
       ->method('getClass')
-      ->will($this->returnValue(get_class($this->getMockEntity())));
+      ->willReturn(get_class($this->getMockEntity()));
     $this->setUpKeyValueEntityStorage();
 
     $this->moduleHandler->expects($this->exactly(2))
@@ -175,7 +175,7 @@ public function testCreateWithoutUuidKey() {
     // Set up the entity storage to expect no UUID key.
     $this->entityType->expects($this->once())
       ->method('getClass')
-      ->will($this->returnValue(get_class($this->getMockEntity())));
+      ->willReturn(get_class($this->getMockEntity()));
     $this->setUpKeyValueEntityStorage(NULL);
 
     $this->moduleHandler->expects($this->exactly(2))
@@ -200,7 +200,7 @@ public function testCreate() {
     $entity = $this->getMockEntity('Drupal\Core\Entity\EntityBase', [], ['toArray']);
     $this->entityType->expects($this->once())
       ->method('getClass')
-      ->will($this->returnValue(get_class($entity)));
+      ->willReturn(get_class($entity));
     $this->setUpKeyValueEntityStorage();
 
     $this->moduleHandler->expects($this->exactly(2))
@@ -208,7 +208,7 @@ public function testCreate() {
       ->withConsecutive(['test_entity_type_create'], ['entity_create']);
     $this->uuidService->expects($this->once())
       ->method('generate')
-      ->will($this->returnValue('bar'));
+      ->willReturn('bar');
 
     $entity = $this->entityStorage->create(['id' => 'foo']);
     $this->assertInstanceOf('Drupal\Core\Entity\EntityInterface', $entity);
@@ -235,7 +235,7 @@ public function testSaveInsert(EntityInterface $entity) {
     $this->keyValueStore->expects($this->exactly(2))
       ->method('has')
       ->with('foo')
-      ->will($this->returnValue(FALSE));
+      ->willReturn(FALSE);
     $this->keyValueStore->expects($this->never())
       ->method('getMultiple');
     $this->keyValueStore->expects($this->never())
@@ -243,7 +243,7 @@ public function testSaveInsert(EntityInterface $entity) {
 
     $entity->expects($this->atLeastOnce())
       ->method('toArray')
-      ->will($this->returnValue($expected));
+      ->willReturn($expected);
 
     $this->moduleHandler->expects($this->exactly(4))
       ->method('invokeAll')
@@ -275,18 +275,18 @@ public function testSaveInsert(EntityInterface $entity) {
   public function testSaveUpdate(EntityInterface $entity) {
     $this->entityType->expects($this->once())
       ->method('getClass')
-      ->will($this->returnValue(get_class($entity)));
+      ->willReturn(get_class($entity));
     $this->setUpKeyValueEntityStorage();
 
     $expected = ['id' => 'foo'];
     $this->keyValueStore->expects($this->exactly(2))
       ->method('has')
       ->with('foo')
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
     $this->keyValueStore->expects($this->once())
       ->method('getMultiple')
       ->with(['foo'])
-      ->will($this->returnValue([['id' => 'foo']]));
+      ->willReturn([['id' => 'foo']]);
     $this->keyValueStore->expects($this->never())
       ->method('delete');
     $this->moduleHandler->expects($this->exactly(4))
@@ -323,12 +323,12 @@ public function testSaveConfigEntity() {
     $expected = ['id' => 'foo'];
     $entity->expects($this->atLeastOnce())
       ->method('toArray')
-      ->will($this->returnValue($expected));
+      ->willReturn($expected);
 
     $this->keyValueStore->expects($this->exactly(2))
       ->method('has')
       ->with('foo')
-      ->will($this->returnValue(FALSE));
+      ->willReturn(FALSE);
     $this->keyValueStore->expects($this->once())
       ->method('set')
       ->with('foo', $expected);
@@ -349,21 +349,21 @@ public function testSaveConfigEntity() {
   public function testSaveRenameConfigEntity(ConfigEntityInterface $entity) {
     $this->entityType->expects($this->once())
       ->method('getClass')
-      ->will($this->returnValue(get_class($entity)));
+      ->willReturn(get_class($entity));
     $this->setUpKeyValueEntityStorage();
 
     $expected = ['id' => 'foo'];
     $entity->expects($this->once())
       ->method('toArray')
-      ->will($this->returnValue($expected));
+      ->willReturn($expected);
     $this->keyValueStore->expects($this->exactly(2))
       ->method('has')
       ->with('foo')
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
     $this->keyValueStore->expects($this->once())
       ->method('getMultiple')
       ->with(['foo'])
-      ->will($this->returnValue([['id' => 'foo']]));
+      ->willReturn([['id' => 'foo']]);
     $this->keyValueStore->expects($this->once())
       ->method('delete')
       ->with('foo');
@@ -388,16 +388,16 @@ public function testSaveRenameConfigEntity(ConfigEntityInterface $entity) {
   public function testSaveContentEntity() {
     $this->entityType->expects($this->any())
       ->method('getKeys')
-      ->will($this->returnValue([
+      ->willReturn([
         'id' => 'id',
-      ]));
+      ]);
     $this->setUpKeyValueEntityStorage();
 
     $expected = ['id' => 'foo'];
     $this->keyValueStore->expects($this->exactly(2))
       ->method('has')
       ->with('foo')
-      ->will($this->returnValue(FALSE));
+      ->willReturn(FALSE);
     $this->keyValueStore->expects($this->once())
       ->method('set')
       ->with('foo', $expected);
@@ -409,10 +409,10 @@ public function testSaveContentEntity() {
     ]);
     $entity->expects($this->atLeastOnce())
       ->method('id')
-      ->will($this->returnValue('foo'));
+      ->willReturn('foo');
     $entity->expects($this->once())
       ->method('toArray')
-      ->will($this->returnValue($expected));
+      ->willReturn($expected);
     $this->entityStorage->save($entity);
   }
 
@@ -446,7 +446,7 @@ public function testSaveDuplicate() {
     $entity->enforceIsNew();
     $this->keyValueStore->expects($this->once())
       ->method('has')
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
     $this->keyValueStore->expects($this->never())
       ->method('set');
     $this->keyValueStore->expects($this->never())
@@ -464,13 +464,13 @@ public function testLoad() {
     $entity = $this->getMockEntity();
     $this->entityType->expects($this->once())
       ->method('getClass')
-      ->will($this->returnValue(get_class($entity)));
+      ->willReturn(get_class($entity));
     $this->setUpKeyValueEntityStorage();
 
     $this->keyValueStore->expects($this->once())
       ->method('getMultiple')
       ->with(['foo'])
-      ->will($this->returnValue([['id' => 'foo']]));
+      ->willReturn([['id' => 'foo']]);
     $entity = $this->entityStorage->load('foo');
     $this->assertInstanceOf('Drupal\Core\Entity\EntityInterface', $entity);
     $this->assertSame('foo', $entity->id());
@@ -485,7 +485,7 @@ public function testLoadMissingEntity() {
     $this->keyValueStore->expects($this->once())
       ->method('getMultiple')
       ->with(['foo'])
-      ->will($this->returnValue([]));
+      ->willReturn([]);
     $entity = $this->entityStorage->load('foo');
     $this->assertNull($entity);
   }
@@ -501,12 +501,12 @@ public function testLoadMultipleAll() {
     $expected['bar'] = $this->getMockEntity('Drupal\Core\Entity\EntityBase', [['id' => 'bar']]);
     $this->entityType->expects($this->once())
       ->method('getClass')
-      ->will($this->returnValue(get_class(reset($expected))));
+      ->willReturn(get_class(reset($expected)));
     $this->setUpKeyValueEntityStorage();
 
     $this->keyValueStore->expects($this->once())
       ->method('getAll')
-      ->will($this->returnValue([['id' => 'foo'], ['id' => 'bar']]));
+      ->willReturn([['id' => 'foo'], ['id' => 'bar']]);
     $entities = $this->entityStorage->loadMultiple();
     foreach ($entities as $id => $entity) {
       $this->assertInstanceOf('Drupal\Core\Entity\EntityInterface', $entity);
@@ -525,14 +525,14 @@ public function testLoadMultipleIds() {
     $entity = $this->getMockEntity('Drupal\Core\Entity\EntityBase', [['id' => 'foo']]);
     $this->entityType->expects($this->once())
       ->method('getClass')
-      ->will($this->returnValue(get_class($entity)));
+      ->willReturn(get_class($entity));
     $this->setUpKeyValueEntityStorage();
 
     $expected[] = $entity;
     $this->keyValueStore->expects($this->once())
       ->method('getMultiple')
       ->with(['foo'])
-      ->will($this->returnValue([['id' => 'foo']]));
+      ->willReturn([['id' => 'foo']]);
     $entities = $this->entityStorage->loadMultiple(['foo']);
     foreach ($entities as $id => $entity) {
       $this->assertInstanceOf('Drupal\Core\Entity\EntityInterface', $entity);
diff --git a/core/tests/Drupal/Tests/Core/Entity/Sql/DefaultTableMappingTest.php b/core/tests/Drupal/Tests/Core/Entity/Sql/DefaultTableMappingTest.php
index cd1be3f9fcaebbc06a238898065bf1c28db05b78..66862dedf42b9c9e075f87d2fa36972c78f0c5bc 100644
--- a/core/tests/Drupal/Tests/Core/Entity/Sql/DefaultTableMappingTest.php
+++ b/core/tests/Drupal/Tests/Core/Entity/Sql/DefaultTableMappingTest.php
@@ -462,10 +462,10 @@ public function testGetDedicatedTableName($info, $expected_data_table, $expected
     $definition = $this->setUpDefinition($field_name, []);
     $definition->expects($this->any())
       ->method('getTargetEntityTypeId')
-      ->will($this->returnValue($entity_type_id));
+      ->willReturn($entity_type_id);
     $definition->expects($this->any())
       ->method('getUniqueStorageIdentifier')
-      ->will($this->returnValue($entity_type_id . '-' . $field_name));
+      ->willReturn($entity_type_id . '-' . $field_name);
 
     $this->entityType
       ->expects($this->any())
@@ -594,10 +594,10 @@ protected function setUpDefinition($name, array $column_names, $base_field = TRU
       ->willReturn($base_field);
     $definition->expects($this->any())
       ->method('getName')
-      ->will($this->returnValue($name));
+      ->willReturn($name);
     $definition->expects($this->any())
       ->method('getColumns')
-      ->will($this->returnValue(array_fill_keys($column_names, [])));
+      ->willReturn(array_fill_keys($column_names, []));
     return $definition;
   }
 
diff --git a/core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageSchemaTest.php b/core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageSchemaTest.php
index 9cbb634b25a24cb9c91f1718c1604a176c75700e..02b2c7e0603d8c2ce473d7304134c6a0af2aba26 100644
--- a/core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageSchemaTest.php
+++ b/core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageSchemaTest.php
@@ -86,7 +86,7 @@ protected function setUp(): void {
 
     $this->storage->expects($this->any())
       ->method('getBaseTable')
-      ->will($this->returnValue('entity_test'));
+      ->willReturn('entity_test');
 
     // Add an ID field. This also acts as a test for a simple, single-column
     // field.
@@ -388,7 +388,7 @@ public function testGetSchemaBase() {
 
     $this->storageSchema->expects($this->any())
       ->method('getTableMapping')
-      ->will($this->returnValue($table_mapping));
+      ->willReturn($table_mapping);
 
     $this->assertNull(
       $this->storageSchema->onEntityTypeCreate($this->entityType)
@@ -422,11 +422,11 @@ public function testGetSchemaRevisionable() {
 
     $this->entityType->expects($this->any())
       ->method('getRevisionMetadataKeys')
-      ->will($this->returnValue([]));
+      ->willReturn([]);
 
     $this->storage->expects($this->exactly(9))
       ->method('getRevisionTable')
-      ->will($this->returnValue('entity_test_revision'));
+      ->willReturn('entity_test_revision');
 
     $this->setUpStorageDefinition('revision_id', [
       'columns' => [
@@ -495,7 +495,7 @@ public function testGetSchemaRevisionable() {
 
     $this->storageSchema->expects($this->any())
       ->method('getTableMapping')
-      ->will($this->returnValue($table_mapping));
+      ->willReturn($table_mapping);
 
     $this->storageSchema->onEntityTypeCreate($this->entityType);
   }
@@ -522,7 +522,7 @@ public function testGetSchemaTranslatable() {
 
     $this->storage->expects($this->any())
       ->method('getDataTable')
-      ->will($this->returnValue('entity_test_field_data'));
+      ->willReturn('entity_test_field_data');
 
     $this->setUpStorageDefinition('langcode', [
       'columns' => [
@@ -604,7 +604,7 @@ public function testGetSchemaTranslatable() {
 
     $this->storageSchema->expects($this->any())
       ->method('getTableMapping')
-      ->will($this->returnValue($table_mapping));
+      ->willReturn($table_mapping);
 
     $this->assertNull(
       $this->storageSchema->onEntityTypeCreate($this->entityType)
@@ -640,14 +640,14 @@ public function testGetSchemaRevisionableTranslatable() {
 
     $this->entityType->expects($this->any())
       ->method('isRevisionable')
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
     $this->entityType->expects($this->any())
       ->method('isTranslatable')
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
 
     $this->storage->expects($this->exactly(30))
       ->method('getRevisionTable')
-      ->will($this->returnValue('entity_test_revision'));
+      ->willReturn('entity_test_revision');
 
     $this->setUpStorageDefinition('revision_id', [
       'columns' => [
@@ -822,7 +822,7 @@ public function testGetSchemaRevisionableTranslatable() {
 
     $this->storageSchema->expects($this->any())
       ->method('getTableMapping')
-      ->will($this->returnValue($table_mapping));
+      ->willReturn($table_mapping);
 
     $this->storageSchema->onEntityTypeCreate($this->entityType);
   }
@@ -888,20 +888,20 @@ public function testDedicatedTableSchema() {
     $field_storage
       ->expects($this->any())
       ->method('getType')
-      ->will($this->returnValue('shape'));
+      ->willReturn('shape');
     $field_storage
       ->expects($this->any())
       ->method('getTargetEntityTypeId')
-      ->will($this->returnValue($entity_type_id));
+      ->willReturn($entity_type_id);
     $field_storage
       ->expects($this->any())
       ->method('isMultiple')
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
 
     $this->storageDefinitions['id']
       ->expects($this->any())
       ->method('getType')
-      ->will($this->returnValue('integer'));
+      ->willReturn('integer');
 
     $expected = [
       $entity_type_id . '__' . $field_name => [
@@ -997,7 +997,7 @@ public function testDedicatedTableSchema() {
 
     $this->storageSchema->expects($this->any())
       ->method('getTableMapping')
-      ->will($this->returnValue($table_mapping));
+      ->willReturn($table_mapping);
 
     $this->assertNull(
       $this->storageSchema->onFieldStorageDefinitionCreate($field_storage)
@@ -1049,20 +1049,20 @@ public function testDedicatedTableSchemaForEntityWithStringIdentifier() {
     $field_storage
       ->expects($this->any())
       ->method('getType')
-      ->will($this->returnValue('shape'));
+      ->willReturn('shape');
     $field_storage
       ->expects($this->any())
       ->method('getTargetEntityTypeId')
-      ->will($this->returnValue($entity_type_id));
+      ->willReturn($entity_type_id);
     $field_storage
       ->expects($this->any())
       ->method('isMultiple')
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
 
     $this->storageDefinitions['id']
       ->expects($this->any())
       ->method('getType')
-      ->will($this->returnValue('string'));
+      ->willReturn('string');
 
     $expected = [
       $entity_type_id . '__' . $field_name => [
@@ -1142,7 +1142,7 @@ public function testDedicatedTableSchemaForEntityWithStringIdentifier() {
 
     $this->storageSchema->expects($this->any())
       ->method('getTableMapping')
-      ->will($this->returnValue($table_mapping));
+      ->willReturn($table_mapping);
 
     $this->assertNull(
       $this->storageSchema->onFieldStorageDefinitionCreate($field_storage)
@@ -1316,7 +1316,7 @@ public function testRequiresEntityStorageSchemaChanges(ContentEntityTypeInterfac
     $table_mapping->setExtraColumns('entity_test', ['default_langcode']);
     $this->storageSchema->expects($this->any())
       ->method('getTableMapping')
-      ->will($this->returnValue($table_mapping));
+      ->willReturn($table_mapping);
 
     // Setup storage schema.
     if ($change_schema) {
@@ -1357,22 +1357,22 @@ protected function setUpStorageSchema(array $expected = []) {
     $this->entityTypeManager->expects($this->any())
       ->method('getDefinition')
       ->with($this->entityType->id())
-      ->will($this->returnValue($this->entityType));
+      ->willReturn($this->entityType);
 
     $this->entityTypeManager->expects($this->any())
       ->method('getActiveDefinition')
       ->with($this->entityType->id())
-      ->will($this->returnValue($this->entityType));
+      ->willReturn($this->entityType);
 
     $this->entityFieldManager->expects($this->any())
       ->method('getFieldStorageDefinitions')
       ->with($this->entityType->id())
-      ->will($this->returnValue($this->storageDefinitions));
+      ->willReturn($this->storageDefinitions);
 
     $this->entityFieldManager->expects($this->any())
       ->method('getActiveFieldStorageDefinitions')
       ->with($this->entityType->id())
-      ->will($this->returnValue($this->storageDefinitions));
+      ->willReturn($this->storageDefinitions);
 
     $this->dbSchemaHandler = $this->getMockBuilder('Drupal\Core\Database\Schema')
       ->disableOriginalConstructor()
@@ -1403,7 +1403,7 @@ protected function setUpStorageSchema(array $expected = []) {
       ->getMock();
     $connection->expects($this->any())
       ->method('schema')
-      ->will($this->returnValue($this->dbSchemaHandler));
+      ->willReturn($this->dbSchemaHandler);
 
     $key_value = $this->createMock('Drupal\Core\KeyValueStore\KeyValueStoreInterface');
 
@@ -1423,7 +1423,7 @@ protected function setUpStorageSchema(array $expected = []) {
     $this->storageSchema
       ->expects($this->any())
       ->method('installedStorageSchema')
-      ->will($this->returnValue($key_value));
+      ->willReturn($key_value);
     $this->storageSchema
       ->expects($this->any())
       ->method('isTableEmpty')
@@ -1443,18 +1443,18 @@ public function setUpStorageDefinition($field_name, array $schema) {
     $this->storageDefinitions[$field_name] = $this->createMock('Drupal\Tests\Core\Field\TestBaseFieldDefinitionInterface');
     $this->storageDefinitions[$field_name]->expects($this->any())
       ->method('isBaseField')
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
     // getName() is called once for each table.
     $this->storageDefinitions[$field_name]->expects($this->any())
       ->method('getName')
-      ->will($this->returnValue($field_name));
+      ->willReturn($field_name);
     // getSchema() is called once for each table.
     $this->storageDefinitions[$field_name]->expects($this->any())
       ->method('getSchema')
-      ->will($this->returnValue($schema));
+      ->willReturn($schema);
     $this->storageDefinitions[$field_name]->expects($this->any())
       ->method('getColumns')
-      ->will($this->returnValue($schema['columns']));
+      ->willReturn($schema['columns']);
     // Add property definitions.
     if (!empty($schema['columns'])) {
       $property_definitions = [];
@@ -1462,11 +1462,11 @@ public function setUpStorageDefinition($field_name, array $schema) {
         $property_definitions[$column] = $this->createMock('Drupal\Core\TypedData\DataDefinitionInterface');
         $property_definitions[$column]->expects($this->any())
           ->method('isRequired')
-          ->will($this->returnValue(!empty($info['not null'])));
+          ->willReturn(!empty($info['not null']));
       }
       $this->storageDefinitions[$field_name]->expects($this->any())
         ->method('getPropertyDefinitions')
-        ->will($this->returnValue($property_definitions));
+        ->willReturn($property_definitions);
     }
   }
 
@@ -1520,7 +1520,7 @@ public function testonEntityTypeUpdateWithNewIndex() {
 
     $this->storageSchema->expects($this->any())
       ->method('getTableMapping')
-      ->will($this->returnValue($table_mapping));
+      ->willReturn($table_mapping);
 
     $this->storageSchema->expects($this->any())
       ->method('loadEntitySchemaData')
diff --git a/core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageTest.php b/core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageTest.php
index 2f5db5ad0a2c9de9c2317a64c311caae13899ec9..185a68eda056e06b159c41095dcad85902db9b77 100644
--- a/core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageTest.php
+++ b/core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageTest.php
@@ -118,7 +118,7 @@ protected function setUp(): void {
     $this->entityType = $this->createMock('Drupal\Core\Entity\ContentEntityTypeInterface');
     $this->entityType->expects($this->any())
       ->method('id')
-      ->will($this->returnValue($this->entityTypeId));
+      ->willReturn($this->entityTypeId);
 
     $this->container = new ContainerBuilder();
     \Drupal::setContainer($this->container);
@@ -131,7 +131,7 @@ protected function setUp(): void {
     $this->languageManager = $this->createMock('Drupal\Core\Language\LanguageManagerInterface');
     $this->languageManager->expects($this->any())
       ->method('getDefaultLanguage')
-      ->will($this->returnValue(new Language(['langcode' => 'en'])));
+      ->willReturn(new Language(['langcode' => 'en']));
     $this->connection = $this->getMockBuilder('Drupal\Core\Database\Connection')
       ->disableOriginalConstructor()
       ->getMock();
@@ -199,10 +199,10 @@ public function providerTestGetBaseTable() {
   public function testGetRevisionTable($revision_table, $expected) {
     $this->entityType->expects($this->any())
       ->method('isRevisionable')
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
     $this->entityType->expects($this->once())
       ->method('getRevisionTable')
-      ->will($this->returnValue($revision_table));
+      ->willReturn($revision_table);
     $this->entityType->expects($this->any())
       ->method('getRevisionMetadataKeys')
       ->willReturn([]);
@@ -240,10 +240,10 @@ public function providerTestGetRevisionTable() {
   public function testGetDataTable() {
     $this->entityType->expects($this->any())
       ->method('isTranslatable')
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
     $this->entityType->expects($this->exactly(1))
       ->method('getDataTable')
-      ->will($this->returnValue('entity_test_field_data'));
+      ->willReturn('entity_test_field_data');
     $this->entityType->expects($this->any())
       ->method('getRevisionMetadataKeys')
       ->willReturn([]);
@@ -270,16 +270,16 @@ public function testGetDataTable() {
   public function testGetRevisionDataTable($revision_data_table, $expected) {
     $this->entityType->expects($this->any())
       ->method('isRevisionable')
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
     $this->entityType->expects($this->any())
       ->method('isTranslatable')
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
     $this->entityType->expects($this->exactly(1))
       ->method('getDataTable')
-      ->will($this->returnValue('entity_test_field_data'));
+      ->willReturn('entity_test_field_data');
     $this->entityType->expects($this->once())
       ->method('getRevisionDataTable')
-      ->will($this->returnValue($revision_data_table));
+      ->willReturn($revision_data_table);
     $this->entityType->expects($this->any())
       ->method('getRevisionMetadataKeys')
       ->willReturn([]);
@@ -317,10 +317,10 @@ public function providerTestGetRevisionDataTable() {
   public function testSetTableMapping() {
     $this->entityType->expects($this->any())
       ->method('isRevisionable')
-      ->will($this->returnValue(FALSE));
+      ->willReturn(FALSE);
     $this->entityType->expects($this->any())
       ->method('isTranslatable')
-      ->will($this->returnValue(FALSE));
+      ->willReturn(FALSE);
     $this->entityType->expects($this->any())
       ->method('getRevisionMetadataKeys')
       ->willReturn([]);
@@ -337,13 +337,13 @@ public function testSetTableMapping() {
     $updated_entity_type = $this->createMock('Drupal\Core\Entity\ContentEntityTypeInterface');
     $updated_entity_type->expects($this->any())
       ->method('id')
-      ->will($this->returnValue($this->entityTypeId));
+      ->willReturn($this->entityTypeId);
     $updated_entity_type->expects($this->any())
       ->method('isRevisionable')
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
     $updated_entity_type->expects($this->any())
       ->method('isTranslatable')
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
 
     $table_mapping = new DefaultTableMapping($updated_entity_type, []);
     $this->entityStorage->setTableMapping($table_mapping);
@@ -371,14 +371,14 @@ public function testOnEntityTypeCreate() {
     $this->fieldDefinitions = $this->mockFieldDefinitions(['id']);
     $this->fieldDefinitions['id']->expects($this->any())
       ->method('getColumns')
-      ->will($this->returnValue($columns));
+      ->willReturn($columns);
     $this->fieldDefinitions['id']->expects($this->once())
       ->method('getSchema')
-      ->will($this->returnValue(['columns' => $columns]));
+      ->willReturn(['columns' => $columns]);
 
     $this->entityType->expects($this->once())
       ->method('getKeys')
-      ->will($this->returnValue(['id' => 'id']));
+      ->willReturn(['id' => 'id']);
     $this->entityType->expects($this->any())
       ->method('hasKey')
       ->willReturnMap([
@@ -424,7 +424,7 @@ public function testOnEntityTypeCreate() {
 
     $this->connection->expects($this->once())
       ->method('schema')
-      ->will($this->returnValue($schema_handler));
+      ->willReturn($schema_handler);
 
     $storage = $this->getMockBuilder('Drupal\Core\Entity\Sql\SqlContentEntityStorage')
       ->setConstructorArgs([$this->entityType, $this->connection, $this->entityFieldManager, $this->cache, $this->languageManager, new MemoryCache(), $this->entityTypeBundleInfo, $this->entityTypeManager])
@@ -439,12 +439,12 @@ public function testOnEntityTypeCreate() {
     $schema_handler
       ->expects($this->any())
       ->method('installedStorageSchema')
-      ->will($this->returnValue($key_value));
+      ->willReturn($key_value);
 
     $storage
       ->expects($this->any())
       ->method('getStorageSchema')
-      ->will($this->returnValue($schema_handler));
+      ->willReturn($schema_handler);
 
     $storage->onEntityTypeCreate($this->entityType);
   }
@@ -593,7 +593,7 @@ public function testGetTableMappingRevisionable(array $entity_keys) {
 
     $this->entityType->expects($this->exactly(4))
       ->method('isRevisionable')
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
     $this->entityType->expects($this->any())
       ->method('getKey')
       ->willReturnMap([
@@ -604,7 +604,7 @@ public function testGetTableMappingRevisionable(array $entity_keys) {
       ]);
     $this->entityType->expects($this->any())
       ->method('getRevisionMetadataKeys')
-      ->will($this->returnValue([]));
+      ->willReturn([]);
 
     $this->setUpEntityStorage();
 
@@ -666,7 +666,7 @@ public function testGetTableMappingRevisionableWithFields(array $entity_keys) {
 
       $this->entityType->expects($this->exactly(4))
         ->method('isRevisionable')
-        ->will($this->returnValue(TRUE));
+        ->willReturn(TRUE);
       $this->entityType->expects($this->any())
         ->method('getKey')
         ->willReturnMap([
@@ -678,7 +678,7 @@ public function testGetTableMappingRevisionableWithFields(array $entity_keys) {
 
       $this->entityType->expects($this->any())
         ->method('getRevisionMetadataKeys')
-        ->will($this->returnValue($revision_metadata_field_names));
+        ->willReturn($revision_metadata_field_names);
 
       $this->setUpEntityStorage();
 
@@ -717,10 +717,10 @@ public function testGetTableMappingTranslatable(array $entity_keys) {
 
     $this->entityType->expects($this->atLeastOnce())
       ->method('isTranslatable')
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
     $this->entityType->expects($this->atLeastOnce())
       ->method('getDataTable')
-      ->will($this->returnValue('entity_test_field_data'));
+      ->willReturn('entity_test_field_data');
     $this->entityType->expects($this->any())
       ->method('getKey')
       ->willReturnMap([
@@ -777,10 +777,10 @@ public function testGetTableMappingTranslatableWithFields(array $entity_keys) {
 
     $this->entityType->expects($this->atLeastOnce())
       ->method('isTranslatable')
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
     $this->entityType->expects($this->atLeastOnce())
       ->method('getDataTable')
-      ->will($this->returnValue('entity_test_field_data'));
+      ->willReturn('entity_test_field_data');
     $this->entityType->expects($this->any())
       ->method('getKey')
       ->willReturnMap([
@@ -844,13 +844,13 @@ public function testGetTableMappingRevisionableTranslatable(array $entity_keys)
 
     $this->entityType->expects($this->atLeastOnce())
       ->method('isRevisionable')
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
     $this->entityType->expects($this->atLeastOnce())
       ->method('isTranslatable')
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
     $this->entityType->expects($this->atLeastOnce())
       ->method('getDataTable')
-      ->will($this->returnValue('entity_test_field_data'));
+      ->willReturn('entity_test_field_data');
     $this->entityType->expects($this->any())
       ->method('getKey')
       ->willReturnMap([
@@ -862,7 +862,7 @@ public function testGetTableMappingRevisionableTranslatable(array $entity_keys)
       ]);
     $this->entityType->expects($this->any())
       ->method('getRevisionMetadataKeys')
-      ->will($this->returnValue($revision_metadata_keys));
+      ->willReturn($revision_metadata_keys);
 
     $this->fieldDefinitions = $this->mockFieldDefinitions(array_values($revision_metadata_keys), ['isRevisionable' => TRUE]);
 
@@ -971,13 +971,13 @@ public function testGetTableMappingRevisionableTranslatableWithFields(array $ent
 
       $this->entityType->expects($this->atLeastOnce())
         ->method('isRevisionable')
-        ->will($this->returnValue(TRUE));
+        ->willReturn(TRUE);
       $this->entityType->expects($this->atLeastOnce())
         ->method('isTranslatable')
-        ->will($this->returnValue(TRUE));
+        ->willReturn(TRUE);
       $this->entityType->expects($this->atLeastOnce())
         ->method('getDataTable')
-        ->will($this->returnValue('entity_test_field_data'));
+        ->willReturn('entity_test_field_data');
       $this->entityType->expects($this->any())
         ->method('getKey')
         ->willReturnMap([
@@ -989,7 +989,7 @@ public function testGetTableMappingRevisionableTranslatableWithFields(array $ent
         ]);
       $this->entityType->expects($this->any())
         ->method('getRevisionMetadataKeys')
-        ->will($this->returnValue($revision_metadata_field_names));
+        ->willReturn($revision_metadata_field_names);
 
       $this->setUpEntityStorage();
 
@@ -1069,7 +1069,7 @@ public function testCreate() {
     $language = new Language(['id' => 'en']);
     $language_manager->expects($this->any())
       ->method('getCurrentLanguage')
-      ->will($this->returnValue($language));
+      ->willReturn($language);
 
     $entity = $this->getMockBuilder('Drupal\Core\Entity\ContentEntityBase')
       ->disableOriginalConstructor()
@@ -1078,34 +1078,34 @@ public function testCreate() {
 
     $this->entityType->expects($this->atLeastOnce())
       ->method('id')
-      ->will($this->returnValue($this->entityTypeId));
+      ->willReturn($this->entityTypeId);
     $this->entityType->expects($this->atLeastOnce())
       ->method('getClass')
-      ->will($this->returnValue(get_class($entity)));
+      ->willReturn(get_class($entity));
     $this->entityType->expects($this->atLeastOnce())
       ->method('getKeys')
-      ->will($this->returnValue(['id' => 'id']));
+      ->willReturn(['id' => 'id']);
 
     // ContentEntityStorageBase iterates over the entity which calls this method
     // internally in ContentEntityBase::getProperties().
     $this->entityFieldManager->expects($this->once())
       ->method('getFieldDefinitions')
-      ->will($this->returnValue([]));
+      ->willReturn([]);
 
     $this->entityType->expects($this->atLeastOnce())
       ->method('isRevisionable')
-      ->will($this->returnValue(FALSE));
+      ->willReturn(FALSE);
     $this->entityTypeManager->expects($this->atLeastOnce())
       ->method('getDefinition')
       ->with($this->entityType->id())
-      ->will($this->returnValue($this->entityType));
+      ->willReturn($this->entityType);
 
     $this->setUpEntityStorage();
 
     $entity = $this->entityStorage->create();
     $entity->expects($this->atLeastOnce())
       ->method('id')
-      ->will($this->returnValue('foo'));
+      ->willReturn('foo');
 
     $this->assertInstanceOf('Drupal\Core\Entity\EntityInterface', $entity);
     $this->assertSame('foo', $entity->id());
@@ -1136,7 +1136,7 @@ protected function mockFieldDefinitions(array $field_names, $methods = []) {
       $definition
         ->expects($this->any())
         ->method($method)
-        ->will($this->returnValue($result));
+        ->willReturn($result);
     }
 
     // Assign field names to mock definitions.
@@ -1145,7 +1145,7 @@ protected function mockFieldDefinitions(array $field_names, $methods = []) {
       $field_definitions[$field_name]
         ->expects($this->any())
         ->method('getName')
-        ->will($this->returnValue($field_name));
+        ->willReturn($field_name);
     }
 
     return $field_definitions;
@@ -1161,19 +1161,19 @@ protected function setUpEntityStorage() {
 
     $this->entityTypeManager->expects($this->any())
       ->method('getDefinition')
-      ->will($this->returnValue($this->entityType));
+      ->willReturn($this->entityType);
 
     $this->entityTypeManager->expects($this->any())
       ->method('getActiveDefinition')
-      ->will($this->returnValue($this->entityType));
+      ->willReturn($this->entityType);
 
     $this->entityFieldManager->expects($this->any())
       ->method('getFieldStorageDefinitions')
-      ->will($this->returnValue($this->fieldDefinitions));
+      ->willReturn($this->fieldDefinitions);
 
     $this->entityFieldManager->expects($this->any())
       ->method('getActiveFieldStorageDefinitions')
-      ->will($this->returnValue($this->fieldDefinitions));
+      ->willReturn($this->fieldDefinitions);
 
     $this->entityStorage = new SqlContentEntityStorage($this->entityType, $this->connection, $this->entityFieldManager, $this->cache, $this->languageManager, new MemoryCache(), $this->entityTypeBundleInfo, $this->entityTypeManager);
     $this->entityStorage->setModuleHandler($this->moduleHandler);
@@ -1193,19 +1193,19 @@ public function testLoadMultiplePersistentCached() {
       ->getMockForAbstractClass();
     $entity->expects($this->any())
       ->method('id')
-      ->will($this->returnValue($id));
+      ->willReturn($id);
 
     $this->entityType->expects($this->atLeastOnce())
       ->method('isPersistentlyCacheable')
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
     $this->entityType->expects($this->atLeastOnce())
       ->method('id')
-      ->will($this->returnValue($this->entityTypeId));
+      ->willReturn($this->entityTypeId);
 
     $this->cache->expects($this->once())
       ->method('getMultiple')
       ->with([$key])
-      ->will($this->returnValue([$key => (object) ['data' => $entity]]));
+      ->willReturn([$key => (object) ['data' => $entity]]);
     $this->cache->expects($this->never())
       ->method('set');
 
@@ -1228,14 +1228,14 @@ public function testLoadMultipleNoPersistentCache() {
       ->getMockForAbstractClass();
     $entity->expects($this->any())
       ->method('id')
-      ->will($this->returnValue($id));
+      ->willReturn($id);
 
     $this->entityType->expects($this->any())
       ->method('isPersistentlyCacheable')
-      ->will($this->returnValue(FALSE));
+      ->willReturn(FALSE);
     $this->entityType->expects($this->atLeastOnce())
       ->method('id')
-      ->will($this->returnValue($this->entityTypeId));
+      ->willReturn($this->entityTypeId);
 
     // There should be no calls to the cache backend for an entity type without
     // persistent caching.
@@ -1246,7 +1246,7 @@ public function testLoadMultipleNoPersistentCache() {
 
     $this->entityTypeManager->expects($this->any())
       ->method('getActiveDefinition')
-      ->will($this->returnValue($this->entityType));
+      ->willReturn($this->entityType);
 
     $entity_storage = $this->getMockBuilder('Drupal\Core\Entity\Sql\SqlContentEntityStorage')
       ->setConstructorArgs([$this->entityType, $this->connection, $this->entityFieldManager, $this->cache, $this->languageManager, new MemoryCache(), $this->entityTypeBundleInfo, $this->entityTypeManager])
@@ -1259,7 +1259,7 @@ public function testLoadMultipleNoPersistentCache() {
     $entity_storage->expects($this->once())
       ->method('getFromStorage')
       ->with([$id])
-      ->will($this->returnValue([$id => $entity]));
+      ->willReturn([$id => $entity]);
 
     $entities = $entity_storage->loadMultiple([$id]);
     $this->assertEquals($entity, $entities[$id]);
@@ -1279,14 +1279,14 @@ public function testLoadMultiplePersistentCacheMiss() {
       ->getMockForAbstractClass();
     $entity->expects($this->any())
       ->method('id')
-      ->will($this->returnValue($id));
+      ->willReturn($id);
 
     $this->entityType->expects($this->any())
       ->method('isPersistentlyCacheable')
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
     $this->entityType->expects($this->atLeastOnce())
       ->method('id')
-      ->will($this->returnValue($this->entityTypeId));
+      ->willReturn($this->entityTypeId);
 
     // In case of a cache miss, the entity is loaded from the storage and then
     // set in the cache.
@@ -1294,14 +1294,14 @@ public function testLoadMultiplePersistentCacheMiss() {
     $this->cache->expects($this->once())
       ->method('getMultiple')
       ->with([$key])
-      ->will($this->returnValue([]));
+      ->willReturn([]);
     $this->cache->expects($this->once())
       ->method('set')
       ->with($key, $entity, CacheBackendInterface::CACHE_PERMANENT, [$this->entityTypeId . '_values', 'entity_field_info']);
 
     $this->entityTypeManager->expects($this->any())
       ->method('getActiveDefinition')
-      ->will($this->returnValue($this->entityType));
+      ->willReturn($this->entityType);
 
     $entity_storage = $this->getMockBuilder('Drupal\Core\Entity\Sql\SqlContentEntityStorage')
       ->setConstructorArgs([$this->entityType, $this->connection, $this->entityFieldManager, $this->cache, $this->languageManager, new MemoryCache(), $this->entityTypeBundleInfo, $this->entityTypeManager])
@@ -1314,7 +1314,7 @@ public function testLoadMultiplePersistentCacheMiss() {
     $entity_storage->expects($this->once())
       ->method('getFromStorage')
       ->with([$id])
-      ->will($this->returnValue([$id => $entity]));
+      ->willReturn([$id => $entity]);
 
     $entities = $entity_storage->loadMultiple([$id]);
     $this->assertEquals($entity, $entities[$id]);
@@ -1351,19 +1351,19 @@ public function testHasData() {
 
     $this->entityTypeManager->expects($this->any())
       ->method('getDefinition')
-      ->will($this->returnValue($this->entityType));
+      ->willReturn($this->entityType);
 
     $this->entityTypeManager->expects($this->any())
       ->method('getActiveDefinition')
-      ->will($this->returnValue($this->entityType));
+      ->willReturn($this->entityType);
 
     $this->entityFieldManager->expects($this->any())
       ->method('getFieldStorageDefinitions')
-      ->will($this->returnValue($this->fieldDefinitions));
+      ->willReturn($this->fieldDefinitions);
 
     $this->entityFieldManager->expects($this->any())
       ->method('getActiveFieldStorageDefinitions')
-      ->will($this->returnValue($this->fieldDefinitions));
+      ->willReturn($this->fieldDefinitions);
 
     $this->entityStorage = new SqlContentEntityStorage($this->entityType, $database, $this->entityFieldManager, $this->cache, $this->languageManager, new MemoryCache(), $this->entityTypeBundleInfo, $this->entityTypeManager);
 
@@ -1409,7 +1409,7 @@ public function testCleanIds() {
     $this->fieldDefinitions = $this->mockFieldDefinitions(['id']);
     $this->fieldDefinitions['id']->expects($this->any())
       ->method('getType')
-      ->will($this->returnValue('integer'));
+      ->willReturn('integer');
 
     $this->setUpEntityStorage();
 
diff --git a/core/tests/Drupal/Tests/Core/Entity/TypedData/EntityAdapterUnitTest.php b/core/tests/Drupal/Tests/Core/Entity/TypedData/EntityAdapterUnitTest.php
index 7c8aa9bc7ff4c6a54d51866c66dc5ba0620e66ae..d515a5be684f4f9f671f26c5538da06db0727b9e 100644
--- a/core/tests/Drupal/Tests/Core/Entity/TypedData/EntityAdapterUnitTest.php
+++ b/core/tests/Drupal/Tests/Core/Entity/TypedData/EntityAdapterUnitTest.php
@@ -133,16 +133,16 @@ protected function setUp(): void {
     $this->entityType = $this->createMock('\Drupal\Core\Entity\EntityTypeInterface');
     $this->entityType->expects($this->any())
       ->method('getKeys')
-      ->will($this->returnValue([
+      ->willReturn([
         'id' => 'id',
         'uuid' => 'uuid',
-      ]));
+      ]);
 
     $this->entityTypeManager = $this->createMock(EntityTypeManagerInterface::class);
     $this->entityTypeManager->expects($this->any())
       ->method('getDefinition')
       ->with($this->entityTypeId)
-      ->will($this->returnValue($this->entityType));
+      ->willReturn($this->entityType);
 
     $this->uuid = $this->createMock('\Drupal\Component\Uuid\UuidInterface');
 
@@ -150,7 +150,7 @@ protected function setUp(): void {
     $this->typedDataManager->expects($this->any())
       ->method('getDefinition')
       ->with('entity')
-      ->will($this->returnValue(['class' => '\Drupal\Core\Entity\Plugin\DataType\EntityAdapter']));
+      ->willReturn(['class' => '\Drupal\Core\Entity\Plugin\DataType\EntityAdapter']);
     $this->typedDataManager->expects($this->any())
       ->method('getDefaultConstraints')
       ->willReturn([]);
@@ -169,22 +169,22 @@ protected function setUp(): void {
     $this->languageManager = $this->createMock('\Drupal\Core\Language\LanguageManagerInterface');
     $this->languageManager->expects($this->any())
       ->method('getLanguages')
-      ->will($this->returnValue([LanguageInterface::LANGCODE_NOT_SPECIFIED => $not_specified]));
+      ->willReturn([LanguageInterface::LANGCODE_NOT_SPECIFIED => $not_specified]);
 
     $this->languageManager->expects($this->any())
       ->method('getLanguage')
       ->with(LanguageInterface::LANGCODE_NOT_SPECIFIED)
-      ->will($this->returnValue($not_specified));
+      ->willReturn($not_specified);
 
     $this->fieldTypePluginManager = $this->getMockBuilder('\Drupal\Core\Field\FieldTypePluginManager')
       ->disableOriginalConstructor()
       ->getMock();
     $this->fieldTypePluginManager->expects($this->any())
       ->method('getDefaultStorageSettings')
-      ->will($this->returnValue([]));
+      ->willReturn([]);
     $this->fieldTypePluginManager->expects($this->any())
       ->method('getDefaultFieldSettings')
-      ->will($this->returnValue([]));
+      ->willReturn([]);
 
     $this->fieldItemList = $this->createMock('\Drupal\Core\Field\FieldItemListInterface');
     $this->fieldTypePluginManager->expects($this->any())
@@ -209,7 +209,7 @@ protected function setUp(): void {
     $this->entityFieldManager->expects($this->any())
       ->method('getFieldDefinitions')
       ->with($this->entityTypeId, $this->bundle)
-      ->will($this->returnValue($this->fieldDefinitions));
+      ->willReturn($this->fieldDefinitions);
 
     $this->entity = $this->getMockForAbstractClass('\Drupal\Core\Entity\ContentEntityBase', [$values, $this->entityTypeId, $this->bundle]);
 
diff --git a/core/tests/Drupal/Tests/Core/Extension/ModuleHandlerTest.php b/core/tests/Drupal/Tests/Core/Extension/ModuleHandlerTest.php
index 1859b84cf769b4fa8591927e7352454c13076a93..c989ea870db378c9cc0e7bbaa4993267a1ed2c0f 100644
--- a/core/tests/Drupal/Tests/Core/Extension/ModuleHandlerTest.php
+++ b/core/tests/Drupal/Tests/Core/Extension/ModuleHandlerTest.php
@@ -452,7 +452,7 @@ public function testWriteCache() {
     $this->cacheBackend
       ->expects($this->exactly(2))
       ->method('get')
-      ->will($this->returnValue(NULL));
+      ->willReturn(NULL);
     $this->cacheBackend
       ->expects($this->exactly(2))
       ->method('set')
diff --git a/core/tests/Drupal/Tests/Core/Extension/ThemeHandlerTest.php b/core/tests/Drupal/Tests/Core/Extension/ThemeHandlerTest.php
index c06d828c84828d6e464fec8d6f064c0352ff66eb..4435380e6fc12c446d3a2172c1723b055db1d1e6 100644
--- a/core/tests/Drupal/Tests/Core/Extension/ThemeHandlerTest.php
+++ b/core/tests/Drupal/Tests/Core/Extension/ThemeHandlerTest.php
@@ -64,7 +64,7 @@ protected function setUp(): void {
     $container->expects($this->any())
       ->method('get')
       ->with('class_loader')
-      ->will($this->returnValue($this->createMock(ClassLoader::class)));
+      ->willReturn($this->createMock(ClassLoader::class));
     \Drupal::setContainer($container);
   }
 
@@ -79,9 +79,9 @@ public function testRebuildThemeData() {
       ->willReturnSelf();
     $this->themeList->expects($this->once())
       ->method('getList')
-      ->will($this->returnValue([
+      ->willReturn([
         'stark' => new Extension($this->root, 'theme', 'core/themes/stark/stark.info.yml', 'stark.theme'),
-      ]));
+      ]);
 
     $theme_data = $this->themeHandler->rebuildThemeData();
     $this->assertCount(1, $theme_data);
diff --git a/core/tests/Drupal/Tests/Core/Field/BaseFieldDefinitionTestBase.php b/core/tests/Drupal/Tests/Core/Field/BaseFieldDefinitionTestBase.php
index fa26aec4f690713e6a5f0b535544f189bb82e1b5..c2f45ae311805558e007dafa07cf1d1afbbc0a14 100644
--- a/core/tests/Drupal/Tests/Core/Field/BaseFieldDefinitionTestBase.php
+++ b/core/tests/Drupal/Tests/Core/Field/BaseFieldDefinitionTestBase.php
@@ -36,7 +36,7 @@ protected function setUp(): void {
     $module_handler->expects($this->once())
       ->method('moduleExists')
       ->with($module_name)
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
     $typed_data_manager = $this->createMock(TypedDataManagerInterface::class);
     $plugin_manager = new FieldTypePluginManager(
       $namespaces,
diff --git a/core/tests/Drupal/Tests/Core/Field/FieldItemListTest.php b/core/tests/Drupal/Tests/Core/Field/FieldItemListTest.php
index b213a2076f32430d3142471991e51f37915e94ea..a49f269aa50480243ecfa555661b7855b5e6a2ba 100644
--- a/core/tests/Drupal/Tests/Core/Field/FieldItemListTest.php
+++ b/core/tests/Drupal/Tests/Core/Field/FieldItemListTest.php
@@ -47,7 +47,7 @@ public function testEquals($expected, FieldItemInterface $first_field_item = NUL
     $field_storage_definition = $this->createMock('Drupal\Core\Field\FieldStorageDefinitionInterface');
     $field_storage_definition->expects($this->any())
       ->method('getPropertyDefinitions')
-      ->will($this->returnValue($property_definitions));
+      ->willReturn($property_definitions);
     $field_definition = $this->createMock('Drupal\Core\Field\FieldDefinitionInterface');
     $field_definition->expects($this->any())
       ->method('getFieldStorageDefinition')
@@ -193,7 +193,7 @@ public function testHasAffectingChanges($expected, FieldItemInterface $first_fie
     $field_storage_definition = $this->createMock('Drupal\Core\Field\FieldStorageDefinitionInterface');
     $field_storage_definition->expects($this->any())
       ->method('getPropertyDefinitions')
-      ->will($this->returnValue($property_definitions));
+      ->willReturn($property_definitions);
 
     $field_definition = $this->createMock(FieldDefinitionInterface::class);
     $field_definition->expects($this->any())
@@ -251,7 +251,7 @@ public function testEqualsEmptyItems() {
     $field_storage_definition = $this->createMock('Drupal\Core\Field\FieldStorageDefinitionInterface');
     $field_storage_definition->expects($this->any())
       ->method('getPropertyDefinitions')
-      ->will($this->returnValue($property_definitions));
+      ->willReturn($property_definitions);
     $field_definition = $this->createMock('Drupal\Core\Field\FieldDefinitionInterface');
     $field_definition->expects($this->any())
       ->method('getFieldStorageDefinition')
diff --git a/core/tests/Drupal/Tests/Core/Form/ConfirmFormHelperTest.php b/core/tests/Drupal/Tests/Core/Form/ConfirmFormHelperTest.php
index b7f78627fcc49359999d28a1f4ce9ac155919c63..f50abc1253915dff7399435ac9a1e902406fc8d0 100644
--- a/core/tests/Drupal/Tests/Core/Form/ConfirmFormHelperTest.php
+++ b/core/tests/Drupal/Tests/Core/Form/ConfirmFormHelperTest.php
@@ -24,7 +24,7 @@ public function testCancelLinkTitle() {
     $form = $this->createMock('Drupal\Core\Form\ConfirmFormInterface');
     $form->expects($this->any())
       ->method('getCancelText')
-      ->will($this->returnValue($cancel_text));
+      ->willReturn($cancel_text);
 
     $link = ConfirmFormHelper::buildCancelLink($form, new Request());
     $this->assertSame($cancel_text, $link['#title']);
@@ -42,7 +42,7 @@ public function testCancelLinkRoute() {
     $form = $this->createMock('Drupal\Core\Form\ConfirmFormInterface');
     $form->expects($this->any())
       ->method('getCancelUrl')
-      ->will($this->returnValue($cancel_route));
+      ->willReturn($cancel_route);
     $link = ConfirmFormHelper::buildCancelLink($form, new Request());
     $this->assertEquals(Url::fromRoute($route_name), $link['#url']);
     $this->assertSame(['contexts' => ['url.query_args:destination']], $link['#cache']);
@@ -58,7 +58,7 @@ public function testCancelLinkRouteWithParams() {
     $form = $this->createMock('Drupal\Core\Form\ConfirmFormInterface');
     $form->expects($this->any())
       ->method('getCancelUrl')
-      ->will($this->returnValue($expected));
+      ->willReturn($expected);
     $link = ConfirmFormHelper::buildCancelLink($form, new Request());
     $this->assertEquals($expected, $link['#url']);
     $this->assertSame(['contexts' => ['url.query_args:destination']], $link['#cache']);
@@ -81,7 +81,7 @@ public function testCancelLinkRouteWithUrl() {
     $form = $this->createMock('Drupal\Core\Form\ConfirmFormInterface');
     $form->expects($this->any())
       ->method('getCancelUrl')
-      ->will($this->returnValue($cancel_route));
+      ->willReturn($cancel_route);
     $link = ConfirmFormHelper::buildCancelLink($form, new Request());
     $this->assertSame($cancel_route, $link['#url']);
     $this->assertSame(['contexts' => ['url.query_args:destination']], $link['#cache']);
diff --git a/core/tests/Drupal/Tests/Core/Form/FormBuilderTest.php b/core/tests/Drupal/Tests/Core/Form/FormBuilderTest.php
index ae287334bec7e9a1f3742a86929395b473fa1b7b..ebdf4b54932cd2ed2c3fc7d835c89b91c9b3f0c0 100644
--- a/core/tests/Drupal/Tests/Core/Form/FormBuilderTest.php
+++ b/core/tests/Drupal/Tests/Core/Form/FormBuilderTest.php
@@ -116,10 +116,10 @@ public function testGetFormIdWithBaseForm() {
     $form_arg = $this->createMock('Drupal\Core\Form\BaseFormIdInterface');
     $form_arg->expects($this->once())
       ->method('getFormId')
-      ->will($this->returnValue($expected_form_id));
+      ->willReturn($expected_form_id);
     $form_arg->expects($this->once())
       ->method('getBaseFormId')
-      ->will($this->returnValue($base_form_id));
+      ->willReturn($base_form_id);
 
     $form_state = new FormState();
     $form_id = $this->formBuilder->getFormId($form_arg, $form_state);
@@ -349,10 +349,10 @@ public function testRebuildForm() {
     $form_arg = $this->createMock('Drupal\Core\Form\FormInterface');
     $form_arg->expects($this->exactly(2))
       ->method('getFormId')
-      ->will($this->returnValue($form_id));
+      ->willReturn($form_id);
     $form_arg->expects($this->exactly(4))
       ->method('buildForm')
-      ->will($this->returnValue($expected_form));
+      ->willReturn($expected_form);
 
     // Do an initial build of the form and track the build ID.
     $form_state = new FormState();
@@ -389,10 +389,10 @@ public function testRebuildFormOnGetRequest() {
     $form_arg = $this->createMock('Drupal\Core\Form\FormInterface');
     $form_arg->expects($this->exactly(2))
       ->method('getFormId')
-      ->will($this->returnValue($form_id));
+      ->willReturn($form_id);
     $form_arg->expects($this->exactly(4))
       ->method('buildForm')
-      ->will($this->returnValue($expected_form));
+      ->willReturn($expected_form);
 
     // Do an initial build of the form and track the build ID.
     $form_state = new FormState();
@@ -429,10 +429,10 @@ public function testGetCache() {
     $form_arg = $this->createMock('Drupal\Core\Form\FormInterface');
     $form_arg->expects($this->exactly(2))
       ->method('getFormId')
-      ->will($this->returnValue($form_id));
+      ->willReturn($form_id);
     $form_arg->expects($this->once())
       ->method('buildForm')
-      ->will($this->returnValue($expected_form));
+      ->willReturn($expected_form);
 
     // Do an initial build of the form and track the build ID.
     $form_state = (new FormState())
@@ -471,10 +471,10 @@ public function testUniqueHtmlId() {
     $form_arg = $this->createMock('Drupal\Core\Form\FormInterface');
     $form_arg->expects($this->exactly(2))
       ->method('getFormId')
-      ->will($this->returnValue($form_id));
+      ->willReturn($form_id);
     $form_arg->expects($this->exactly(2))
       ->method('buildForm')
-      ->will($this->returnValue($expected_form));
+      ->willReturn($expected_form);
 
     $form_state = new FormState();
     $form = $this->simulateFormSubmission($form_id, $form_arg, $form_state);
@@ -497,17 +497,17 @@ public function testUniqueElementHtmlId() {
     $form_arg_1 = $this->createMock('Drupal\Core\Form\FormInterface');
     $form_arg_1->expects($this->exactly(1))
       ->method('getFormId')
-      ->will($this->returnValue($form_id_1));
+      ->willReturn($form_id_1);
     $form_arg_1->expects($this->exactly(1))
       ->method('buildForm')
-      ->will($this->returnValue($expected_form));
+      ->willReturn($expected_form);
     $form_arg_2 = $this->createMock('Drupal\Core\Form\FormInterface');
     $form_arg_2->expects($this->exactly(1))
       ->method('getFormId')
-      ->will($this->returnValue($form_id_2));
+      ->willReturn($form_id_2);
     $form_arg_2->expects($this->exactly(1))
       ->method('buildForm')
-      ->will($this->returnValue($expected_form));
+      ->willReturn($expected_form);
     $form_state = new FormState();
     $form_1 = $this->simulateFormSubmission($form_id_1, $form_arg_1, $form_state);
     $form_state = new FormState();
@@ -890,10 +890,10 @@ public function testFormTokenCacheability($token, $is_authenticated, $expected_f
     $form_arg = $this->createMock('Drupal\Core\Form\FormInterface');
     $form_arg->expects($this->once())
       ->method('getFormId')
-      ->will($this->returnValue($form_id));
+      ->willReturn($form_id);
     $form_arg->expects($this->once())
       ->method('buildForm')
-      ->will($this->returnValue($form));
+      ->willReturn($form);
 
     $form_state = new FormState();
     $built_form = $this->formBuilder->buildForm($form_arg, $form_state);
diff --git a/core/tests/Drupal/Tests/Core/Form/FormSubmitterTest.php b/core/tests/Drupal/Tests/Core/Form/FormSubmitterTest.php
index a50b728b9994ccadd4077263eed9d43d792af695..f55722f84860f789e6b0f1df40652a6f045b18ab 100644
--- a/core/tests/Drupal/Tests/Core/Form/FormSubmitterTest.php
+++ b/core/tests/Drupal/Tests/Core/Form/FormSubmitterTest.php
@@ -80,7 +80,7 @@ public function testHandleFormSubmissionWithResponses($class, $form_state_key) {
       ->getMock();
     $response->expects($this->any())
       ->method('prepare')
-      ->will($this->returnValue($response));
+      ->willReturn($response);
 
     $form_state = (new FormState())
       ->setSubmitted()
diff --git a/core/tests/Drupal/Tests/Core/Form/FormTestBase.php b/core/tests/Drupal/Tests/Core/Form/FormTestBase.php
index d9d5392035d83aa6a6ed5658235e12b5a8f12913..f10f79be833cc362ac43d5c8eb5693e76693826f 100644
--- a/core/tests/Drupal/Tests/Core/Form/FormTestBase.php
+++ b/core/tests/Drupal/Tests/Core/Form/FormTestBase.php
@@ -217,12 +217,12 @@ protected function getMockForm($form_id, $expected_form = NULL, $count = 1) {
     $form = $this->createMock('Drupal\Core\Form\FormInterface');
     $form->expects($this->once())
       ->method('getFormId')
-      ->will($this->returnValue($form_id));
+      ->willReturn($form_id);
 
     if ($expected_form) {
       $form->expects($this->exactly($count))
         ->method('buildForm')
-        ->will($this->returnValue($expected_form));
+        ->willReturn($expected_form);
     }
     return $form;
   }
diff --git a/core/tests/Drupal/Tests/Core/Form/FormValidatorTest.php b/core/tests/Drupal/Tests/Core/Form/FormValidatorTest.php
index 016d3691699c3545ae5fb75039065ecc0fbe1573..eccceecc59b4119485c918c80840c8b83f989b0e 100644
--- a/core/tests/Drupal/Tests/Core/Form/FormValidatorTest.php
+++ b/core/tests/Drupal/Tests/Core/Form/FormValidatorTest.php
@@ -114,7 +114,7 @@ public function testValidateInvalidFormToken() {
     $request_stack->push($request);
     $this->csrfToken->expects($this->once())
       ->method('validate')
-      ->will($this->returnValue(FALSE));
+      ->willReturn(FALSE);
 
     $form_validator = $this->getMockBuilder('Drupal\Core\Form\FormValidator')
       ->setConstructorArgs([$request_stack, $this->getStringTranslationStub(), $this->csrfToken, $this->logger, $this->formErrorHandler])
@@ -142,7 +142,7 @@ public function testValidateValidFormToken() {
     $request_stack = new RequestStack();
     $this->csrfToken->expects($this->once())
       ->method('validate')
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
 
     $form_validator = $this->getMockBuilder('Drupal\Core\Form\FormValidator')
       ->setConstructorArgs([$request_stack, $this->getStringTranslationStub(), $this->csrfToken, $this->logger, $this->formErrorHandler])
diff --git a/core/tests/Drupal/Tests/Core/Image/ImageTest.php b/core/tests/Drupal/Tests/Core/Image/ImageTest.php
index e0a15e2a8260e010a87debf97520b432852c0db7..4f892fa3a0638070c483ce01a127a4c3243ac2aa 100644
--- a/core/tests/Drupal/Tests/Core/Image/ImageTest.php
+++ b/core/tests/Drupal/Tests/Core/Image/ImageTest.php
@@ -108,7 +108,7 @@ protected function getTestImage($load_expected = TRUE, array $stubs = []) {
 
     $this->toolkit->expects($this->any())
       ->method('getPluginId')
-      ->will($this->returnValue('gd'));
+      ->willReturn('gd');
 
     if (!$load_expected) {
       $this->toolkit->expects($this->never())
@@ -135,11 +135,11 @@ protected function getTestImageForOperation($class_name) {
 
     $this->toolkit->expects($this->any())
       ->method('getPluginId')
-      ->will($this->returnValue('gd'));
+      ->willReturn('gd');
 
     $this->toolkit->expects($this->any())
       ->method('getToolkitOperation')
-      ->will($this->returnValue($this->toolkitOperation));
+      ->willReturn($this->toolkitOperation);
 
     $this->image = new Image($this->toolkit, $this->source);
 
@@ -212,7 +212,7 @@ public function testSave() {
     $toolkit = $this->getToolkitMock();
     $toolkit->expects($this->once())
       ->method('save')
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
 
     $image = new Image($toolkit, $this->image->getSource());
 
@@ -240,7 +240,7 @@ public function testSaveFails() {
     // This will fail if save() method isn't called on the toolkit.
     $this->toolkit->expects($this->once())
       ->method('save')
-      ->will($this->returnValue(FALSE));
+      ->willReturn(FALSE);
 
     $this->assertFalse($this->image->save());
   }
@@ -254,7 +254,7 @@ public function testChmodFails() {
     $toolkit = $this->getToolkitMock();
     $toolkit->expects($this->once())
       ->method('save')
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
 
     $image = new Image($toolkit, $this->image->getSource());
 
diff --git a/core/tests/Drupal/Tests/Core/Language/LanguageUnitTest.php b/core/tests/Drupal/Tests/Core/Language/LanguageUnitTest.php
index a4c5aa5f051baa2793934d79bf24749f96d1bff9..f7e146f47804603957f439e8a6663706fe70d8f4 100644
--- a/core/tests/Drupal/Tests/Core/Language/LanguageUnitTest.php
+++ b/core/tests/Drupal/Tests/Core/Language/LanguageUnitTest.php
@@ -63,7 +63,7 @@ public function testIsDefault() {
     $container->expects($this->any())
       ->method('get')
       ->with('language.default')
-      ->will($this->returnValue($language_default));
+      ->willReturn($language_default);
     \Drupal::setContainer($container);
 
     $language = new Language(['id' => $this->randomMachineName(2)]);
diff --git a/core/tests/Drupal/Tests/Core/Lock/LockBackendAbstractTest.php b/core/tests/Drupal/Tests/Core/Lock/LockBackendAbstractTest.php
index efae04ea67bc17e1a7c91e2587a6a17f7d9f0812..be95c518ad182a686b7e53b4568a2ea67eabe98b 100644
--- a/core/tests/Drupal/Tests/Core/Lock/LockBackendAbstractTest.php
+++ b/core/tests/Drupal/Tests/Core/Lock/LockBackendAbstractTest.php
@@ -31,7 +31,7 @@ public function testWaitFalse() {
     $this->lock->expects($this->any())
       ->method('lockMayBeAvailable')
       ->with($this->equalTo('test_name'))
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
 
     $this->assertFalse($this->lock->wait('test_name'));
   }
@@ -46,7 +46,7 @@ public function testWaitTrue() {
     $this->lock->expects($this->any())
       ->method('lockMayBeAvailable')
       ->with($this->equalTo('test_name'))
-      ->will($this->returnValue(FALSE));
+      ->willReturn(FALSE);
 
     $this->assertTrue($this->lock->wait('test_name', 1));
   }
diff --git a/core/tests/Drupal/Tests/Core/Logger/LoggerChannelTest.php b/core/tests/Drupal/Tests/Core/Logger/LoggerChannelTest.php
index fc4727c999527801b3eb16a17cc82520c288fe74..fb4eb47acc0678fedfb3abf5fd335249b6b1f005 100644
--- a/core/tests/Drupal/Tests/Core/Logger/LoggerChannelTest.php
+++ b/core/tests/Drupal/Tests/Core/Logger/LoggerChannelTest.php
@@ -137,14 +137,14 @@ public function providerTestLog() {
     $account_mock = $this->createMock('Drupal\Core\Session\AccountInterface');
     $account_mock->expects($this->any())
       ->method('id')
-      ->will($this->returnValue(1));
+      ->willReturn(1);
 
     $request_mock = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')
       ->onlyMethods(['getClientIp'])
       ->getMock();
     $request_mock->expects($this->any())
       ->method('getClientIp')
-      ->will($this->returnValue('127.0.0.1'));
+      ->willReturn('127.0.0.1');
     $request_mock->headers = $this->createMock('Symfony\Component\HttpFoundation\ParameterBag');
 
     // No request or account.
diff --git a/core/tests/Drupal/Tests/Core/Mail/MailManagerTest.php b/core/tests/Drupal/Tests/Core/Mail/MailManagerTest.php
index fae456308ea1874d7f2387d5107011677ec33621..814596df60af47e6cf6b82d4a04802ff2059df24 100644
--- a/core/tests/Drupal/Tests/Core/Mail/MailManagerTest.php
+++ b/core/tests/Drupal/Tests/Core/Mail/MailManagerTest.php
@@ -92,7 +92,7 @@ protected function setUp(): void {
     $this->discovery = $this->createMock('Drupal\Component\Plugin\Discovery\DiscoveryInterface');
     $this->discovery->expects($this->any())
       ->method('getDefinitions')
-      ->will($this->returnValue($this->definitions));
+      ->willReturn($this->definitions);
   }
 
   /**
diff --git a/core/tests/Drupal/Tests/Core/Menu/ContextualLinkDefaultTest.php b/core/tests/Drupal/Tests/Core/Menu/ContextualLinkDefaultTest.php
index 051bbbe0bb39f8453254dc3b04b942a09e795b60..49a764680bcf285787acb942b24321e2986ced4f 100644
--- a/core/tests/Drupal/Tests/Core/Menu/ContextualLinkDefaultTest.php
+++ b/core/tests/Drupal/Tests/Core/Menu/ContextualLinkDefaultTest.php
@@ -72,7 +72,7 @@ public function testGetTitle() {
     $this->stringTranslation->expects($this->once())
       ->method('translateString')
       ->with($this->pluginDefinition['title'])
-      ->will($this->returnValue('Example translated'));
+      ->willReturn('Example translated');
 
     $this->setupContextualLinkDefault();
     $this->assertEquals('Example translated', $this->contextualLinkDefault->getTitle());
@@ -87,7 +87,7 @@ public function testGetTitleWithContext() {
     $this->stringTranslation->expects($this->once())
       ->method('translateString')
       ->with($this->pluginDefinition['title'])
-      ->will($this->returnValue('Example translated with context'));
+      ->willReturn('Example translated with context');
 
     $this->setupContextualLinkDefault();
     $this->assertEquals('Example translated with context', $this->contextualLinkDefault->getTitle());
@@ -102,7 +102,7 @@ public function testGetTitleWithTitleArguments() {
     $this->stringTranslation->expects($this->once())
       ->method('translateString')
       ->with($this->pluginDefinition['title'])
-      ->will($this->returnValue('Example value'));
+      ->willReturn('Example value');
 
     $this->setupContextualLinkDefault();
     $request = new Request();
diff --git a/core/tests/Drupal/Tests/Core/Menu/ContextualLinkManagerTest.php b/core/tests/Drupal/Tests/Core/Menu/ContextualLinkManagerTest.php
index 3fc82210a0bc42cfd8f2044a69e0ed7c0e1b1ce0..3dea04ef27216fb0e16c45a0c9608c846ae02ae5 100644
--- a/core/tests/Drupal/Tests/Core/Menu/ContextualLinkManagerTest.php
+++ b/core/tests/Drupal/Tests/Core/Menu/ContextualLinkManagerTest.php
@@ -69,7 +69,7 @@ protected function setUp(): void {
     $language_manager = $this->createMock(LanguageManagerInterface::class);
     $language_manager->expects($this->any())
       ->method('getCurrentLanguage')
-      ->will($this->returnValue(new Language(['id' => 'en'])));
+      ->willReturn(new Language(['id' => 'en']));
 
     $this->moduleHandler = $this->createMock(ModuleHandlerInterface::class);
     $this->moduleHandler->expects($this->any())
@@ -124,7 +124,7 @@ public function testGetContextualLinkPluginsByGroup() {
     ];
     $this->pluginDiscovery->expects($this->once())
       ->method('getDefinitions')
-      ->will($this->returnValue($definitions));
+      ->willReturn($definitions);
 
     // Test with a non existing group.
     $result = $this->contextualLinkManager->getContextualLinkPluginsByGroup('group_non_existing');
@@ -159,7 +159,7 @@ public function testGetContextualLinkPluginsByGroupWithCache() {
     $this->cacheBackend->expects($this->once())
       ->method('get')
       ->with('contextual_links_plugins:en:group1')
-      ->will($this->returnValue((object) ['data' => $definitions]));
+      ->willReturn((object) ['data' => $definitions]);
 
     $result = $this->contextualLinkManager->getContextualLinkPluginsByGroup('group1');
     $this->assertEquals($definitions, $result);
@@ -238,11 +238,11 @@ public function testGetContextualLinksArrayByGroup() {
 
     $this->pluginDiscovery->expects($this->once())
       ->method('getDefinitions')
-      ->will($this->returnValue($definitions));
+      ->willReturn($definitions);
 
     $this->accessManager->expects($this->any())
       ->method('checkNamedRoute')
-      ->will($this->returnValue(AccessResult::allowed()));
+      ->willReturn(AccessResult::allowed());
 
     $this->moduleHandler->expects($this->exactly(2))
       ->method('alter')
@@ -291,7 +291,7 @@ public function testGetContextualLinksArrayByGroupAccessCheck() {
 
     $this->pluginDiscovery->expects($this->once())
       ->method('getDefinitions')
-      ->will($this->returnValue($definitions));
+      ->willReturn($definitions);
 
     $this->accessManager->expects($this->any())
       ->method('checkNamedRoute')
@@ -323,7 +323,7 @@ public function testPluginDefinitionAlter() {
 
     $this->pluginDiscovery->expects($this->once())
       ->method('getDefinitions')
-      ->will($this->returnValue($definitions));
+      ->willReturn($definitions);
 
     $this->moduleHandler->expects($this->once())
       ->method('alter')
diff --git a/core/tests/Drupal/Tests/Core/Menu/LocalActionDefaultTest.php b/core/tests/Drupal/Tests/Core/Menu/LocalActionDefaultTest.php
index 3ee0850d8f1ac5332df2b9cebade5a008431eebc..de7f2c5c1374249136d75ec81dec640c65705d9e 100644
--- a/core/tests/Drupal/Tests/Core/Menu/LocalActionDefaultTest.php
+++ b/core/tests/Drupal/Tests/Core/Menu/LocalActionDefaultTest.php
@@ -84,7 +84,7 @@ public function testGetTitle() {
     $this->stringTranslation->expects($this->once())
       ->method('translateString')
       ->with($this->pluginDefinition['title'])
-      ->will($this->returnValue('Example translated'));
+      ->willReturn('Example translated');
 
     $this->setupLocalActionDefault();
     $this->assertEquals('Example translated', $this->localActionDefault->getTitle());
@@ -100,7 +100,7 @@ public function testGetTitleWithContext() {
     $this->stringTranslation->expects($this->once())
       ->method('translateString')
       ->with($this->pluginDefinition['title'])
-      ->will($this->returnValue('Example translated with context'));
+      ->willReturn('Example translated with context');
 
     $this->setupLocalActionDefault();
     $this->assertEquals('Example translated with context', $this->localActionDefault->getTitle());
@@ -114,7 +114,7 @@ public function testGetTitleWithTitleArguments() {
     $this->stringTranslation->expects($this->once())
       ->method('translateString')
       ->with($this->pluginDefinition['title'])
-      ->will($this->returnValue('Example value'));
+      ->willReturn('Example value');
 
     $this->setupLocalActionDefault();
     $request = new Request();
diff --git a/core/tests/Drupal/Tests/Core/Menu/LocalActionManagerTest.php b/core/tests/Drupal/Tests/Core/Menu/LocalActionManagerTest.php
index 4bba2d2326f2d1e3fc95337e072f2cca3c1e87a2..7238bbfbe8c1aca46f7e42e9fad3b17456a93a54 100644
--- a/core/tests/Drupal/Tests/Core/Menu/LocalActionManagerTest.php
+++ b/core/tests/Drupal/Tests/Core/Menu/LocalActionManagerTest.php
@@ -146,7 +146,7 @@ public function testGetTitle() {
     $this->argumentResolver->expects($this->once())
       ->method('getArguments')
       ->with($this->request, [$local_action, 'getTitle'])
-      ->will($this->returnValue(['test']));
+      ->willReturn(['test']);
 
     $this->localActionManager->getTitle($local_action);
   }
@@ -159,31 +159,31 @@ public function testGetTitle() {
   public function testGetActionsForRoute($route_appears, array $plugin_definitions, array $expected_actions) {
     $this->discovery->expects($this->any())
       ->method('getDefinitions')
-      ->will($this->returnValue($plugin_definitions));
+      ->willReturn($plugin_definitions);
     $map = [];
     foreach ($plugin_definitions as $plugin_id => $plugin_definition) {
       $plugin = $this->createMock('Drupal\Core\Menu\LocalActionInterface');
       $plugin->expects($this->any())
         ->method('getRouteName')
-        ->will($this->returnValue($plugin_definition['route_name']));
+        ->willReturn($plugin_definition['route_name']);
       $plugin->expects($this->any())
         ->method('getRouteParameters')
-        ->will($this->returnValue($plugin_definition['route_parameters'] ?? []));
+        ->willReturn($plugin_definition['route_parameters'] ?? []);
       $plugin->expects($this->any())
         ->method('getTitle')
-        ->will($this->returnValue($plugin_definition['title']));
+        ->willReturn($plugin_definition['title']);
       $this->argumentResolver->expects($this->any())
         ->method('getArguments')
         ->with($this->request, [$plugin, 'getTitle'])
-        ->will($this->returnValue([]));
+        ->willReturn([]);
 
       $plugin->expects($this->any())
         ->method('getWeight')
-        ->will($this->returnValue($plugin_definition['weight']));
+        ->willReturn($plugin_definition['weight']);
       $this->argumentResolver->expects($this->any())
         ->method('getArguments')
         ->with($this->request, [$plugin, 'getTitle'])
-        ->will($this->returnValue([]));
+        ->willReturn([]);
       $map[] = [$plugin_id, [], $plugin];
     }
     $this->factory->expects($this->any())
diff --git a/core/tests/Drupal/Tests/Core/Menu/LocalTaskDefaultTest.php b/core/tests/Drupal/Tests/Core/Menu/LocalTaskDefaultTest.php
index 7ce9b0c096b8aaa7632d30b26e13b21ccf213448..3bd8e91f8a6f24a2ab99f71d9a17c8961cffed33 100644
--- a/core/tests/Drupal/Tests/Core/Menu/LocalTaskDefaultTest.php
+++ b/core/tests/Drupal/Tests/Core/Menu/LocalTaskDefaultTest.php
@@ -94,7 +94,7 @@ public function testGetRouteParametersForStaticRoute() {
     $this->routeProvider->expects($this->once())
       ->method('getRouteByName')
       ->with('test_route')
-      ->will($this->returnValue(new Route('/test-route')));
+      ->willReturn(new Route('/test-route'));
 
     $this->setupLocalTaskDefault();
 
@@ -114,7 +114,7 @@ public function testGetRouteParametersInPluginDefinitions() {
     $this->routeProvider->expects($this->once())
       ->method('getRouteByName')
       ->with('test_route')
-      ->will($this->returnValue(new Route('/test-route/{parameter}')));
+      ->willReturn(new Route('/test-route/{parameter}'));
 
     $this->setupLocalTaskDefault();
 
@@ -134,7 +134,7 @@ public function testGetRouteParametersForDynamicRouteWithNonUpcastedParameters()
     $this->routeProvider->expects($this->once())
       ->method('getRouteByName')
       ->with('test_route')
-      ->will($this->returnValue($route));
+      ->willReturn($route);
 
     $this->setupLocalTaskDefault();
 
@@ -157,7 +157,7 @@ public function testGetRouteParametersForDynamicRouteWithUpcastedParameters() {
     $this->routeProvider->expects($this->once())
       ->method('getRouteByName')
       ->with('test_route')
-      ->will($this->returnValue($route));
+      ->willReturn($route);
 
     $this->setupLocalTaskDefault();
 
@@ -179,7 +179,7 @@ public function testGetRouteParametersForDynamicRouteWithUpcastedParametersEmpty
     $this->routeProvider->expects($this->once())
       ->method('getRouteByName')
       ->with('test_route')
-      ->will($this->returnValue($route));
+      ->willReturn($route);
 
     $this->setupLocalTaskDefault();
 
@@ -262,7 +262,7 @@ public function testGetTitle() {
     $this->stringTranslation->expects($this->once())
       ->method('translateString')
       ->with($this->pluginDefinition['title'])
-      ->will($this->returnValue('Example translated'));
+      ->willReturn('Example translated');
 
     $this->setupLocalTaskDefault();
     $this->assertEquals('Example translated', $this->localTaskBase->getTitle());
@@ -277,7 +277,7 @@ public function testGetTitleWithContext() {
     $this->stringTranslation->expects($this->once())
       ->method('translateString')
       ->with($this->pluginDefinition['title'])
-      ->will($this->returnValue('Example translated with context'));
+      ->willReturn('Example translated with context');
 
     $this->setupLocalTaskDefault();
     $this->assertEquals('Example translated with context', $this->localTaskBase->getTitle());
@@ -291,7 +291,7 @@ public function testGetTitleWithTitleArguments() {
     $this->stringTranslation->expects($this->once())
       ->method('translateString')
       ->with($this->pluginDefinition['title'])
-      ->will($this->returnValue('Example value'));
+      ->willReturn('Example value');
 
     $this->setupLocalTaskDefault();
     $this->assertEquals('Example value', $this->localTaskBase->getTitle());
diff --git a/core/tests/Drupal/Tests/Core/Menu/LocalTaskIntegrationTestBase.php b/core/tests/Drupal/Tests/Core/Menu/LocalTaskIntegrationTestBase.php
index 41500531c41e070087402866d65d069411b7fb49..fc90fdb85e67e9147d96e5ac3dc2cb9c8ebf7707 100644
--- a/core/tests/Drupal/Tests/Core/Menu/LocalTaskIntegrationTestBase.php
+++ b/core/tests/Drupal/Tests/Core/Menu/LocalTaskIntegrationTestBase.php
@@ -109,7 +109,7 @@ protected function getLocalTaskManager($module_dirs, $route_name, $route_params)
     $factory = $this->createMock('Drupal\Component\Plugin\Factory\FactoryInterface');
     $factory->expects($this->any())
       ->method('createInstance')
-      ->will($this->returnValue($plugin_stub));
+      ->willReturn($plugin_stub);
     $property = new \ReflectionProperty('Drupal\Core\Menu\LocalTaskManager', 'factory');
     $property->setAccessible(TRUE);
     $property->setValue($manager, $factory);
diff --git a/core/tests/Drupal/Tests/Core/Menu/LocalTaskManagerTest.php b/core/tests/Drupal/Tests/Core/Menu/LocalTaskManagerTest.php
index e5ac2121b7ab1fb8e5ec1abbf0af8e3c43ffc395..41cce150c7741007e52b459297e0f659d0f66207 100644
--- a/core/tests/Drupal/Tests/Core/Menu/LocalTaskManagerTest.php
+++ b/core/tests/Drupal/Tests/Core/Menu/LocalTaskManagerTest.php
@@ -123,7 +123,7 @@ public function testGetLocalTasksForRouteSingleLevelTitle() {
 
     $this->pluginDiscovery->expects($this->once())
       ->method('getDefinitions')
-      ->will($this->returnValue($definitions));
+      ->willReturn($definitions);
 
     $mock_plugin = $this->createMock('Drupal\Core\Menu\LocalTaskInterface');
 
@@ -147,7 +147,7 @@ public function testGetLocalTasksForRouteForChild() {
 
     $this->pluginDiscovery->expects($this->once())
       ->method('getDefinitions')
-      ->will($this->returnValue($definitions));
+      ->willReturn($definitions);
 
     $mock_plugin = $this->createMock('Drupal\Core\Menu\LocalTaskInterface');
 
@@ -169,7 +169,7 @@ public function testGetLocalTaskForRouteWithEmptyCache() {
 
     $this->pluginDiscovery->expects($this->once())
       ->method('getDefinitions')
-      ->will($this->returnValue($definitions));
+      ->willReturn($definitions);
 
     $mock_plugin = $this->createMock('Drupal\Core\Menu\LocalTaskInterface');
     $this->setupFactory($mock_plugin);
@@ -212,7 +212,7 @@ public function testGetLocalTaskForRouteWithFilledCache() {
     $this->cacheBackend->expects($this->once())
       ->method('get')
       ->with('local_task_plugins:en:menu_local_task_test_tasks_view')
-      ->will($this->returnValue((object) ['data' => $result]));
+      ->willReturn((object) ['data' => $result]);
 
     $this->cacheBackend->expects($this->never())
       ->method('set');
@@ -235,7 +235,7 @@ public function testGetTitle() {
     $this->argumentResolver->expects($this->once())
       ->method('getArguments')
       ->with($this->request, [$menu_local_task, 'getTitle'])
-      ->will($this->returnValue([]));
+      ->willReturn([]);
 
     $this->manager->getTitle($menu_local_task);
   }
@@ -253,7 +253,7 @@ protected function setupLocalTaskManager() {
     $language_manager = $this->createMock('Drupal\Core\Language\LanguageManagerInterface');
     $language_manager->expects($this->any())
       ->method('getCurrentLanguage')
-      ->will($this->returnValue(new Language(['id' => 'en'])));
+      ->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);
 
@@ -406,7 +406,7 @@ public function testGetTasksBuildWithCacheabilityMetadata() {
 
     $this->pluginDiscovery->expects($this->once())
       ->method('getDefinitions')
-      ->will($this->returnValue($definitions));
+      ->willReturn($definitions);
 
     // Set up some cacheability metadata and ensure its merged together.
     $definitions['menu_local_task_test_tasks_settings']['cache_tags'] = ['tag.example1'];
diff --git a/core/tests/Drupal/Tests/Core/Menu/MenuActiveTrailTest.php b/core/tests/Drupal/Tests/Core/Menu/MenuActiveTrailTest.php
index 4e7e330f3364491a32b5d6b8a9cbfbbb478ae1b0..e1fa99219d95932b5a74b7aa79226e8a42249da7 100644
--- a/core/tests/Drupal/Tests/Core/Menu/MenuActiveTrailTest.php
+++ b/core/tests/Drupal/Tests/Core/Menu/MenuActiveTrailTest.php
@@ -145,7 +145,7 @@ public function testGetActiveLink(Request $request, $links, $menu_name, $expecte
       $this->menuLinkManager->expects($this->exactly(2))
         ->method('loadLinksbyRoute')
         ->with('baby_llama')
-        ->will($this->returnValue($links));
+        ->willReturn($links);
     }
     // Test with menu name.
     $this->assertSame($expected_link, $this->menuActiveTrail->getActiveLink($menu_name));
@@ -169,7 +169,7 @@ public function testGetActiveTrailIds(Request $request, $links, $menu_name, $exp
       $this->menuLinkManager->expects($this->exactly(2))
         ->method('loadLinksbyRoute')
         ->with('baby_llama')
-        ->will($this->returnValue($links));
+        ->willReturn($links);
       if ($expected_link !== NULL) {
         $this->menuLinkManager->expects($this->exactly(2))
           ->method('getParentIds')
@@ -205,7 +205,7 @@ public function testGetCid() {
     $this->menuLinkManager->expects($this->any())
       ->method('loadLinksbyRoute')
       ->with('baby_llama')
-      ->will($this->returnValue($data[1]));
+      ->willReturn($data[1]);
 
     $expected_link = $data[3];
     $expected_trail = $data[4];
diff --git a/core/tests/Drupal/Tests/Core/Menu/StaticMenuLinkOverridesTest.php b/core/tests/Drupal/Tests/Core/Menu/StaticMenuLinkOverridesTest.php
index d1b13b0432692fcdf2052094d205a0ba83d42702..a440d539d3676a14723de18016436a364ae3da67 100644
--- a/core/tests/Drupal/Tests/Core/Menu/StaticMenuLinkOverridesTest.php
+++ b/core/tests/Drupal/Tests/Core/Menu/StaticMenuLinkOverridesTest.php
@@ -121,7 +121,7 @@ public function testSaveOverride() {
     $config_factory = $this->createMock('Drupal\Core\Config\ConfigFactoryInterface');
     $config_factory->expects($this->once())
       ->method('getEditable')
-      ->will($this->returnValue($config));
+      ->willReturn($config);
 
     $static_override = new StaticMenuLinkOverrides($config_factory);
 
@@ -148,7 +148,7 @@ public function testDeleteOverrides($ids, array $old_definitions, array $new_def
     $config->expects($this->once())
       ->method('get')
       ->with('definitions')
-      ->will($this->returnValue($old_definitions));
+      ->willReturn($old_definitions);
 
     // Only save if the definitions changes.
     $config->expects($old_definitions != $new_definitions ? $this->once() : $this->never())
@@ -161,7 +161,7 @@ public function testDeleteOverrides($ids, array $old_definitions, array $new_def
     $config_factory = $this->createMock('Drupal\Core\Config\ConfigFactoryInterface');
     $config_factory->expects($this->once())
       ->method('getEditable')
-      ->will($this->returnValue($config));
+      ->willReturn($config);
 
     $static_override = new StaticMenuLinkOverrides($config_factory);
 
diff --git a/core/tests/Drupal/Tests/Core/PageCache/ChainRequestPolicyTest.php b/core/tests/Drupal/Tests/Core/PageCache/ChainRequestPolicyTest.php
index dbacd549c45af564dc0910652bb319c17da06f4d..03b66ce502485117bb180b260895834f6bcb405b 100644
--- a/core/tests/Drupal/Tests/Core/PageCache/ChainRequestPolicyTest.php
+++ b/core/tests/Drupal/Tests/Core/PageCache/ChainRequestPolicyTest.php
@@ -55,7 +55,7 @@ public function testNullRuleChain() {
     $rule->expects($this->once())
       ->method('check')
       ->with($this->request)
-      ->will($this->returnValue(NULL));
+      ->willReturn(NULL);
 
     $this->policy->addPolicy($rule);
 
@@ -74,7 +74,7 @@ public function testChainExceptionOnInvalidReturnValue($return_value) {
     $rule->expects($this->once())
       ->method('check')
       ->with($this->request)
-      ->will($this->returnValue($return_value));
+      ->willReturn($return_value);
 
     $this->policy->addPolicy($rule);
 
@@ -111,7 +111,7 @@ public function testAllowIfAnyRuleReturnedAllow($return_values) {
       $rule->expects($this->once())
         ->method('check')
         ->with($this->request)
-        ->will($this->returnValue($return_value));
+        ->willReturn($return_value);
 
       $this->policy->addPolicy($rule);
     }
@@ -141,14 +141,14 @@ public function testStopChainOnFirstDeny() {
     $rule1->expects($this->once())
       ->method('check')
       ->with($this->request)
-      ->will($this->returnValue(RequestPolicyInterface::ALLOW));
+      ->willReturn(RequestPolicyInterface::ALLOW);
     $this->policy->addPolicy($rule1);
 
     $deny_rule = $this->createMock('Drupal\Core\PageCache\RequestPolicyInterface');
     $deny_rule->expects($this->once())
       ->method('check')
       ->with($this->request)
-      ->will($this->returnValue(RequestPolicyInterface::DENY));
+      ->willReturn(RequestPolicyInterface::DENY);
     $this->policy->addPolicy($deny_rule);
 
     $ignored_rule = $this->createMock('Drupal\Core\PageCache\RequestPolicyInterface');
diff --git a/core/tests/Drupal/Tests/Core/PageCache/ChainResponsePolicyTest.php b/core/tests/Drupal/Tests/Core/PageCache/ChainResponsePolicyTest.php
index 193b94ee17f083ae18ad998e99ed205ce43f7879..85ec70898645ad0108d5dd7a6ccb11b17a9d6cf0 100644
--- a/core/tests/Drupal/Tests/Core/PageCache/ChainResponsePolicyTest.php
+++ b/core/tests/Drupal/Tests/Core/PageCache/ChainResponsePolicyTest.php
@@ -64,7 +64,7 @@ public function testNullRuleChain() {
     $rule->expects($this->once())
       ->method('check')
       ->with($this->response, $this->request)
-      ->will($this->returnValue(NULL));
+      ->willReturn(NULL);
 
     $this->policy->addPolicy($rule);
 
@@ -83,7 +83,7 @@ public function testChainExceptionOnInvalidReturnValue($return_value) {
     $rule->expects($this->once())
       ->method('check')
       ->with($this->response, $this->request)
-      ->will($this->returnValue($return_value));
+      ->willReturn($return_value);
 
     $this->policy->addPolicy($rule);
 
@@ -122,7 +122,7 @@ public function testStopChainOnFirstDeny() {
     $deny_rule->expects($this->once())
       ->method('check')
       ->with($this->response, $this->request)
-      ->will($this->returnValue(ResponsePolicyInterface::DENY));
+      ->willReturn(ResponsePolicyInterface::DENY);
     $this->policy->addPolicy($deny_rule);
 
     $ignored_rule = $this->createMock('Drupal\Core\PageCache\ResponsePolicyInterface');
diff --git a/core/tests/Drupal/Tests/Core/PageCache/CommandLineOrUnsafeMethodTest.php b/core/tests/Drupal/Tests/Core/PageCache/CommandLineOrUnsafeMethodTest.php
index fa35dddecfe90a6668d36a854d3ad5dab5fe6686..2d1d1b23e5ffd6e3aa12e54c6d8452449ba6ae45 100644
--- a/core/tests/Drupal/Tests/Core/PageCache/CommandLineOrUnsafeMethodTest.php
+++ b/core/tests/Drupal/Tests/Core/PageCache/CommandLineOrUnsafeMethodTest.php
@@ -39,7 +39,7 @@ protected function setUp(): void {
   public function testHttpMethod($expected_result, $method) {
     $this->policy->expects($this->once())
       ->method('isCli')
-      ->will($this->returnValue(FALSE));
+      ->willReturn(FALSE);
 
     $request = Request::create('/', $method);
     $actual_result = $this->policy->check($request);
@@ -73,7 +73,7 @@ public function providerTestHttpMethod() {
   public function testIsCli() {
     $this->policy->expects($this->once())
       ->method('isCli')
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
 
     $request = Request::create('/', 'GET');
     $actual_result = $this->policy->check($request);
diff --git a/core/tests/Drupal/Tests/Core/ParamConverter/ParamConverterManagerTest.php b/core/tests/Drupal/Tests/Core/ParamConverter/ParamConverterManagerTest.php
index d755a783953946ac2ce6487221926d69f78680d1..b3858a136a5b75518673adff08c4f3dbc049cb6d 100644
--- a/core/tests/Drupal/Tests/Core/ParamConverter/ParamConverterManagerTest.php
+++ b/core/tests/Drupal/Tests/Core/ParamConverter/ParamConverterManagerTest.php
@@ -132,7 +132,7 @@ public function testSetRouteParameterConverters($path, $parameters = NULL, $expe
     $converter->expects($this->any())
       ->method('applies')
       ->with($this->anything(), 'id', $this->anything())
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
     $this->manager->addConverter($converter, 'applied');
 
     $route = new Route($path);
@@ -194,7 +194,7 @@ public function testConvert() {
     $converter->expects($this->any())
       ->method('convert')
       ->with(1, $this->isType('array'), 'id', $this->isType('array'))
-      ->will($this->returnValue('something_better!'));
+      ->willReturn('something_better!');
     $this->manager->addConverter($converter, 'test_convert');
 
     $result = $this->manager->convert($defaults);
@@ -240,7 +240,7 @@ public function testConvertMissingParam() {
     $converter->expects($this->any())
       ->method('convert')
       ->with(1, $this->isType('array'), 'id', $this->isType('array'))
-      ->will($this->returnValue(NULL));
+      ->willReturn(NULL);
     $this->manager->addConverter($converter, 'test_convert');
 
     $this->expectException(ParamNotConvertedException::class);
diff --git a/core/tests/Drupal/Tests/Core/PathProcessor/PathProcessorTest.php b/core/tests/Drupal/Tests/Core/PathProcessor/PathProcessorTest.php
index 9682e4b52599643455373fe22522f35c47258233..2737bd4015b6db3f4bd92fd261ee1107cf256851 100644
--- a/core/tests/Drupal/Tests/Core/PathProcessor/PathProcessorTest.php
+++ b/core/tests/Drupal/Tests/Core/PathProcessor/PathProcessorTest.php
@@ -61,13 +61,13 @@ protected function setUp(): void {
       ->getMock();
     $language_manager->expects($this->any())
       ->method('getCurrentLanguage')
-      ->will($this->returnValue($languages['en']));
+      ->willReturn($languages['en']);
     $language_manager->expects($this->any())
       ->method('getLanguages')
-      ->will($this->returnValue($this->languages));
+      ->willReturn($this->languages);
     $language_manager->expects($this->any())
       ->method('getLanguageTypes')
-      ->will($this->returnValue([LanguageInterface::TYPE_INTERFACE]));
+      ->willReturn([LanguageInterface::TYPE_INTERFACE]);
 
     $this->languageManager = $language_manager;
   }
@@ -116,18 +116,18 @@ public function testProcessInbound() {
       ->getMock();
     $negotiator->expects($this->any())
       ->method('getNegotiationMethods')
-      ->will($this->returnValue([
+      ->willReturn([
         LanguageNegotiationUrl::METHOD_ID => [
           'class' => 'Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationUrl',
           'weight' => 9,
         ],
-      ]));
+      ]);
     $method = new LanguageNegotiationUrl();
     $method->setConfig($config_factory_stub);
     $method->setLanguageManager($this->languageManager);
     $negotiator->expects($this->any())
       ->method('getNegotiationMethodInstance')
-      ->will($this->returnValue($method));
+      ->willReturn($method);
 
     // Create a user stub.
     $current_user = $this->getMockBuilder('Drupal\Core\Session\AccountInterface')
diff --git a/core/tests/Drupal/Tests/Core/Plugin/ContextHandlerTest.php b/core/tests/Drupal/Tests/Core/Plugin/ContextHandlerTest.php
index 0863c064af6cf9305be066b5717f0d332f94f399..04a8bed22d74750c89a57bd1b6f12c07d7fdcb91 100644
--- a/core/tests/Drupal/Tests/Core/Plugin/ContextHandlerTest.php
+++ b/core/tests/Drupal/Tests/Core/Plugin/ContextHandlerTest.php
@@ -90,7 +90,7 @@ public function providerTestCheckRequirements() {
     $context_any = $this->createMock('Drupal\Core\Plugin\Context\ContextInterface');
     $context_any->expects($this->atLeastOnce())
       ->method('getContextDefinition')
-      ->will($this->returnValue(new ContextDefinition('any')));
+      ->willReturn(new ContextDefinition('any'));
 
     $requirement_specific = new ContextDefinition('string');
     $requirement_specific->setConstraints(['Blank' => []]);
@@ -98,18 +98,18 @@ public function providerTestCheckRequirements() {
     $context_constraint_mismatch = $this->createMock('Drupal\Core\Plugin\Context\ContextInterface');
     $context_constraint_mismatch->expects($this->atLeastOnce())
       ->method('getContextDefinition')
-      ->will($this->returnValue(new ContextDefinition('foo')));
+      ->willReturn(new ContextDefinition('foo'));
     $context_datatype_mismatch = $this->createMock('Drupal\Core\Plugin\Context\ContextInterface');
     $context_datatype_mismatch->expects($this->atLeastOnce())
       ->method('getContextDefinition')
-      ->will($this->returnValue(new ContextDefinition('fuzzy')));
+      ->willReturn(new ContextDefinition('fuzzy'));
 
     $context_definition_specific = new ContextDefinition('string');
     $context_definition_specific->setConstraints(['Blank' => []]);
     $context_specific = $this->createMock('Drupal\Core\Plugin\Context\ContextInterface');
     $context_specific->expects($this->atLeastOnce())
       ->method('getContextDefinition')
-      ->will($this->returnValue($context_definition_specific));
+      ->willReturn($context_definition_specific);
 
     $data = [];
     $data[] = [[], [], TRUE];
@@ -148,21 +148,21 @@ public function providerTestGetMatchingContexts() {
     $context_any = $this->createMock('Drupal\Core\Plugin\Context\ContextInterface');
     $context_any->expects($this->atLeastOnce())
       ->method('getContextDefinition')
-      ->will($this->returnValue(new ContextDefinition('any')));
+      ->willReturn(new ContextDefinition('any'));
     $context_constraint_mismatch = $this->createMock('Drupal\Core\Plugin\Context\ContextInterface');
     $context_constraint_mismatch->expects($this->atLeastOnce())
       ->method('getContextDefinition')
-      ->will($this->returnValue(new ContextDefinition('foo')));
+      ->willReturn(new ContextDefinition('foo'));
     $context_datatype_mismatch = $this->createMock('Drupal\Core\Plugin\Context\ContextInterface');
     $context_datatype_mismatch->expects($this->atLeastOnce())
       ->method('getContextDefinition')
-      ->will($this->returnValue(new ContextDefinition('fuzzy')));
+      ->willReturn(new ContextDefinition('fuzzy'));
     $context_definition_specific = new ContextDefinition('string');
     $context_definition_specific->setConstraints(['Blank' => []]);
     $context_specific = $this->createMock('Drupal\Core\Plugin\Context\ContextInterface');
     $context_specific->expects($this->atLeastOnce())
       ->method('getContextDefinition')
-      ->will($this->returnValue($context_definition_specific));
+      ->willReturn($context_definition_specific);
 
     $data = [];
     // No context will return no valid contexts.
@@ -191,7 +191,7 @@ public function testFilterPluginDefinitionsByContexts($has_context, $definitions
       $expected_context_definition = (new ContextDefinition('string'))->setConstraints(['Blank' => []]);
       $context->expects($this->atLeastOnce())
         ->method('getContextDefinition')
-        ->will($this->returnValue($expected_context_definition));
+        ->willReturn($expected_context_definition);
       $contexts = [$context];
     }
     else {
@@ -332,7 +332,7 @@ public function testApplyContextMapping() {
       ->willReturn([]);
     $plugin->expects($this->once())
       ->method('getContextDefinitions')
-      ->will($this->returnValue(['hit' => $context_definition]));
+      ->willReturn(['hit' => $context_definition]);
     $plugin->expects($this->once())
       ->method('setContext')
       ->with('hit', $context_hit);
@@ -373,7 +373,7 @@ public function testApplyContextMappingMissingRequired() {
       ->willReturn([]);
     $plugin->expects($this->once())
       ->method('getContextDefinitions')
-      ->will($this->returnValue(['hit' => $context_definition]));
+      ->willReturn(['hit' => $context_definition]);
     $plugin->expects($this->never())
       ->method('setContext');
 
@@ -410,7 +410,7 @@ public function testApplyContextMappingMissingNotRequired() {
       ->willReturn(['optional' => 'missing']);
     $plugin->expects($this->once())
       ->method('getContextDefinitions')
-      ->will($this->returnValue(['optional' => $context_definition]));
+      ->willReturn(['optional' => $context_definition]);
     $plugin->expects($this->never())
       ->method('setContext');
 
@@ -448,7 +448,7 @@ public function testApplyContextMappingNoValueRequired() {
       ->willReturn([]);
     $plugin->expects($this->once())
       ->method('getContextDefinitions')
-      ->will($this->returnValue(['hit' => $context_definition]));
+      ->willReturn(['hit' => $context_definition]);
     $plugin->expects($this->never())
       ->method('setContext');
 
@@ -483,7 +483,7 @@ public function testApplyContextMappingNoValueNonRequired() {
       ->willReturn([]);
     $plugin->expects($this->once())
       ->method('getContextDefinitions')
-      ->will($this->returnValue(['hit' => $context_definition]));
+      ->willReturn(['hit' => $context_definition]);
     $plugin->expects($this->never())
       ->method('setContext');
 
@@ -511,7 +511,7 @@ public function testApplyContextMappingConfigurableAssigned() {
       ->willReturn([]);
     $plugin->expects($this->once())
       ->method('getContextDefinitions')
-      ->will($this->returnValue(['hit' => $context_definition]));
+      ->willReturn(['hit' => $context_definition]);
     $plugin->expects($this->once())
       ->method('setContext')
       ->with('hit', $context);
@@ -549,7 +549,7 @@ public function testApplyContextMappingConfigurableAssignedMiss() {
       ->willReturn([]);
     $plugin->expects($this->once())
       ->method('getContextDefinitions')
-      ->will($this->returnValue(['hit' => $context_definition]));
+      ->willReturn(['hit' => $context_definition]);
     $plugin->expects($this->never())
       ->method('setContext');
 
diff --git a/core/tests/Drupal/Tests/Core/Plugin/DefaultPluginManagerTest.php b/core/tests/Drupal/Tests/Core/Plugin/DefaultPluginManagerTest.php
index 33881211195f964fa405abf4ecd96c61e2ff8d60..37799cdfe4f769fc44eba19f725d83657db9e372 100644
--- a/core/tests/Drupal/Tests/Core/Plugin/DefaultPluginManagerTest.php
+++ b/core/tests/Drupal/Tests/Core/Plugin/DefaultPluginManagerTest.php
@@ -100,7 +100,7 @@ public function testDefaultPluginManagerWithDisabledModule() {
     $module_handler->expects($this->once())
       ->method('moduleExists')
       ->with('disabled_module')
-      ->will($this->returnValue(FALSE));
+      ->willReturn(FALSE);
 
     $plugin_manager = new TestPluginManager($this->namespaces, $definitions, $module_handler, 'test_alter_hook', '\Drupal\plugin_test\Plugin\plugin_test\fruit\FruitInterface');
 
@@ -125,7 +125,7 @@ public function testDefaultPluginManagerWithObjects() {
     $module_handler->expects($this->once())
       ->method('moduleExists')
       ->with('disabled_module')
-      ->will($this->returnValue(FALSE));
+      ->willReturn(FALSE);
 
     $plugin_manager = new TestPluginManager($this->namespaces, $definitions, $module_handler, 'test_alter_hook', '\Drupal\plugin_test\Plugin\plugin_test\fruit\FruitInterface');
 
@@ -184,7 +184,7 @@ public function testDefaultPluginManagerWithEmptyCache() {
       ->expects($this->once())
       ->method('get')
       ->with($cid)
-      ->will($this->returnValue(FALSE));
+      ->willReturn(FALSE);
     $cache_backend
       ->expects($this->once())
       ->method('set')
@@ -209,7 +209,7 @@ public function testDefaultPluginManagerWithFilledCache() {
       ->expects($this->once())
       ->method('get')
       ->with($cid)
-      ->will($this->returnValue((object) ['data' => $this->expectedDefinitions]));
+      ->willReturn((object) ['data' => $this->expectedDefinitions]);
     $cache_backend
       ->expects($this->never())
       ->method('set');
diff --git a/core/tests/Drupal/Tests/Core/Plugin/Discovery/ContainerDerivativeDiscoveryDecoratorTest.php b/core/tests/Drupal/Tests/Core/Plugin/Discovery/ContainerDerivativeDiscoveryDecoratorTest.php
index fbdec9e677a9ea11a2c77795a38cfdf63d38b38c..c47eba77faec8573c7ed8e4a4fa36ca913f13ad9 100644
--- a/core/tests/Drupal/Tests/Core/Plugin/Discovery/ContainerDerivativeDiscoveryDecoratorTest.php
+++ b/core/tests/Drupal/Tests/Core/Plugin/Discovery/ContainerDerivativeDiscoveryDecoratorTest.php
@@ -22,7 +22,7 @@ public function testGetDefinitions() {
     $example_container->expects($this->once())
       ->method('get')
       ->with($this->equalTo('example_service'))
-      ->will($this->returnValue($example_service));
+      ->willReturn($example_service);
 
     \Drupal::setContainer($example_container);
 
@@ -39,7 +39,7 @@ public function testGetDefinitions() {
     $discovery_main = $this->createMock('Drupal\Component\Plugin\Discovery\DiscoveryInterface');
     $discovery_main->expects($this->any())
       ->method('getDefinitions')
-      ->will($this->returnValue($definitions));
+      ->willReturn($definitions);
 
     $discovery = new ContainerDerivativeDiscoveryDecorator($discovery_main);
     $definitions = $discovery->getDefinitions();
diff --git a/core/tests/Drupal/Tests/Core/Plugin/Discovery/DerivativeDiscoveryDecoratorTest.php b/core/tests/Drupal/Tests/Core/Plugin/Discovery/DerivativeDiscoveryDecoratorTest.php
index 12bf5e343cf095917cca5cfe9ebe9d464b6271a3..8027421bcea580b731258e48690142e6056f33be 100644
--- a/core/tests/Drupal/Tests/Core/Plugin/Discovery/DerivativeDiscoveryDecoratorTest.php
+++ b/core/tests/Drupal/Tests/Core/Plugin/Discovery/DerivativeDiscoveryDecoratorTest.php
@@ -44,7 +44,7 @@ public function testGetDerivativeFetcher() {
 
     $this->discoveryMain->expects($this->any())
       ->method('getDefinitions')
-      ->will($this->returnValue($definitions));
+      ->willReturn($definitions);
 
     $discovery = new DerivativeDiscoveryDecorator($this->discoveryMain);
     $definitions = $discovery->getDefinitions();
@@ -70,7 +70,7 @@ public function testGetDerivativeFetcherWithAnnotationObjects() {
 
     $this->discoveryMain->expects($this->any())
       ->method('getDefinitions')
-      ->will($this->returnValue($definitions));
+      ->willReturn($definitions);
 
     $discovery = new DerivativeDiscoveryDecorator($this->discoveryMain);
     $definitions = $discovery->getDefinitions();
@@ -100,7 +100,7 @@ public function testGetDeriverClassWithClassedDefinitions() {
 
     $this->discoveryMain->expects($this->any())
       ->method('getDefinitions')
-      ->will($this->returnValue($definitions));
+      ->willReturn($definitions);
 
     $discovery = new DerivativeDiscoveryDecorator($this->discoveryMain);
     $definitions = $discovery->getDefinitions();
@@ -145,7 +145,7 @@ public function testNonExistentDerivativeFetcher() {
     ];
     $this->discoveryMain->expects($this->any())
       ->method('getDefinitions')
-      ->will($this->returnValue($definitions));
+      ->willReturn($definitions);
 
     $discovery = new DerivativeDiscoveryDecorator($this->discoveryMain);
     $this->expectException(InvalidDeriverException::class);
@@ -167,7 +167,7 @@ public function testInvalidDerivativeFetcher() {
     ];
     $this->discoveryMain->expects($this->any())
       ->method('getDefinitions')
-      ->will($this->returnValue($definitions));
+      ->willReturn($definitions);
 
     $discovery = new DerivativeDiscoveryDecorator($this->discoveryMain);
     $this->expectException(InvalidDeriverException::class);
@@ -202,7 +202,7 @@ public function testExistingDerivative() {
 
     $this->discoveryMain->expects($this->any())
       ->method('getDefinitions')
-      ->will($this->returnValue($definitions));
+      ->willReturn($definitions);
 
     $discovery = new DerivativeDiscoveryDecorator($this->discoveryMain);
     $returned_definitions = $discovery->getDefinitions();
diff --git a/core/tests/Drupal/Tests/Core/Plugin/Discovery/HookDiscoveryTest.php b/core/tests/Drupal/Tests/Core/Plugin/Discovery/HookDiscoveryTest.php
index b6d13d43dc867cc0ff091545e12a85a65446c55e..0ac5cd7739f9a7a4ecaae535d11d2563da834335 100644
--- a/core/tests/Drupal/Tests/Core/Plugin/Discovery/HookDiscoveryTest.php
+++ b/core/tests/Drupal/Tests/Core/Plugin/Discovery/HookDiscoveryTest.php
@@ -40,11 +40,6 @@ protected function setUp(): void {
    * @see \Drupal\Core\Plugin\Discovery::getDefinitions()
    */
   public function testGetDefinitionsWithoutPlugins() {
-    $this->moduleHandler->expects($this->once())
-      ->method('invokeAllWith')
-      ->with('test_plugin')
-      ->will($this->returnValue([]));
-
     $this->assertCount(0, $this->hookDiscovery->getDefinitions());
   }
 
@@ -112,10 +107,6 @@ public function testGetDefinition() {
    * @see \Drupal\Core\Plugin\Discovery::getDefinition()
    */
   public function testGetDefinitionWithUnknownID() {
-    $this->moduleHandler->expects($this->once())
-      ->method('invokeAllWith')
-      ->will($this->returnValue([]));
-
     $this->expectException(PluginNotFoundException::class);
     $this->hookDiscovery->getDefinition('test_non_existent', TRUE);
   }
diff --git a/core/tests/Drupal/Tests/Core/Plugin/Discovery/YamlDiscoveryDecoratorTest.php b/core/tests/Drupal/Tests/Core/Plugin/Discovery/YamlDiscoveryDecoratorTest.php
index e4a1257ad77474a7ca5b67e8e22357dc28fefcf6..5717f75ca1152c648f97561f887cfc98731038ab 100644
--- a/core/tests/Drupal/Tests/Core/Plugin/Discovery/YamlDiscoveryDecoratorTest.php
+++ b/core/tests/Drupal/Tests/Core/Plugin/Discovery/YamlDiscoveryDecoratorTest.php
@@ -62,7 +62,7 @@ protected function setUp(): void {
     $decorated = $this->createMock('Drupal\Component\Plugin\Discovery\DiscoveryInterface');
     $decorated->expects($this->once())
       ->method('getDefinitions')
-      ->will($this->returnValue($definitions));
+      ->willReturn($definitions);
 
     $this->discoveryDecorator = new YamlDiscoveryDecorator($decorated, 'test', $directories);
   }
diff --git a/core/tests/Drupal/Tests/Core/Plugin/LazyPluginCollectionTestBase.php b/core/tests/Drupal/Tests/Core/Plugin/LazyPluginCollectionTestBase.php
index 18a69770ee7a73191928c6663d350753de6c6fac..e96a2d864d51f87ba4a866aac62dd4c4efeaadb0 100644
--- a/core/tests/Drupal/Tests/Core/Plugin/LazyPluginCollectionTestBase.php
+++ b/core/tests/Drupal/Tests/Core/Plugin/LazyPluginCollectionTestBase.php
@@ -50,7 +50,7 @@ protected function setUp(): void {
     $this->pluginManager = $this->createMock('Drupal\Component\Plugin\PluginManagerInterface');
     $this->pluginManager->expects($this->any())
       ->method('getDefinitions')
-      ->will($this->returnValue($this->getPluginDefinitions()));
+      ->willReturn($this->getPluginDefinitions());
 
   }
 
@@ -107,7 +107,7 @@ protected function getPluginMock($plugin_id, array $definition) {
     $mock = $this->createMock('Drupal\Component\Plugin\PluginInspectionInterface');
     $mock->expects($this->any())
       ->method('getPluginId')
-      ->will($this->returnValue($plugin_id));
+      ->willReturn($plugin_id);
     return $mock;
   }
 
diff --git a/core/tests/Drupal/Tests/Core/PrivateKeyTest.php b/core/tests/Drupal/Tests/Core/PrivateKeyTest.php
index b662bec50354954192176e270424e47c20e41b85..932bf0a2f74c06a2da609f15fe7548fa7a6c042b 100644
--- a/core/tests/Drupal/Tests/Core/PrivateKeyTest.php
+++ b/core/tests/Drupal/Tests/Core/PrivateKeyTest.php
@@ -53,7 +53,7 @@ public function testGet() {
     $this->state->expects($this->once())
       ->method('get')
       ->with('system.private_key')
-      ->will($this->returnValue($this->key));
+      ->willReturn($this->key);
 
     $this->assertEquals($this->key, $this->privateKey->get());
   }
@@ -74,7 +74,7 @@ public function testSet() {
     $this->state->expects($this->once())
       ->method('set')
       ->with('system.private_key', $random_name)
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
 
     $this->privateKey->set($random_name);
   }
diff --git a/core/tests/Drupal/Tests/Core/Routing/AccessAwareRouterTest.php b/core/tests/Drupal/Tests/Core/Routing/AccessAwareRouterTest.php
index ed2e557940d33a475a5fa72b42da47e50cbae755..f7928065a68bc30aa1f66b63514ecd3b0da670f7 100644
--- a/core/tests/Drupal/Tests/Core/Routing/AccessAwareRouterTest.php
+++ b/core/tests/Drupal/Tests/Core/Routing/AccessAwareRouterTest.php
@@ -67,7 +67,7 @@ protected function setupRouter() {
       ->getMock();
     $this->router->expects($this->once())
       ->method('matchRequest')
-      ->will($this->returnValue([RouteObjectInterface::ROUTE_OBJECT => $this->route]));
+      ->willReturn([RouteObjectInterface::ROUTE_OBJECT => $this->route]);
     $this->accessAwareRouter = new AccessAwareRouter($this->router, $this->accessManager, $this->currentUser);
   }
 
diff --git a/core/tests/Drupal/Tests/Core/Routing/LazyRouteCollectionTest.php b/core/tests/Drupal/Tests/Core/Routing/LazyRouteCollectionTest.php
index 47bade86516512c4a4c3215565d571f398fb9fe6..2c1283e4c11bf71a3ba86d1882b629d27c8c2b2d 100644
--- a/core/tests/Drupal/Tests/Core/Routing/LazyRouteCollectionTest.php
+++ b/core/tests/Drupal/Tests/Core/Routing/LazyRouteCollectionTest.php
@@ -49,7 +49,7 @@ public function testGetIterator() {
     $this->routeProvider->expects($this->exactly(2))
       ->method('getRoutesByNames')
       ->with(NULL)
-      ->will($this->returnValue($this->testRoutes));
+      ->willReturn($this->testRoutes);
     $lazyRouteCollection = new LazyRouteCollection($this->routeProvider);
     $this->assertEquals($this->testRoutes, (array) $lazyRouteCollection->getIterator());
     $this->assertEquals($this->testRoutes, $lazyRouteCollection->all());
@@ -62,7 +62,7 @@ public function testCount() {
     $this->routeProvider
       ->method('getRoutesByNames')
       ->with(NULL)
-      ->will($this->returnValue($this->testRoutes));
+      ->willReturn($this->testRoutes);
     $lazyRouteCollection = new LazyRouteCollection($this->routeProvider);
     $this->assertEquals(2, $lazyRouteCollection->count());
   }
@@ -77,7 +77,7 @@ public function testGetName() {
     $this->routeProvider
       ->method('getRouteByName')
       ->with('route_1')
-      ->will($this->returnValue($this->testRoutes['route_1']));
+      ->willReturn($this->testRoutes['route_1']);
     $lazyRouteCollection = new LazyRouteCollection($this->routeProvider);
     $this->assertEquals($lazyRouteCollection->get('route_1'), $this->testRoutes['route_1']);
 
diff --git a/core/tests/Drupal/Tests/Core/Routing/RouteBuilderTest.php b/core/tests/Drupal/Tests/Core/Routing/RouteBuilderTest.php
index 4a7c911c07fe7d0ec78eb9d4af3fbbf30d71574d..a767a0eb4dacb44f52104f847e72d74f35961634 100644
--- a/core/tests/Drupal/Tests/Core/Routing/RouteBuilderTest.php
+++ b/core/tests/Drupal/Tests/Core/Routing/RouteBuilderTest.php
@@ -102,7 +102,7 @@ public function testRebuildLockingUnlocking() {
     $this->lock->expects($this->once())
       ->method('acquire')
       ->with('router_rebuild')
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
 
     $this->lock->expects($this->once())
       ->method('release')
@@ -110,7 +110,7 @@ public function testRebuildLockingUnlocking() {
 
     $this->yamlDiscovery->expects($this->any())
       ->method('findAll')
-      ->will($this->returnValue([]));
+      ->willReturn([]);
 
     $this->assertTrue($this->routeBuilder->rebuild());
   }
@@ -122,7 +122,7 @@ public function testRebuildBlockingLock() {
     $this->lock->expects($this->once())
       ->method('acquire')
       ->with('router_rebuild')
-      ->will($this->returnValue(FALSE));
+      ->willReturn(FALSE);
 
     $this->lock->expects($this->once())
       ->method('wait')
@@ -146,14 +146,14 @@ public function testRebuildWithStaticModuleRoutes() {
     $this->lock->expects($this->once())
       ->method('acquire')
       ->with('router_rebuild')
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
 
     $routing_fixtures = new RoutingFixtures();
     $routes = $routing_fixtures->staticSampleRouteCollection();
 
     $this->yamlDiscovery->expects($this->once())
       ->method('findAll')
-      ->will($this->returnValue(['test_module' => $routes]));
+      ->willReturn(['test_module' => $routes]);
 
     $route_collection = $routing_fixtures->sampleRouteCollection();
     foreach ($route_collection->all() as $route) {
@@ -194,18 +194,18 @@ public function testRebuildWithProviderBasedRoutes() {
     $this->lock->expects($this->once())
       ->method('acquire')
       ->with('router_rebuild')
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
 
     $this->yamlDiscovery->expects($this->once())
       ->method('findAll')
-      ->will($this->returnValue([
+      ->willReturn([
         'test_module' => [
           'route_callbacks' => [
             '\Drupal\Tests\Core\Routing\TestRouteSubscriber::routesFromArray',
             'test_module.route_service:routesFromCollection',
           ],
         ],
-      ]));
+      ]);
 
     $container = new ContainerBuilder();
     $container->set('test_module.route_service', new TestRouteSubscriber());
@@ -261,7 +261,7 @@ public function testRebuildIfNeeded() {
     $this->lock->expects($this->once())
       ->method('acquire')
       ->with('router_rebuild')
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
 
     $this->lock->expects($this->once())
       ->method('release')
@@ -269,7 +269,7 @@ public function testRebuildIfNeeded() {
 
     $this->yamlDiscovery->expects($this->any())
       ->method('findAll')
-      ->will($this->returnValue([]));
+      ->willReturn([]);
 
     $this->routeBuilder->setRebuildNeeded();
 
@@ -289,10 +289,10 @@ public function testRebuildWithOverriddenRouteClass() {
     $this->lock->expects($this->once())
       ->method('acquire')
       ->with('router_rebuild')
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
     $this->yamlDiscovery->expects($this->once())
       ->method('findAll')
-      ->will($this->returnValue([
+      ->willReturn([
         'test_module' => [
           'test_route.override' => [
             'path' => '/test_route_override',
@@ -304,7 +304,7 @@ public function testRebuildWithOverriddenRouteClass() {
             'path' => '/test_route',
           ],
         ],
-      ]));
+      ]);
 
     $container = new ContainerBuilder();
     $container->set('test_module.route_service', new TestRouteSubscriber());
diff --git a/core/tests/Drupal/Tests/Core/Routing/RoutePreloaderTest.php b/core/tests/Drupal/Tests/Core/Routing/RoutePreloaderTest.php
index da6117438789072f089111a5f72491dd85c268cf..a5d75064eff88fa7d0d991f2a64d741ebaca3b0c 100644
--- a/core/tests/Drupal/Tests/Core/Routing/RoutePreloaderTest.php
+++ b/core/tests/Drupal/Tests/Core/Routing/RoutePreloaderTest.php
@@ -65,7 +65,7 @@ public function testOnAlterRoutesWithAdminRoutes() {
     $route_collection->add('test2', new Route('/admin/bar', ['_controller' => 'Drupal\ExampleController']));
     $event->expects($this->once())
       ->method('getRouteCollection')
-      ->will($this->returnValue($route_collection));
+      ->willReturn($route_collection);
 
     $this->state->expects($this->once())
       ->method('set')
@@ -88,7 +88,7 @@ public function testOnAlterRoutesWithAdminPathNoAdminRoute() {
     $route_collection->add('test4', new Route('/admin', ['_controller' => 'Drupal\ExampleController']));
     $event->expects($this->once())
       ->method('getRouteCollection')
-      ->will($this->returnValue($route_collection));
+      ->willReturn($route_collection);
 
     $this->state->expects($this->once())
       ->method('set')
@@ -126,7 +126,7 @@ public function testOnAlterRoutesWithNonAdminRoutes() {
 
     $event->expects($this->once())
       ->method('getRouteCollection')
-      ->will($this->returnValue($route_collection));
+      ->willReturn($route_collection);
 
     $this->state->expects($this->once())
       ->method('set')
@@ -146,7 +146,7 @@ public function testOnRequestNonHtml() {
     $request->setRequestFormat('non-html');
     $event->expects($this->any())
       ->method('getRequest')
-      ->will($this->returnValue($request));
+      ->willReturn($request);
 
     $this->routeProvider->expects($this->never())
       ->method('getRoutesByNames');
@@ -167,7 +167,7 @@ public function testOnRequestOnHtml() {
     $request->setRequestFormat('html');
     $event->expects($this->any())
       ->method('getRequest')
-      ->will($this->returnValue($request));
+      ->willReturn($request);
 
     $this->routeProvider->expects($this->once())
       ->method('preLoadRoutes')
@@ -175,7 +175,7 @@ public function testOnRequestOnHtml() {
     $this->state->expects($this->once())
       ->method('get')
       ->with('routing.non_admin_routes')
-      ->will($this->returnValue(['test2']));
+      ->willReturn(['test2']);
 
     $this->preloader->onRequest($event);
   }
diff --git a/core/tests/Drupal/Tests/Core/Session/PermissionsHashGeneratorTest.php b/core/tests/Drupal/Tests/Core/Session/PermissionsHashGeneratorTest.php
index 8bd979a81c0fa0e27ced95a947da095c1f311a46..1736593194a2fb8eeb2d68472e0925f6b0c1d04b 100644
--- a/core/tests/Drupal/Tests/Core/Session/PermissionsHashGeneratorTest.php
+++ b/core/tests/Drupal/Tests/Core/Session/PermissionsHashGeneratorTest.php
@@ -96,7 +96,7 @@ protected function setUp(): void {
       ->getMock();
     $this->account2->expects($this->any())
       ->method('getRoles')
-      ->will($this->returnValue($roles_1));
+      ->willReturn($roles_1);
     $this->account2->expects($this->any())
       ->method('id')
       ->willReturn(2);
@@ -109,7 +109,7 @@ protected function setUp(): void {
       ->getMock();
     $this->account3->expects($this->any())
       ->method('getRoles')
-      ->will($this->returnValue($roles_3));
+      ->willReturn($roles_3);
     $this->account3->expects($this->any())
       ->method('id')
       ->willReturn(3);
@@ -122,7 +122,7 @@ protected function setUp(): void {
       ->getMock();
     $this->account2Updated->expects($this->any())
       ->method('getRoles')
-      ->will($this->returnValue($roles_2_updated));
+      ->willReturn($roles_2_updated);
     $this->account2Updated->expects($this->any())
       ->method('id')
       ->willReturn(2);
@@ -135,7 +135,7 @@ protected function setUp(): void {
       ->getMock();
     $this->privateKey->expects($this->any())
       ->method('get')
-      ->will($this->returnValue($random));
+      ->willReturn($random);
     $this->cache = $this->getMockBuilder('Drupal\Core\Cache\CacheBackendInterface')
       ->disableOriginalConstructor()
       ->getMock();
@@ -178,7 +178,7 @@ public function testGeneratePersistentCache() {
     $this->staticCache->expects($this->once())
       ->method('get')
       ->with($expected_cid)
-      ->will($this->returnValue(FALSE));
+      ->willReturn(FALSE);
     $this->staticCache->expects($this->once())
       ->method('set')
       ->with($expected_cid, $this->isType('string'));
@@ -186,7 +186,7 @@ public function testGeneratePersistentCache() {
     $this->cache->expects($this->once())
       ->method('get')
       ->with($expected_cid)
-      ->will($this->returnValue($mock_cache));
+      ->willReturn($mock_cache);
     $this->cache->expects($this->never())
       ->method('set');
 
@@ -206,7 +206,7 @@ public function testGenerateStaticCache() {
     $this->staticCache->expects($this->once())
       ->method('get')
       ->with($expected_cid)
-      ->will($this->returnValue($mock_cache));
+      ->willReturn($mock_cache);
     $this->staticCache->expects($this->never())
       ->method('set');
 
@@ -228,7 +228,7 @@ public function testGenerateNoCache() {
     $this->staticCache->expects($this->once())
       ->method('get')
       ->with($expected_cid)
-      ->will($this->returnValue(FALSE));
+      ->willReturn(FALSE);
     $this->staticCache->expects($this->once())
       ->method('set')
       ->with($expected_cid, $this->isType('string'));
@@ -236,7 +236,7 @@ public function testGenerateNoCache() {
     $this->cache->expects($this->once())
       ->method('get')
       ->with($expected_cid)
-      ->will($this->returnValue(FALSE));
+      ->willReturn(FALSE);
     $this->cache->expects($this->once())
       ->method('set')
       ->with($expected_cid, $this->isType('string'));
diff --git a/core/tests/Drupal/Tests/Core/Session/UserSessionTest.php b/core/tests/Drupal/Tests/Core/Session/UserSessionTest.php
index 236b31b39b9e773b05b6ad12e7807fe68847717e..92b156386ae03259e3ef3e7462a1dd38297ab80c 100644
--- a/core/tests/Drupal/Tests/Core/Session/UserSessionTest.php
+++ b/core/tests/Drupal/Tests/Core/Session/UserSessionTest.php
@@ -117,7 +117,7 @@ protected function setUp(): void {
     $entity_type_manager->expects($this->any())
       ->method('getStorage')
       ->with($this->equalTo('user_role'))
-      ->will($this->returnValue($role_storage));
+      ->willReturn($role_storage);
     $container = new ContainerBuilder();
     $container->set('entity_type.manager', $entity_type_manager);
     \Drupal::setContainer($container);
diff --git a/core/tests/Drupal/Tests/Core/Session/WriteSafeSessionHandlerTest.php b/core/tests/Drupal/Tests/Core/Session/WriteSafeSessionHandlerTest.php
index 4e07b0f6e63e0e32012e6398930a1408c966507c..5db4d7c9df403562b26b66a1463aeade0a04bab8 100644
--- a/core/tests/Drupal/Tests/Core/Session/WriteSafeSessionHandlerTest.php
+++ b/core/tests/Drupal/Tests/Core/Session/WriteSafeSessionHandlerTest.php
@@ -135,7 +135,7 @@ public function testSetSessionWritable() {
   public function testOtherMethods($method, $expected_result, $args) {
     $invocation = $this->wrappedSessionHandler->expects($this->exactly(2))
       ->method($method)
-      ->will($this->returnValue($expected_result));
+      ->willReturn($expected_result);
 
     // Set the parameter matcher.
     call_user_func_array([$invocation, 'with'], $args);
diff --git a/core/tests/Drupal/Tests/Core/StackMiddleware/NegotiationMiddlewareTest.php b/core/tests/Drupal/Tests/Core/StackMiddleware/NegotiationMiddlewareTest.php
index 935de8972e8168e840ea0e6f6f4538e3ce5ce46a..a185f100bb1d20bd86b42db6e267fe622eaecb73 100644
--- a/core/tests/Drupal/Tests/Core/StackMiddleware/NegotiationMiddlewareTest.php
+++ b/core/tests/Drupal/Tests/Core/StackMiddleware/NegotiationMiddlewareTest.php
@@ -131,7 +131,7 @@ public function testSetFormat() {
     $app = $this->createMock(HttpKernelInterface::class);
     $app->expects($this->once())
       ->method('handle')
-      ->will($this->returnValue($this->createMock(Response::class)));
+      ->willReturn($this->createMock(Response::class));
 
     $content_negotiation = new StubNegotiationMiddleware($app);
 
diff --git a/core/tests/Drupal/Tests/Core/TempStore/PrivateTempStoreTest.php b/core/tests/Drupal/Tests/Core/TempStore/PrivateTempStoreTest.php
index 0df104a907416f24b03975853bc72487e806f40d..efc048cf368f31f2050fd0fb7ba966ffae584981 100644
--- a/core/tests/Drupal/Tests/Core/TempStore/PrivateTempStoreTest.php
+++ b/core/tests/Drupal/Tests/Core/TempStore/PrivateTempStoreTest.php
@@ -127,7 +127,7 @@ public function testSetWithNoLockAvailable() {
     $this->lock->expects($this->exactly(2))
       ->method('acquire')
       ->with('1:test')
-      ->will($this->returnValue(FALSE));
+      ->willReturn(FALSE);
     $this->lock->expects($this->once())
       ->method('wait')
       ->with('1:test');
@@ -148,7 +148,7 @@ public function testSet() {
     $this->lock->expects($this->once())
       ->method('acquire')
       ->with('1:test')
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
     $this->lock->expects($this->never())
       ->method('wait');
     $this->lock->expects($this->once())
@@ -192,11 +192,11 @@ public function testDeleteLocking() {
     $this->keyValue->expects($this->once())
       ->method('get')
       ->with('1:test')
-      ->will($this->returnValue($this->ownObject));
+      ->willReturn($this->ownObject);
     $this->lock->expects($this->once())
       ->method('acquire')
       ->with('1:test')
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
     $this->lock->expects($this->never())
       ->method('wait');
     $this->lock->expects($this->once())
@@ -219,11 +219,11 @@ public function testDeleteWithNoLockAvailable() {
     $this->keyValue->expects($this->once())
       ->method('get')
       ->with('1:test')
-      ->will($this->returnValue($this->ownObject));
+      ->willReturn($this->ownObject);
     $this->lock->expects($this->exactly(2))
       ->method('acquire')
       ->with('1:test')
-      ->will($this->returnValue(FALSE));
+      ->willReturn(FALSE);
     $this->lock->expects($this->once())
       ->method('wait')
       ->with('1:test');
@@ -244,7 +244,7 @@ public function testDelete() {
     $this->lock->expects($this->once())
       ->method('acquire')
       ->with('1:test_2')
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
 
     $this->keyValue->expects($this->exactly(3))
       ->method('get')
diff --git a/core/tests/Drupal/Tests/Core/TempStore/SharedTempStoreTest.php b/core/tests/Drupal/Tests/Core/TempStore/SharedTempStoreTest.php
index 6aa700182135ba82f83263d556be9a4c506c2ca4..4df06f7a4c51047aed83a928f288a2edd6b4d173 100644
--- a/core/tests/Drupal/Tests/Core/TempStore/SharedTempStoreTest.php
+++ b/core/tests/Drupal/Tests/Core/TempStore/SharedTempStoreTest.php
@@ -147,7 +147,7 @@ public function testSetWithNoLockAvailable() {
     $this->lock->expects($this->exactly(2))
       ->method('acquire')
       ->with('test')
-      ->will($this->returnValue(FALSE));
+      ->willReturn(FALSE);
     $this->lock->expects($this->once())
       ->method('wait')
       ->with('test');
@@ -168,7 +168,7 @@ public function testSet() {
     $this->lock->expects($this->once())
       ->method('acquire')
       ->with('test')
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
     $this->lock->expects($this->never())
       ->method('wait');
     $this->lock->expects($this->once())
@@ -191,7 +191,7 @@ public function testSetIfNotExists() {
     $this->keyValue->expects($this->once())
       ->method('setWithExpireIfNotExists')
       ->with('test', $this->ownObject, 604800)
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
 
     $this->assertTrue($this->tempStore->setIfNotExists('test', 'test_data'));
   }
@@ -204,7 +204,7 @@ public function testSetIfNotExists() {
   public function testSetIfOwnerWhenNotExists() {
     $this->keyValue->expects($this->once())
       ->method('setWithExpireIfNotExists')
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
 
     $this->assertTrue($this->tempStore->setIfOwner('test', 'test_data'));
   }
@@ -217,12 +217,12 @@ public function testSetIfOwnerWhenNotExists() {
   public function testSetIfOwnerNoObject() {
     $this->keyValue->expects($this->once())
       ->method('setWithExpireIfNotExists')
-      ->will($this->returnValue(FALSE));
+      ->willReturn(FALSE);
 
     $this->keyValue->expects($this->once())
       ->method('get')
       ->with('test')
-      ->will($this->returnValue(FALSE));
+      ->willReturn(FALSE);
 
     $this->assertFalse($this->tempStore->setIfOwner('test', 'test_data'));
   }
@@ -236,11 +236,11 @@ public function testSetIfOwner() {
     $this->lock->expects($this->once())
       ->method('acquire')
       ->with('test')
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
 
     $this->keyValue->expects($this->exactly(2))
       ->method('setWithExpireIfNotExists')
-      ->will($this->returnValue(FALSE));
+      ->willReturn(FALSE);
 
     $this->keyValue->expects($this->exactly(2))
       ->method('get')
@@ -280,7 +280,7 @@ public function testDelete() {
     $this->lock->expects($this->once())
       ->method('acquire')
       ->with('test')
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
     $this->lock->expects($this->never())
       ->method('wait');
     $this->lock->expects($this->once())
@@ -303,7 +303,7 @@ public function testDeleteWithNoLockAvailable() {
     $this->lock->expects($this->exactly(2))
       ->method('acquire')
       ->with('test')
-      ->will($this->returnValue(FALSE));
+      ->willReturn(FALSE);
     $this->lock->expects($this->once())
       ->method('wait')
       ->with('test');
@@ -324,7 +324,7 @@ public function testDeleteIfOwner() {
     $this->lock->expects($this->once())
       ->method('acquire')
       ->with('test_2')
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
 
     $this->keyValue->expects($this->exactly(3))
       ->method('get')
diff --git a/core/tests/Drupal/Tests/Core/Theme/ThemeNegotiatorTest.php b/core/tests/Drupal/Tests/Core/Theme/ThemeNegotiatorTest.php
index 84a5970344a8dc814a7533921669d347bfb147ed..f0d372f10204e92184803933d41bd471e9e289e6 100644
--- a/core/tests/Drupal/Tests/Core/Theme/ThemeNegotiatorTest.php
+++ b/core/tests/Drupal/Tests/Core/Theme/ThemeNegotiatorTest.php
@@ -62,10 +62,10 @@ public function testDetermineActiveTheme() {
     $negotiator = $this->createMock('Drupal\Core\Theme\ThemeNegotiatorInterface');
     $negotiator->expects($this->once())
       ->method('determineActiveTheme')
-      ->will($this->returnValue('example_test'));
+      ->willReturn('example_test');
     $negotiator->expects($this->once())
       ->method('applies')
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
 
     $this->container->set('test_negotiator', $negotiator);
 
@@ -73,7 +73,7 @@ public function testDetermineActiveTheme() {
 
     $this->themeAccessCheck->expects($this->any())
       ->method('checkAccess')
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
 
     $route_match = new RouteMatch('test_route', new Route('/test-route'), [], []);
     $theme = $this->createThemeNegotiator($negotiators)->determineActiveTheme($route_match);
@@ -92,10 +92,10 @@ public function testDetermineActiveThemeWithPriority() {
     $negotiator = $this->createMock('Drupal\Core\Theme\ThemeNegotiatorInterface');
     $negotiator->expects($this->once())
       ->method('determineActiveTheme')
-      ->will($this->returnValue('example_test'));
+      ->willReturn('example_test');
     $negotiator->expects($this->once())
       ->method('applies')
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
 
     $negotiators['test_negotiator_1'] = $negotiator;
 
@@ -113,7 +113,7 @@ public function testDetermineActiveThemeWithPriority() {
 
     $this->themeAccessCheck->expects($this->any())
       ->method('checkAccess')
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
 
     $route_match = new RouteMatch('test_route', new Route('/test-route'), [], []);
     $theme = $this->createThemeNegotiator(array_keys($negotiators))->determineActiveTheme($route_match);
@@ -132,20 +132,20 @@ public function testDetermineActiveThemeWithAccessCheck() {
     $negotiator = $this->createMock('Drupal\Core\Theme\ThemeNegotiatorInterface');
     $negotiator->expects($this->once())
       ->method('determineActiveTheme')
-      ->will($this->returnValue('example_test'));
+      ->willReturn('example_test');
     $negotiator->expects($this->once())
       ->method('applies')
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
 
     $negotiators['test_negotiator_1'] = $negotiator;
 
     $negotiator = $this->createMock('Drupal\Core\Theme\ThemeNegotiatorInterface');
     $negotiator->expects($this->once())
       ->method('determineActiveTheme')
-      ->will($this->returnValue('example_test2'));
+      ->willReturn('example_test2');
     $negotiator->expects($this->once())
       ->method('applies')
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
 
     $negotiators['test_negotiator_2'] = $negotiator;
 
@@ -179,17 +179,17 @@ public function testDetermineActiveThemeWithNotApplyingNegotiator() {
       ->method('determineActiveTheme');
     $negotiator->expects($this->once())
       ->method('applies')
-      ->will($this->returnValue(FALSE));
+      ->willReturn(FALSE);
 
     $negotiators['test_negotiator_1'] = $negotiator;
 
     $negotiator = $this->createMock('Drupal\Core\Theme\ThemeNegotiatorInterface');
     $negotiator->expects($this->once())
       ->method('determineActiveTheme')
-      ->will($this->returnValue('example_test2'));
+      ->willReturn('example_test2');
     $negotiator->expects($this->once())
       ->method('applies')
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
 
     $negotiators['test_negotiator_2'] = $negotiator;
 
@@ -199,7 +199,7 @@ public function testDetermineActiveThemeWithNotApplyingNegotiator() {
 
     $this->themeAccessCheck->expects($this->any())
       ->method('checkAccess')
-      ->will($this->returnValue(TRUE));
+      ->willReturn(TRUE);
 
     $route_match = new RouteMatch('test_route', new Route('/test-route'), [], []);
     $theme = $this->createThemeNegotiator(array_keys($negotiators))->determineActiveTheme($route_match);
diff --git a/core/tests/Drupal/Tests/Core/UrlTest.php b/core/tests/Drupal/Tests/Core/UrlTest.php
index 2e4dea754f2157bb98af48251364e60a84eee14f..d9817a32a9304bf54520be6cdeba3ae58a5030fa 100644
--- a/core/tests/Drupal/Tests/Core/UrlTest.php
+++ b/core/tests/Drupal/Tests/Core/UrlTest.php
@@ -265,7 +265,7 @@ public function testCreateFromRequest() {
     $this->router->expects($this->once())
       ->method('matchRequest')
       ->with($request)
-      ->will($this->returnValue($attributes));
+      ->willReturn($attributes);
 
     $url = Url::createFromRequest($request);
     $expected = new Url('the_route_name', ['color' => 'chartreuse']);
@@ -357,14 +357,14 @@ public function testGetInternalPath($urls) {
     $map[] = ['node_view', ['node' => '1'], '/node/1'];
     $map[] = ['node_edit', ['node' => '2'], '/node/2/edit'];
 
-    foreach ($urls as $index => $url) {
+    foreach ($urls as $url) {
       // Clone the url so that there is no leak of internal state into the
       // other ones.
       $url = clone $url;
       $url_generator = $this->createMock('Drupal\Core\Routing\UrlGeneratorInterface');
       $url_generator->expects($this->once())
         ->method('getPathFromRoute')
-        ->will($this->returnValueMap($map, $index));
+        ->willReturnMap($map);
       $url->setUrlGenerator($url_generator);
 
       $url->getInternalPath();
diff --git a/core/tests/Drupal/Tests/Core/Utility/LinkGeneratorTest.php b/core/tests/Drupal/Tests/Core/Utility/LinkGeneratorTest.php
index d45d2b0f7130e74c31fa9d4c097c9ba0f62e144c..7d9596871055de159b15ade1aeebf7767595cc02 100644
--- a/core/tests/Drupal/Tests/Core/Utility/LinkGeneratorTest.php
+++ b/core/tests/Drupal/Tests/Core/Utility/LinkGeneratorTest.php
@@ -628,7 +628,7 @@ public function testGenerateWithAlterHook() {
   public function testGenerateTwice() {
     $this->urlGenerator->expects($this->any())
       ->method('generateFromRoute')
-      ->will($this->returnValue((new GeneratedUrl())->setGeneratedUrl('/')));
+      ->willReturn((new GeneratedUrl())->setGeneratedUrl('/'));
 
     $url = Url::fromRoute('<front>', [], ['attributes' => ['class' => ['foo', 'bar']]]);
     $url->setUrlGenerator($this->urlGenerator);
diff --git a/core/tests/Drupal/Tests/Core/Utility/TokenTest.php b/core/tests/Drupal/Tests/Core/Utility/TokenTest.php
index fdfa710554de71e074c8239dea29dc5ce13e047c..ae62e7c4eb3e59abb2f1e4f52e6d25939a867227 100644
--- a/core/tests/Drupal/Tests/Core/Utility/TokenTest.php
+++ b/core/tests/Drupal/Tests/Core/Utility/TokenTest.php
@@ -114,12 +114,12 @@ public function testGetInfo() {
 
     $this->language->expects($this->atLeastOnce())
       ->method('getId')
-      ->will($this->returnValue($this->randomMachineName()));
+      ->willReturn($this->randomMachineName());
 
     $this->languageManager->expects($this->once())
       ->method('getCurrentLanguage')
       ->with(LanguageInterface::TYPE_CONTENT)
-      ->will($this->returnValue($this->language));
+      ->willReturn($this->language);
 
     // The persistent cache must only be hit once, after which the info is
     // cached statically.
@@ -132,7 +132,7 @@ public function testGetInfo() {
     $this->moduleHandler->expects($this->once())
       ->method('invokeAll')
       ->with('token_info')
-      ->will($this->returnValue($token_info));
+      ->willReturn($token_info);
     $this->moduleHandler->expects($this->once())
       ->method('alter')
       ->with('token_info', $token_info);
diff --git a/core/tests/Drupal/Tests/UnitTestCase.php b/core/tests/Drupal/Tests/UnitTestCase.php
index 0191a49fa49d24d1676ca64c05c9d79f7608c2cc..0b40c075f8e899012867688933e9acff6febcfb4 100644
--- a/core/tests/Drupal/Tests/UnitTestCase.php
+++ b/core/tests/Drupal/Tests/UnitTestCase.php
@@ -178,13 +178,13 @@ public function getConfigStorageStub(array $configs) {
     $config_storage = $this->createMock('Drupal\Core\Config\NullStorage');
     $config_storage->expects($this->any())
       ->method('listAll')
-      ->will($this->returnValue(array_keys($configs)));
+      ->willReturn(array_keys($configs));
 
     foreach ($configs as $name => $config) {
       $config_storage->expects($this->any())
         ->method('read')
         ->with($this->equalTo($name))
-        ->will($this->returnValue($config));
+        ->willReturn($config);
     }
     return $config_storage;
   }
@@ -230,7 +230,7 @@ protected function getContainerWithCacheTagsInvalidator(CacheTagsInvalidatorInte
     $container->expects($this->any())
       ->method('get')
       ->with('cache_tags.invalidator')
-      ->will($this->returnValue($cache_tags_validator));
+      ->willReturn($cache_tags_validator);
 
     \Drupal::setContainer($container);
     return $container;