From 00efdb11e54475ce8e31dbf091826589ddaffda6 Mon Sep 17 00:00:00 2001 From: catch Date: Wed, 28 Jul 2021 11:57:46 +0100 Subject: [PATCH] Issue #3221312 by Spokje: ->willReturn(...) would make more sense here (cherry picked from commit 6335af17b43699c64f8eaf140964700199f9d318) --- .../src/Unit/CommentStatisticsUnitTest.php | 2 +- .../tests/src/Unit/ConfigNamesMapperTest.php | 6 +-- .../Menu/ContentTranslationLocalTasksTest.php | 9 ++-- ...dStorageConfigAccessControlHandlerTest.php | 4 +- .../ForumListingBreadcrumbBuilderTest.php | 10 ++-- .../ForumNodeBreadcrumbBuilderTest.php | 10 ++-- .../image/tests/src/Unit/ImageStyleTest.php | 2 +- .../tests/src/Unit/FormErrorHandlerTest.php | 5 +- .../src/Unit/JsonApiResource/LinkTest.php | 4 +- .../tests/src/Unit/LocaleLookupTest.php | 18 ++++--- .../tests/src/Unit/process/GetTest.php | 8 +-- .../src/Unit/process/MachineNameTest.php | 4 +- .../process/MakeUniqueEntityFieldTest.php | 10 ++-- .../PathProcessor/AliasPathProcessorTest.php | 8 +-- .../QuickEditEntityFieldAccessCheckTest.php | 8 +-- .../PathBasedBreadcrumbBuilderTest.php | 12 ++--- .../src/Unit/PermissionAccessCheckTest.php | 11 ++-- .../tests/src/Unit/PermissionHandlerTest.php | 4 +- .../src/Unit/UserAccessControlHandlerTest.php | 8 +-- .../src/Unit/Views/Argument/RolesRidTest.php | 9 ++-- .../Controller/ViewAjaxControllerTest.php | 5 +- .../EventSubscriber/RouteSubscriberTest.php | 8 +-- .../Plugin/argument_validator/EntityTest.php | 10 ++-- .../tests/src/Unit/ViewListBuilderTest.php | 8 +-- .../Plugin/Discovery/DiscoveryTraitTest.php | 4 +- .../Tests/Core/Access/AccessManagerTest.php | 13 ++--- .../Context/CacheContextsManagerTest.php | 50 +++++++++++++++---- .../Enhancer/ParamConversionEnhancerTest.php | 5 +- ...ityFormDisplayAccessControlHandlerTest.php | 12 ++--- ...ityViewDisplayAccessControlHandlerTest.php | 4 +- .../Core/Entity/EntityResolverManagerTest.php | 4 +- .../Tests/Core/Entity/EntityUnitTest.php | 4 +- .../Sql/SqlContentEntityStorageSchemaTest.php | 4 +- .../Sql/SqlContentEntityStorageTest.php | 44 ++++++++-------- .../CustomPageExceptionHtmlSubscriberTest.php | 8 +-- .../ModuleRouteSubscriberTest.php | 2 +- .../Tests/Core/Form/FormBuilderTest.php | 8 +-- .../Drupal/Tests/Core/Form/FormCacheTest.php | 4 +- .../Tests/Core/Form/FormSubmitterTest.php | 13 +++-- .../Drupal/Tests/Core/Form/FormTestBase.php | 2 +- .../Tests/Core/Logger/LoggerChannelTest.php | 4 +- .../Core/Menu/ContextualLinkManagerTest.php | 8 +-- .../DefaultMenuLinkTreeManipulatorsTest.php | 20 ++++++-- .../Core/Menu/LocalActionManagerTest.php | 2 +- .../Menu/LocalTaskIntegrationTestBase.php | 4 +- .../Tests/Core/Menu/LocalTaskManagerTest.php | 4 +- .../Tests/Core/Menu/MenuActiveTrailTest.php | 8 +-- .../Core/PathProcessor/PathProcessorTest.php | 2 +- .../Plugin/Discovery/HookDiscoveryTest.php | 19 +++++-- .../Plugin/LazyPluginCollectionTestBase.php | 2 +- .../Tests/Core/Routing/RouteBuilderTest.php | 9 ++-- .../Tests/Core/Routing/UrlGeneratorTest.php | 6 +-- .../Tests/Core/Session/UserSessionTest.php | 21 ++++---- .../TranslationManagerTest.php | 4 +- .../Tests/Core/Template/TwigExtensionTest.php | 4 +- .../PhpTransliterationTest.php | 4 +- core/tests/Drupal/Tests/Core/UrlTest.php | 4 +- .../Tests/Core/Utility/LinkGeneratorTest.php | 36 +++++++++---- core/tests/Drupal/Tests/UnitTestCase.php | 12 ++--- 59 files changed, 312 insertions(+), 225 deletions(-) diff --git a/core/modules/comment/tests/src/Unit/CommentStatisticsUnitTest.php b/core/modules/comment/tests/src/Unit/CommentStatisticsUnitTest.php index f24f456ced1..d8c390dfe87 100644 --- a/core/modules/comment/tests/src/Unit/CommentStatisticsUnitTest.php +++ b/core/modules/comment/tests/src/Unit/CommentStatisticsUnitTest.php @@ -57,7 +57,7 @@ class CommentStatisticsUnitTest extends UnitTestCase { $this->statement->expects($this->any()) ->method('fetchObject') - ->will($this->returnCallback([$this, 'fetchObjectCallback'])); + ->willReturnCallback([$this, 'fetchObjectCallback']); $this->select = $this->getMockBuilder('Drupal\Core\Database\Query\Select') ->disableOriginalConstructor() diff --git a/core/modules/config_translation/tests/src/Unit/ConfigNamesMapperTest.php b/core/modules/config_translation/tests/src/Unit/ConfigNamesMapperTest.php index fade477e22b..1a66307611c 100644 --- a/core/modules/config_translation/tests/src/Unit/ConfigNamesMapperTest.php +++ b/core/modules/config_translation/tests/src/Unit/ConfigNamesMapperTest.php @@ -506,7 +506,7 @@ class ConfigNamesMapperTest extends UnitTestCase { $this->typedConfigManager ->expects($this->any()) ->method('hasConfigSchema') - ->will($this->returnValueMap($map)); + ->willReturnMap($map); $result = $this->configNamesMapper->hasSchema(); $this->assertSame($expected, $result); @@ -553,7 +553,7 @@ class ConfigNamesMapperTest extends UnitTestCase { $this->configMapperManager ->expects($this->any()) ->method('hasTranslatable') - ->will($this->returnValueMap($map)); + ->willReturnMap($map); $result = $this->configNamesMapper->hasTranslatable(); $this->assertSame($expected, $result); @@ -604,7 +604,7 @@ class ConfigNamesMapperTest extends UnitTestCase { $this->localeConfigManager ->expects($this->any()) ->method('hasTranslation') - ->will($this->returnValueMap($map)); + ->willReturnMap($map); $result = $this->configNamesMapper->hasTranslation($language); $this->assertSame($expected, $result); 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 18385fd42f8..38ea3a308d0 100644 --- a/core/modules/content_translation/tests/src/Unit/Menu/ContentTranslationLocalTasksTest.php +++ b/core/modules/content_translation/tests/src/Unit/Menu/ContentTranslationLocalTasksTest.php @@ -21,10 +21,13 @@ class ContentTranslationLocalTasksTest extends LocalTaskIntegrationTestBase { $entity_type = $this->createMock('Drupal\Core\Entity\EntityTypeInterface'); $entity_type->expects($this->any()) ->method('getLinkTemplate') - ->will($this->returnValueMap([ + ->willReturnMap([ ['canonical', 'entity.node.canonical'], - ['drupal:content-translation-overview', 'entity.node.content_translation_overview'], - ])); + [ + 'drupal:content-translation-overview', + 'entity.node.content_translation_overview', + ], + ]); $content_translation_manager = $this->createMock('Drupal\content_translation\ContentTranslationManagerInterface'); $content_translation_manager->expects($this->any()) ->method('getSupportedEntityTypes') diff --git a/core/modules/field/tests/src/Unit/FieldStorageConfigAccessControlHandlerTest.php b/core/modules/field/tests/src/Unit/FieldStorageConfigAccessControlHandlerTest.php index 3539b97a6fa..f613d08cd18 100644 --- a/core/modules/field/tests/src/Unit/FieldStorageConfigAccessControlHandlerTest.php +++ b/core/modules/field/tests/src/Unit/FieldStorageConfigAccessControlHandlerTest.php @@ -78,9 +78,9 @@ class FieldStorageConfigAccessControlHandlerTest extends UnitTestCase { $this->member ->expects($this->any()) ->method('hasPermission') - ->will($this->returnValueMap([ + ->willReturnMap([ ['administer node fields', TRUE], - ])); + ]); $this->member ->expects($this->any()) ->method('id') diff --git a/core/modules/forum/tests/src/Unit/Breadcrumb/ForumListingBreadcrumbBuilderTest.php b/core/modules/forum/tests/src/Unit/Breadcrumb/ForumListingBreadcrumbBuilderTest.php index f353a284bb1..39351231c5a 100644 --- a/core/modules/forum/tests/src/Unit/Breadcrumb/ForumListingBreadcrumbBuilderTest.php +++ b/core/modules/forum/tests/src/Unit/Breadcrumb/ForumListingBreadcrumbBuilderTest.php @@ -68,7 +68,7 @@ class ForumListingBreadcrumbBuilderTest extends UnitTestCase { ->will($this->returnValue($route_name)); $route_match->expects($this->any()) ->method('getParameter') - ->will($this->returnValueMap($parameter_map)); + ->willReturnMap($parameter_map); $this->assertEquals($expected, $builder->applies($route_match)); } @@ -159,19 +159,19 @@ class ForumListingBreadcrumbBuilderTest extends UnitTestCase { $vocab_storage = $this->createMock('Drupal\Core\Entity\EntityStorageInterface'); $vocab_storage->expects($this->any()) ->method('load') - ->will($this->returnValueMap([ + ->willReturnMap([ ['forums', $prophecy->reveal()], - ])); + ]); $entity_type_manager = $this->getMockBuilder(EntityTypeManagerInterface::class) ->disableOriginalConstructor() ->getMock(); $entity_type_manager->expects($this->any()) ->method('getStorage') - ->will($this->returnValueMap([ + ->willReturnMap([ ['taxonomy_vocabulary', $vocab_storage], ['taxonomy_term', $term_storage], - ])); + ]); $config_factory = $this->getConfigFactoryStub( [ diff --git a/core/modules/forum/tests/src/Unit/Breadcrumb/ForumNodeBreadcrumbBuilderTest.php b/core/modules/forum/tests/src/Unit/Breadcrumb/ForumNodeBreadcrumbBuilderTest.php index 17ce97ba07e..1c37a806dff 100644 --- a/core/modules/forum/tests/src/Unit/Breadcrumb/ForumNodeBreadcrumbBuilderTest.php +++ b/core/modules/forum/tests/src/Unit/Breadcrumb/ForumNodeBreadcrumbBuilderTest.php @@ -75,7 +75,7 @@ class ForumNodeBreadcrumbBuilderTest extends UnitTestCase { ->will($this->returnValue($route_name)); $route_match->expects($this->any()) ->method('getParameter') - ->will($this->returnValueMap($parameter_map)); + ->willReturnMap($parameter_map); $this->assertEquals($expected, $builder->applies($route_match)); } @@ -169,19 +169,19 @@ class ForumNodeBreadcrumbBuilderTest extends UnitTestCase { $vocab_storage = $this->createMock('Drupal\Core\Entity\EntityStorageInterface'); $vocab_storage->expects($this->any()) ->method('load') - ->will($this->returnValueMap([ + ->willReturnMap([ ['forums', $prophecy->reveal()], - ])); + ]); $entity_type_manager = $this->getMockBuilder(EntityTypeManagerInterface::class) ->disableOriginalConstructor() ->getMock(); $entity_type_manager->expects($this->any()) ->method('getStorage') - ->will($this->returnValueMap([ + ->willReturnMap([ ['taxonomy_vocabulary', $vocab_storage], ['taxonomy_term', $term_storage], - ])); + ]); $config_factory = $this->getConfigFactoryStub( [ diff --git a/core/modules/image/tests/src/Unit/ImageStyleTest.php b/core/modules/image/tests/src/Unit/ImageStyleTest.php index a0fb5fd28d1..4a3f1830d65 100644 --- a/core/modules/image/tests/src/Unit/ImageStyleTest.php +++ b/core/modules/image/tests/src/Unit/ImageStyleTest.php @@ -73,7 +73,7 @@ class ImageStyleTest extends UnitTestCase { ->will($this->returnValue($effectManager)); $image_style->expects($this->any()) ->method('fileDefaultScheme') - ->will($this->returnCallback([$this, 'fileDefaultScheme'])); + ->willReturnCallback([$this, 'fileDefaultScheme']); return $image_style; } diff --git a/core/modules/inline_form_errors/tests/src/Unit/FormErrorHandlerTest.php b/core/modules/inline_form_errors/tests/src/Unit/FormErrorHandlerTest.php index b4265043e1c..962f1079559 100644 --- a/core/modules/inline_form_errors/tests/src/Unit/FormErrorHandlerTest.php +++ b/core/modules/inline_form_errors/tests/src/Unit/FormErrorHandlerTest.php @@ -129,13 +129,14 @@ class FormErrorHandlerTest extends UnitTestCase { $this->renderer->expects($this->once()) ->method('renderPlain') - ->will($this->returnCallback(function ($render_array) { + ->willReturnCallback(function ($render_array) { $links = []; foreach ($render_array[1]['#items'] as $item) { $links[] = htmlspecialchars($item['#title']); } + return $render_array[0]['#markup'] . '' . implode('', $links) . ''; - })); + }); $form_state = new FormState(); $form_state->setErrorByName('test1', 'invalid'); diff --git a/core/modules/jsonapi/tests/src/Unit/JsonApiResource/LinkTest.php b/core/modules/jsonapi/tests/src/Unit/JsonApiResource/LinkTest.php index 8d16b46f231..518b8b2e35a 100644 --- a/core/modules/jsonapi/tests/src/Unit/JsonApiResource/LinkTest.php +++ b/core/modules/jsonapi/tests/src/Unit/JsonApiResource/LinkTest.php @@ -134,9 +134,9 @@ class LinkTest extends UnitTestCase { $url_assembler = $this->getMockBuilder(UnroutedUrlAssemblerInterface::class) ->disableOriginalConstructor() ->getMock(); - $url_assembler->method('assemble')->will($this->returnCallback(function ($uri) { + $url_assembler->method('assemble')->willReturnCallback(function ($uri) { return (new GeneratedUrl())->setGeneratedUrl($uri); - })); + }); $container = new ContainerBuilder(); $container->set('unrouted_url_assembler', $url_assembler); diff --git a/core/modules/locale/tests/src/Unit/LocaleLookupTest.php b/core/modules/locale/tests/src/Unit/LocaleLookupTest.php index 03c0f725ecd..c1999d19c54 100644 --- a/core/modules/locale/tests/src/Unit/LocaleLookupTest.php +++ b/core/modules/locale/tests/src/Unit/LocaleLookupTest.php @@ -157,16 +157,17 @@ class LocaleLookupTest extends UnitTestCase { // cSpell:enable $this->storage->expects($this->any()) ->method('findTranslation') - ->will($this->returnCallback(function ($argument) use ($translations) { + ->willReturnCallback(function ($argument) use ($translations) { if (isset($translations[$argument['language']][$argument['source']])) { return (object) ['translation' => $translations[$argument['language']][$argument['source']]]; } + return TRUE; - })); + }); $this->languageManager->expects($this->any()) ->method('getFallbackCandidates') - ->will($this->returnCallback(function (array $context = []) { + ->willReturnCallback(function (array $context = []) { switch ($context['langcode']) { case 'pl': return ['cs', 'en']; @@ -177,7 +178,7 @@ class LocaleLookupTest extends UnitTestCase { default: return []; } - })); + }); $this->cache->expects($this->once()) ->method('get') @@ -289,20 +290,21 @@ class LocaleLookupTest extends UnitTestCase { public function testFixOldPluralStyleTranslations($translations, $langcode, $string, $is_fix) { $this->storage->expects($this->any()) ->method('findTranslation') - ->will($this->returnCallback(function ($argument) use ($translations) { + ->willReturnCallback(function ($argument) use ($translations) { if (isset($translations[$argument['language']][$argument['source']])) { return (object) ['translation' => $translations[$argument['language']][$argument['source']]]; } + return TRUE; - })); + }); $this->languageManager->expects($this->any()) ->method('getFallbackCandidates') - ->will($this->returnCallback(function (array $context = []) { + ->willReturnCallback(function (array $context = []) { switch ($context['langcode']) { case 'by': return ['ru']; } - })); + }); $this->cache->expects($this->once()) ->method('get') ->with('locale:' . $langcode . '::anonymous', FALSE); diff --git a/core/modules/migrate/tests/src/Unit/process/GetTest.php b/core/modules/migrate/tests/src/Unit/process/GetTest.php index bb6c177019a..f9793bb8e2d 100644 --- a/core/modules/migrate/tests/src/Unit/process/GetTest.php +++ b/core/modules/migrate/tests/src/Unit/process/GetTest.php @@ -35,9 +35,9 @@ class GetTest extends MigrateProcessTestCase { $this->plugin = new Get(['source' => ['test1', 'test2']], '', []); $this->row->expects($this->exactly(2)) ->method('get') - ->will($this->returnCallback(function ($argument) use ($map) { + ->willReturnCallback(function ($argument) use ($map) { return $map[$argument]; - })); + }); $value = $this->plugin->transform(NULL, $this->migrateExecutable, $this->row, 'destination_property'); $this->assertSame(['source_value1', 'source_value2'], $value); } @@ -68,9 +68,9 @@ class GetTest extends MigrateProcessTestCase { $this->plugin = new Get(['source' => ['test1', '@@test2', '@@test3', 'test4']], '', []); $this->row->expects($this->exactly(4)) ->method('get') - ->will($this->returnCallback(function ($argument) use ($map) { + ->willReturnCallback(function ($argument) use ($map) { return $map[$argument]; - })); + }); $value = $this->plugin->transform(NULL, $this->migrateExecutable, $this->row, 'destination_property'); $this->assertSame(['source_value1', 'source_value2', 'source_value3', 'source_value4'], $value); } diff --git a/core/modules/migrate/tests/src/Unit/process/MachineNameTest.php b/core/modules/migrate/tests/src/Unit/process/MachineNameTest.php index 6856492af92..fe082acbdbc 100644 --- a/core/modules/migrate/tests/src/Unit/process/MachineNameTest.php +++ b/core/modules/migrate/tests/src/Unit/process/MachineNameTest.php @@ -53,9 +53,9 @@ class MachineNameTest extends MigrateProcessTestCase { ->expects($this->once()) ->method('transliterate') ->with($human_name) - ->will($this->returnCallback(function (string $string): string { + ->willReturnCallback(function (string $string): string { return str_replace(['á', 'é', 'ő'], ['a', 'e', 'o'], $string); - })); + }); $plugin = new MachineName($configuration, 'machine_name', [], $this->transliteration); $value = $plugin->transform($human_name, $this->migrateExecutable, $this->row, 'destination_property'); diff --git a/core/modules/migrate/tests/src/Unit/process/MakeUniqueEntityFieldTest.php b/core/modules/migrate/tests/src/Unit/process/MakeUniqueEntityFieldTest.php index 9b269d9bf3d..eb2a60ff823 100644 --- a/core/modules/migrate/tests/src/Unit/process/MakeUniqueEntityFieldTest.php +++ b/core/modules/migrate/tests/src/Unit/process/MakeUniqueEntityFieldTest.php @@ -168,9 +168,9 @@ class MakeUniqueEntityFieldTest extends MigrateProcessTestCase { ->will($this->returnValue($this->entityQuery)); $this->entityQuery->expects($this->exactly($count + 1)) ->method('execute') - ->will($this->returnCallback(function () use (&$count) { + ->willReturnCallback(function () use (&$count) { return $count--; - })); + }); } /** @@ -198,15 +198,15 @@ class MakeUniqueEntityFieldTest extends MigrateProcessTestCase { } $this->entityQuery ->method('condition') - ->will($this->returnValueMap($map)); + ->willReturnMap($map); // Entity 'forums' is pre-existing, entity 'test_vocab' was migrated. $this->idMap ->method('lookupSourceId') - ->will($this->returnValueMap([ + ->willReturnMap([ [['test_field' => 'forums'], FALSE], [['test_field' => 'test_vocab'], ['source_id' => 42]], - ])); + ]); // Existing entity 'forums' was not migrated, value should not be unique. $actual = $plugin->transform('forums', $this->migrateExecutable, $this->row, 'testproperty'); diff --git a/core/modules/path_alias/tests/src/Unit/PathProcessor/AliasPathProcessorTest.php b/core/modules/path_alias/tests/src/Unit/PathProcessor/AliasPathProcessorTest.php index a616f5b8296..5da232eb452 100644 --- a/core/modules/path_alias/tests/src/Unit/PathProcessor/AliasPathProcessorTest.php +++ b/core/modules/path_alias/tests/src/Unit/PathProcessor/AliasPathProcessorTest.php @@ -42,10 +42,10 @@ class AliasPathProcessorTest extends UnitTestCase { public function testProcessInbound() { $this->aliasManager->expects($this->exactly(2)) ->method('getPathByAlias') - ->will($this->returnValueMap([ + ->willReturnMap([ ['urlalias', NULL, 'internal-url'], ['url', NULL, 'url'], - ])); + ]); $request = Request::create('/urlalias'); $this->assertEquals('internal-url', $this->pathProcessor->processInbound('urlalias', $request)); @@ -61,10 +61,10 @@ class AliasPathProcessorTest extends UnitTestCase { public function testProcessOutbound($path, array $options, $expected_path) { $this->aliasManager->expects($this->any()) ->method('getAliasByPath') - ->will($this->returnValueMap([ + ->willReturnMap([ ['internal-url', NULL, 'urlalias'], ['url', NULL, 'url'], - ])); + ]); $bubbleable_metadata = new BubbleableMetadata(); $this->assertEquals($expected_path, $this->pathProcessor->processOutbound($path, $options, NULL, $bubbleable_metadata)); diff --git a/core/modules/quickedit/tests/src/Unit/Access/QuickEditEntityFieldAccessCheckTest.php b/core/modules/quickedit/tests/src/Unit/Access/QuickEditEntityFieldAccessCheckTest.php index 1fb2143f0f7..da94752cf9b 100644 --- a/core/modules/quickedit/tests/src/Unit/Access/QuickEditEntityFieldAccessCheckTest.php +++ b/core/modules/quickedit/tests/src/Unit/Access/QuickEditEntityFieldAccessCheckTest.php @@ -132,16 +132,16 @@ class QuickEditEntityFieldAccessCheckTest extends UnitTestCase { $entity->expects($this->any()) ->method('hasTranslation') - ->will($this->returnValueMap([ + ->willReturnMap([ [LanguageInterface::LANGCODE_NOT_SPECIFIED, TRUE], ['xx-lolspeak', FALSE], - ])); + ]); $entity->expects($this->any()) ->method('hasField') - ->will($this->returnValueMap([ + ->willReturnMap([ ['valid', TRUE], ['not_valid', FALSE], - ])); + ]); return $entity; } diff --git a/core/modules/system/tests/src/Unit/Breadcrumbs/PathBasedBreadcrumbBuilderTest.php b/core/modules/system/tests/src/Unit/Breadcrumbs/PathBasedBreadcrumbBuilderTest.php index 0b0c1e4aaad..ca5cc68fb9b 100644 --- a/core/modules/system/tests/src/Unit/Breadcrumbs/PathBasedBreadcrumbBuilderTest.php +++ b/core/modules/system/tests/src/Unit/Breadcrumbs/PathBasedBreadcrumbBuilderTest.php @@ -189,7 +189,7 @@ class PathBasedBreadcrumbBuilderTest extends UnitTestCase { $this->requestMatcher->expects($this->exactly(1)) ->method('matchRequest') - ->will($this->returnCallback(function (Request $request) use ($route_1) { + ->willReturnCallback(function (Request $request) use ($route_1) { if ($request->getPathInfo() == '/example') { return [ RouteObjectInterface::ROUTE_NAME => 'example', @@ -197,7 +197,7 @@ class PathBasedBreadcrumbBuilderTest extends UnitTestCase { '_raw_variables' => new ParameterBag([]), ]; } - })); + }); $this->setupAccessManagerToAllow(); @@ -229,7 +229,7 @@ class PathBasedBreadcrumbBuilderTest extends UnitTestCase { $this->requestMatcher->expects($this->exactly(2)) ->method('matchRequest') - ->will($this->returnCallback(function (Request $request) use ($route_1, $route_2) { + ->willReturnCallback(function (Request $request) use ($route_1, $route_2) { if ($request->getPathInfo() == '/example/bar') { return [ RouteObjectInterface::ROUTE_NAME => 'example_bar', @@ -244,7 +244,7 @@ class PathBasedBreadcrumbBuilderTest extends UnitTestCase { '_raw_variables' => new ParameterBag([]), ]; } - })); + }); $this->accessManager->expects($this->any()) ->method('check') @@ -364,7 +364,7 @@ class PathBasedBreadcrumbBuilderTest extends UnitTestCase { $this->requestMatcher->expects($this->exactly(1)) ->method('matchRequest') - ->will($this->returnCallback(function (Request $request) use ($route_1) { + ->willReturnCallback(function (Request $request) use ($route_1) { if ($request->getPathInfo() == '/user/1') { return [ RouteObjectInterface::ROUTE_NAME => 'user_page', @@ -372,7 +372,7 @@ class PathBasedBreadcrumbBuilderTest extends UnitTestCase { '_raw_variables' => new ParameterBag([]), ]; } - })); + }); $this->setupAccessManagerToAllow(); $this->titleResolver->expects($this->once()) diff --git a/core/modules/user/tests/src/Unit/PermissionAccessCheckTest.php b/core/modules/user/tests/src/Unit/PermissionAccessCheckTest.php index b82a4df21df..8ffce00cddd 100644 --- a/core/modules/user/tests/src/Unit/PermissionAccessCheckTest.php +++ b/core/modules/user/tests/src/Unit/PermissionAccessCheckTest.php @@ -76,12 +76,11 @@ class PermissionAccessCheckTest extends UnitTestCase { $user = $this->createMock('Drupal\Core\Session\AccountInterface'); $user->expects($this->any()) ->method('hasPermission') - ->will($this->returnValueMap([ - ['allowed', TRUE], - ['denied', FALSE], - ['other', FALSE], - ] - )); + ->willReturnMap([ + ['allowed', TRUE], + ['denied', FALSE], + ['other', FALSE], + ]); $route = new Route('', [], $requirements); $this->assertEquals($access_result, $this->accessCheck->access($route, $user)); diff --git a/core/modules/user/tests/src/Unit/PermissionHandlerTest.php b/core/modules/user/tests/src/Unit/PermissionHandlerTest.php index 6a45251033c..36d9254229d 100644 --- a/core/modules/user/tests/src/Unit/PermissionHandlerTest.php +++ b/core/modules/user/tests/src/Unit/PermissionHandlerTest.php @@ -171,11 +171,11 @@ EOF ]); $this->moduleHandler->expects($this->exactly(3)) ->method('getName') - ->will($this->returnValueMap([ + ->willReturnMap([ ['module_a', 'Module a'], ['module_b', 'Module b'], ['module_c', 'A Module'], - ])); + ]); $url = vfsStream::url('modules'); mkdir($url . '/module_a'); diff --git a/core/modules/user/tests/src/Unit/UserAccessControlHandlerTest.php b/core/modules/user/tests/src/Unit/UserAccessControlHandlerTest.php index 54b34eae100..2e29bb43e16 100644 --- a/core/modules/user/tests/src/Unit/UserAccessControlHandlerTest.php +++ b/core/modules/user/tests/src/Unit/UserAccessControlHandlerTest.php @@ -87,10 +87,10 @@ class UserAccessControlHandlerTest extends UnitTestCase { $this->owner ->expects($this->any()) ->method('hasPermission') - ->will($this->returnValueMap([ + ->willReturnMap([ ['administer users', FALSE], ['change own username', TRUE], - ])); + ]); $this->owner ->expects($this->any()) @@ -107,9 +107,9 @@ class UserAccessControlHandlerTest extends UnitTestCase { $this->emailViewer ->expects($this->any()) ->method('hasPermission') - ->will($this->returnValueMap([ + ->willReturnMap([ ['view user email addresses', TRUE], - ])); + ]); $this->emailViewer ->expects($this->any()) ->method('id') 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 8aa71c2a335..dc1f9eae9cc 100644 --- a/core/modules/user/tests/src/Unit/Views/Argument/RolesRidTest.php +++ b/core/modules/user/tests/src/Unit/Views/Argument/RolesRidTest.php @@ -33,11 +33,14 @@ class RolesRidTest extends UnitTestCase { $role_storage = $this->getMockForAbstractClass('Drupal\Core\Entity\EntityStorageInterface'); $role_storage->expects($this->any()) ->method('loadMultiple') - ->will($this->returnValueMap([ + ->willReturnMap([ [[], []], [['test_rid_1'], ['test_rid_1' => $role1]], - [['test_rid_1', 'test_rid_2'], ['test_rid_1' => $role1, 'test_rid_2' => $role2]], - ])); + [ + ['test_rid_1', 'test_rid_2'], + ['test_rid_1' => $role1, 'test_rid_2' => $role2], + ], + ]); $entity_type = $this->createMock('Drupal\Core\Entity\EntityTypeInterface'); $entity_type->expects($this->any()) diff --git a/core/modules/views/tests/src/Unit/Controller/ViewAjaxControllerTest.php b/core/modules/views/tests/src/Unit/Controller/ViewAjaxControllerTest.php index 28349f20807..81b15bb0d11 100644 --- a/core/modules/views/tests/src/Unit/Controller/ViewAjaxControllerTest.php +++ b/core/modules/views/tests/src/Unit/Controller/ViewAjaxControllerTest.php @@ -74,10 +74,11 @@ class ViewAjaxControllerTest extends UnitTestCase { $this->renderer = $this->createMock('\Drupal\Core\Render\RendererInterface'); $this->renderer->expects($this->any()) ->method('render') - ->will($this->returnCallback(function (array &$elements) { + ->willReturnCallback(function (array &$elements) { $elements['#attached'] = []; + return isset($elements['#markup']) ? $elements['#markup'] : ''; - })); + }); $this->renderer->expects($this->any()) ->method('executeInRenderContext') ->willReturnCallback(function (RenderContext $context, callable $callable) { diff --git a/core/modules/views/tests/src/Unit/EventSubscriber/RouteSubscriberTest.php b/core/modules/views/tests/src/Unit/EventSubscriber/RouteSubscriberTest.php index 3e290b460fa..ec59ed0b007 100644 --- a/core/modules/views/tests/src/Unit/EventSubscriber/RouteSubscriberTest.php +++ b/core/modules/views/tests/src/Unit/EventSubscriber/RouteSubscriberTest.php @@ -164,11 +164,11 @@ class RouteSubscriberTest extends UnitTestCase { $executable->expects($this->any()) ->method('setDisplay') - ->will($this->returnValueMap([ + ->willReturnMap([ ['page_1', TRUE], ['page_2', TRUE], ['page_3', FALSE], - ])); + ]); // Ensure that only the first two displays are actually called. $display_1 = $this->createMock('Drupal\views\Plugin\views\display\DisplayRouterInterface'); @@ -179,10 +179,10 @@ class RouteSubscriberTest extends UnitTestCase { ->getMock(); $display_collection->expects($this->any()) ->method('get') - ->will($this->returnValueMap([ + ->willReturnMap([ ['page_1', $display_1], ['page_2', $display_2], - ])); + ]); $executable->displayHandlers = $display_collection; $this->routeSubscriber->applicableViews = []; 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 d04ab897d66..74eb8d5c478 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 @@ -63,11 +63,11 @@ class EntityTest extends UnitTestCase { ->will($this->returnValue('test_bundle')); $mock_entity->expects($this->any()) ->method('access') - ->will($this->returnValueMap([ + ->willReturnMap([ ['test_op', NULL, FALSE, TRUE], ['test_op_2', NULL, FALSE, FALSE], ['test_op_3', NULL, FALSE, TRUE], - ])); + ]); $mock_entity_bundle_2 = $this->getMockForAbstractClass('Drupal\Core\Entity\EntityBase', [], '', FALSE, TRUE, TRUE, ['bundle', 'access']); $mock_entity_bundle_2->expects($this->any()) @@ -75,11 +75,11 @@ class EntityTest extends UnitTestCase { ->will($this->returnValue('test_bundle_2')); $mock_entity_bundle_2->expects($this->any()) ->method('access') - ->will($this->returnValueMap([ + ->willReturnMap([ ['test_op', NULL, FALSE, FALSE], ['test_op_2', NULL, FALSE, FALSE], ['test_op_3', NULL, FALSE, TRUE], - ])); + ]); $storage = $this->createMock('Drupal\Core\Entity\EntityStorageInterface'); @@ -95,7 +95,7 @@ class EntityTest extends UnitTestCase { ]; $storage->expects($this->any()) ->method('loadMultiple') - ->will($this->returnValueMap($value_map)); + ->willReturnMap($value_map); $this->entityTypeManager->expects($this->any()) ->method('getStorage') diff --git a/core/modules/views_ui/tests/src/Unit/ViewListBuilderTest.php b/core/modules/views_ui/tests/src/Unit/ViewListBuilderTest.php index d6274619aad..39467130ee4 100644 --- a/core/modules/views_ui/tests/src/Unit/ViewListBuilderTest.php +++ b/core/modules/views_ui/tests/src/Unit/ViewListBuilderTest.php @@ -38,7 +38,7 @@ class ViewListBuilderTest extends UnitTestCase { $display_manager->expects($this->any()) ->method('getDefinition') - ->will($this->returnValueMap([ + ->willReturnMap([ [ 'default', TRUE, @@ -73,7 +73,7 @@ class ViewListBuilderTest extends UnitTestCase { 'admin' => 'Embed admin label', ], ], - ])); + ]); $default_display = $this->getMockBuilder('Drupal\views\Plugin\views\display\DefaultDisplay') ->setMethods(['initDisplay']) @@ -125,13 +125,13 @@ class ViewListBuilderTest extends UnitTestCase { $display_manager->expects($this->any()) ->method('createInstance') - ->will($this->returnValueMap([ + ->willReturnMap([ ['default', $values['display']['default'], $default_display], ['page', $values['display']['page_1'], $page_display], ['page', $values['display']['page_2'], $page_display], ['page', $values['display']['page_3'], $page_display], ['embed', $values['display']['embed'], $embed_display], - ])); + ]); $container = new ContainerBuilder(); $user = $this->createMock('Drupal\Core\Session\AccountInterface'); diff --git a/core/tests/Drupal/Tests/Component/Plugin/Discovery/DiscoveryTraitTest.php b/core/tests/Drupal/Tests/Component/Plugin/Discovery/DiscoveryTraitTest.php index b5c7bbbf0b4..bbcf25b2832 100644 --- a/core/tests/Drupal/Tests/Component/Plugin/Discovery/DiscoveryTraitTest.php +++ b/core/tests/Drupal/Tests/Component/Plugin/Discovery/DiscoveryTraitTest.php @@ -136,10 +136,10 @@ class DiscoveryTraitTest extends TestCase { // for 'not_valid'. $trait->expects($this->once()) ->method('getDefinition') - ->will($this->returnValueMap([ + ->willReturnMap([ ['valid', FALSE, TRUE], ['not_valid', FALSE, FALSE], - ])); + ]); // Call hasDefinition(). $this->assertSame( $expected, diff --git a/core/tests/Drupal/Tests/Core/Access/AccessManagerTest.php b/core/tests/Drupal/Tests/Core/Access/AccessManagerTest.php index 264b2bde3b5..b35ea140ef0 100644 --- a/core/tests/Drupal/Tests/Core/Access/AccessManagerTest.php +++ b/core/tests/Drupal/Tests/Core/Access/AccessManagerTest.php @@ -113,7 +113,7 @@ class AccessManagerTest extends UnitTestCase { $map[] = ['test_route_4', $this->routeCollection->get('test_route_4')]; $this->routeProvider->expects($this->any()) ->method('getRouteByName') - ->will($this->returnValueMap($map)); + ->willReturnMap($map); $map = []; $map[] = ['test_route_1', [], '/test-route-1']; @@ -173,9 +173,9 @@ class AccessManagerTest extends UnitTestCase { $access_check->expects($this->exactly(2)) ->method('applies') ->with($this->isInstanceOf('Symfony\Component\Routing\Route')) - ->will($this->returnCallback(function (Route $route) { - return $route->getRequirement('_bar') == 2; - })); + ->willReturnCallback(function (Route $route) { + return $route->getRequirement('_bar') == 2; + }); $this->checkProvider->setChecks($collection); $this->assertEmpty($route->getOption('_access_checks')); @@ -535,15 +535,16 @@ class AccessManagerTest extends UnitTestCase { } return $this->argumentsResolverFactory->expects($constraint) ->method('getArgumentsResolver') - ->will($this->returnCallback(function ($route_match, $account) { + ->willReturnCallback(function ($route_match, $account) { $resolver = $this->createMock('Drupal\Component\Utility\ArgumentsResolverInterface'); $resolver->expects($this->any()) ->method('getArguments') ->will($this->returnCallback(function ($callable) use ($route_match) { return [$route_match->getRouteObject()]; })); + return $resolver; - })); + }); } } diff --git a/core/tests/Drupal/Tests/Core/Cache/Context/CacheContextsManagerTest.php b/core/tests/Drupal/Tests/Core/Cache/Context/CacheContextsManagerTest.php index 7b5768d3fc6..2066b5ef3fe 100644 --- a/core/tests/Drupal/Tests/Core/Cache/Context/CacheContextsManagerTest.php +++ b/core/tests/Drupal/Tests/Core/Cache/Context/CacheContextsManagerTest.php @@ -32,13 +32,33 @@ class CacheContextsManagerTest extends UnitTestCase { ->getMock(); $container->expects($this->any()) ->method('get') - ->will($this->returnValueMap([ - ['cache_context.a', Container::EXCEPTION_ON_INVALID_REFERENCE, new FooCacheContext()], - ['cache_context.a.b', Container::EXCEPTION_ON_INVALID_REFERENCE, new FooCacheContext()], - ['cache_context.a.b.c', Container::EXCEPTION_ON_INVALID_REFERENCE, new BazCacheContext()], - ['cache_context.x', Container::EXCEPTION_ON_INVALID_REFERENCE, new BazCacheContext()], - ['cache_context.a.b.no-optimize', Container::EXCEPTION_ON_INVALID_REFERENCE, new NoOptimizeCacheContext()], - ])); + ->willReturnMap([ + [ + 'cache_context.a', + Container::EXCEPTION_ON_INVALID_REFERENCE, + new FooCacheContext(), + ], + [ + 'cache_context.a.b', + Container::EXCEPTION_ON_INVALID_REFERENCE, + new FooCacheContext(), + ], + [ + 'cache_context.a.b.c', + Container::EXCEPTION_ON_INVALID_REFERENCE, + new BazCacheContext(), + ], + [ + 'cache_context.x', + Container::EXCEPTION_ON_INVALID_REFERENCE, + new BazCacheContext(), + ], + [ + 'cache_context.a.b.no-optimize', + Container::EXCEPTION_ON_INVALID_REFERENCE, + new NoOptimizeCacheContext(), + ], + ]); $cache_contexts_manager = new CacheContextsManager($container, $this->getContextsFixture()); $this->assertSame($optimized_context_tokens, $cache_contexts_manager->optimizeTokens($context_tokens)); @@ -161,10 +181,18 @@ class CacheContextsManagerTest extends UnitTestCase { ->getMock(); $container->expects($this->any()) ->method('get') - ->will($this->returnValueMap([ - ['cache_context.foo', Container::EXCEPTION_ON_INVALID_REFERENCE, new FooCacheContext()], - ['cache_context.baz', Container::EXCEPTION_ON_INVALID_REFERENCE, new BazCacheContext()], - ])); + ->willReturnMap([ + [ + 'cache_context.foo', + Container::EXCEPTION_ON_INVALID_REFERENCE, + new FooCacheContext(), + ], + [ + 'cache_context.baz', + Container::EXCEPTION_ON_INVALID_REFERENCE, + new BazCacheContext(), + ], + ]); return $container; } diff --git a/core/tests/Drupal/Tests/Core/Enhancer/ParamConversionEnhancerTest.php b/core/tests/Drupal/Tests/Core/Enhancer/ParamConversionEnhancerTest.php index 148f846cd17..8b2969d70c0 100644 --- a/core/tests/Drupal/Tests/Core/Enhancer/ParamConversionEnhancerTest.php +++ b/core/tests/Drupal/Tests/Core/Enhancer/ParamConversionEnhancerTest.php @@ -84,11 +84,12 @@ class ParamConversionEnhancerTest extends UnitTestCase { $this->paramConverterManager->expects($this->any()) ->method('convert') ->with($this->isType('array')) - ->will($this->returnCallback(function ($defaults) { + ->willReturnCallback(function ($defaults) { // Convert the mirrored default to another value. $defaults['bar'] = '2'; + return $defaults; - })); + }); $expected = new ParameterBag(['id' => 1]); $result = $this->paramConversionEnhancer->enhance($defaults, new Request()); $this->assertEquals($result['_raw_variables'], $expected); diff --git a/core/tests/Drupal/Tests/Core/Entity/Access/EntityFormDisplayAccessControlHandlerTest.php b/core/tests/Drupal/Tests/Core/Entity/Access/EntityFormDisplayAccessControlHandlerTest.php index 38611d70e4e..b262aa89872 100644 --- a/core/tests/Drupal/Tests/Core/Entity/Access/EntityFormDisplayAccessControlHandlerTest.php +++ b/core/tests/Drupal/Tests/Core/Entity/Access/EntityFormDisplayAccessControlHandlerTest.php @@ -99,9 +99,9 @@ class EntityFormDisplayAccessControlHandlerTest extends UnitTestCase { $this->member ->expects($this->any()) ->method('hasPermission') - ->will($this->returnValueMap([ + ->willReturnMap([ ['administer foobar form display', TRUE], - ])); + ]); $this->member ->expects($this->any()) ->method('id') @@ -111,9 +111,9 @@ class EntityFormDisplayAccessControlHandlerTest extends UnitTestCase { $this->parent_member ->expects($this->any()) ->method('hasPermission') - ->will($this->returnValueMap([ + ->willReturnMap([ ['Llama', TRUE], - ])); + ]); $this->parent_member ->expects($this->any()) ->method('id') @@ -126,9 +126,9 @@ class EntityFormDisplayAccessControlHandlerTest extends UnitTestCase { $entity_form_display_entity_type ->expects($this->any()) ->method('getKey') - ->will($this->returnValueMap([ + ->willReturnMap([ ['langcode', 'langcode'], - ])); + ]); $entity_form_display_entity_type->expects($this->any()) ->method('entityClassImplements') ->will($this->returnValue(TRUE)); diff --git a/core/tests/Drupal/Tests/Core/Entity/Access/EntityViewDisplayAccessControlHandlerTest.php b/core/tests/Drupal/Tests/Core/Entity/Access/EntityViewDisplayAccessControlHandlerTest.php index c9d7eb31c60..c31a9458798 100644 --- a/core/tests/Drupal/Tests/Core/Entity/Access/EntityViewDisplayAccessControlHandlerTest.php +++ b/core/tests/Drupal/Tests/Core/Entity/Access/EntityViewDisplayAccessControlHandlerTest.php @@ -22,9 +22,9 @@ class EntityViewDisplayAccessControlHandlerTest extends EntityFormDisplayAccessC $this->member ->expects($this->any()) ->method('hasPermission') - ->will($this->returnValueMap([ + ->willReturnMap([ ['administer foobar display', TRUE], - ])); + ]); $this->member ->expects($this->any()) ->method('id') diff --git a/core/tests/Drupal/Tests/Core/Entity/EntityResolverManagerTest.php b/core/tests/Drupal/Tests/Core/Entity/EntityResolverManagerTest.php index 4def2202b4d..4b66ca8c394 100644 --- a/core/tests/Drupal/Tests/Core/Entity/EntityResolverManagerTest.php +++ b/core/tests/Drupal/Tests/Core/Entity/EntityResolverManagerTest.php @@ -463,7 +463,7 @@ class EntityResolverManagerTest extends UnitTestCase { ])); $this->entityTypeManager->expects($this->any()) ->method('getDefinition') - ->will($this->returnCallback(function ($entity_type) use ($definition, $revisionable_definition) { + ->willReturnCallback(function ($entity_type) use ($definition, $revisionable_definition) { if ($entity_type == 'entity_test') { return $definition; } @@ -473,7 +473,7 @@ class EntityResolverManagerTest extends UnitTestCase { else { return NULL; } - })); + }); } } diff --git a/core/tests/Drupal/Tests/Core/Entity/EntityUnitTest.php b/core/tests/Drupal/Tests/Core/Entity/EntityUnitTest.php index 74cbfa23923..16ef3d1c68f 100644 --- a/core/tests/Drupal/Tests/Core/Entity/EntityUnitTest.php +++ b/core/tests/Drupal/Tests/Core/Entity/EntityUnitTest.php @@ -216,9 +216,9 @@ class EntityUnitTest extends UnitTestCase { public function testLanguage() { $this->entityType->expects($this->any()) ->method('getKey') - ->will($this->returnValueMap([ + ->willReturnMap([ ['langcode', 'langcode'], - ])); + ]); $this->assertSame('en', $this->entity->language()->getId()); } diff --git a/core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageSchemaTest.php b/core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageSchemaTest.php index 7473c360b69..1db5beddb68 100644 --- a/core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageSchemaTest.php +++ b/core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageSchemaTest.php @@ -1393,9 +1393,9 @@ class SqlContentEntityStorageSchemaTest extends UnitTestCase { return $expected_table_schemas[$invocation_count] == $table_schema; }) ) - ->will($this->returnCallback(function () use (&$invocation_count) { + ->willReturnCallback(function () use (&$invocation_count) { $invocation_count++; - })); + }); } $connection = $this->getMockBuilder('Drupal\Core\Database\Connection') diff --git a/core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageTest.php b/core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageTest.php index e63dc51af9b..ded18bbed68 100644 --- a/core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageTest.php +++ b/core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageTest.php @@ -381,14 +381,14 @@ class SqlContentEntityStorageTest extends UnitTestCase { ->will($this->returnValue(['id' => 'id'])); $this->entityType->expects($this->any()) ->method('hasKey') - ->will($this->returnValueMap([ + ->willReturnMap([ // SqlContentEntityStorageSchema::initializeBaseTable() ['revision', FALSE], ['id', TRUE], - ])); + ]); $this->entityType->expects($this->any()) ->method('getKey') - ->will($this->returnValueMap([ + ->willReturnMap([ // EntityStorageBase::__construct() ['id', 'id'], // ContentEntityStorageBase::__construct() @@ -397,7 +397,7 @@ class SqlContentEntityStorageTest extends UnitTestCase { // SqlContentEntityStorageSchema::initializeBaseTable() ['id' => 'id'], ['id' => 'id'], - ])); + ]); $this->setUpEntityStorage(); @@ -478,11 +478,11 @@ class SqlContentEntityStorageTest extends UnitTestCase { public function testGetTableMappingSimple(array $entity_keys) { $this->entityType->expects($this->any()) ->method('getKey') - ->will($this->returnValueMap([ + ->willReturnMap([ ['id', $entity_keys['id']], ['uuid', $entity_keys['uuid']], ['bundle', $entity_keys['bundle']], - ])); + ]); $this->setUpEntityStorage(); @@ -596,12 +596,12 @@ class SqlContentEntityStorageTest extends UnitTestCase { ->will($this->returnValue(TRUE)); $this->entityType->expects($this->any()) ->method('getKey') - ->will($this->returnValueMap([ + ->willReturnMap([ ['id', $entity_keys['id']], ['uuid', $entity_keys['uuid']], ['bundle', $entity_keys['bundle']], ['revision', $entity_keys['revision']], - ])); + ]); $this->entityType->expects($this->any()) ->method('getRevisionMetadataKeys') ->will($this->returnValue([])); @@ -669,12 +669,12 @@ class SqlContentEntityStorageTest extends UnitTestCase { ->will($this->returnValue(TRUE)); $this->entityType->expects($this->any()) ->method('getKey') - ->will($this->returnValueMap([ + ->willReturnMap([ ['id', $entity_keys['id']], ['uuid', $entity_keys['uuid']], ['bundle', $entity_keys['bundle']], ['revision', $entity_keys['revision']], - ])); + ]); $this->entityType->expects($this->any()) ->method('getRevisionMetadataKeys') @@ -723,12 +723,12 @@ class SqlContentEntityStorageTest extends UnitTestCase { ->will($this->returnValue('entity_test_field_data')); $this->entityType->expects($this->any()) ->method('getKey') - ->will($this->returnValueMap([ + ->willReturnMap([ ['id', $entity_keys['id']], ['uuid', $entity_keys['uuid']], ['bundle', $entity_keys['bundle']], ['langcode', $entity_keys['langcode']], - ])); + ]); $this->setUpEntityStorage(); @@ -783,12 +783,12 @@ class SqlContentEntityStorageTest extends UnitTestCase { ->will($this->returnValue('entity_test_field_data')); $this->entityType->expects($this->any()) ->method('getKey') - ->will($this->returnValueMap([ + ->willReturnMap([ ['id', $entity_keys['id']], ['uuid', $entity_keys['uuid']], ['bundle', $entity_keys['bundle']], ['langcode', $entity_keys['langcode']], - ])); + ]); $this->setUpEntityStorage(); @@ -853,13 +853,13 @@ class SqlContentEntityStorageTest extends UnitTestCase { ->will($this->returnValue('entity_test_field_data')); $this->entityType->expects($this->any()) ->method('getKey') - ->will($this->returnValueMap([ + ->willReturnMap([ ['id', $entity_keys['id']], ['uuid', $entity_keys['uuid']], ['bundle', $entity_keys['bundle']], ['revision', $entity_keys['revision']], ['langcode', $entity_keys['langcode']], - ])); + ]); $this->entityType->expects($this->any()) ->method('getRevisionMetadataKeys') ->will($this->returnValue($revision_metadata_keys)); @@ -980,13 +980,13 @@ class SqlContentEntityStorageTest extends UnitTestCase { ->will($this->returnValue('entity_test_field_data')); $this->entityType->expects($this->any()) ->method('getKey') - ->will($this->returnValueMap([ + ->willReturnMap([ ['id', $entity_keys['id']], ['uuid', $entity_keys['uuid']], ['bundle', $entity_keys['bundle']], ['revision', $entity_keys['revision']], ['langcode', $entity_keys['langcode']], - ])); + ]); $this->entityType->expects($this->any()) ->method('getRevisionMetadataKeys') ->will($this->returnValue($revision_metadata_field_names)); @@ -1424,9 +1424,7 @@ class SqlContentEntityStorageTest extends UnitTestCase { $this->entityType->expects($this->any()) ->method('getKey') - ->will($this->returnValueMap( - [['id', 'id']] - )); + ->willReturnMap([['id', 'id']]); $method = new \ReflectionMethod($this->entityStorage, 'cleanIds'); $method->setAccessible(TRUE); @@ -1456,10 +1454,10 @@ class SqlContentEntityStorageTest extends UnitTestCase { protected function setUpModuleHandlerNoImplementations() { $this->moduleHandler->expects($this->any()) ->method('getImplementations') - ->will($this->returnValueMap([ + ->willReturnMap([ ['entity_load', []], [$this->entityTypeId . '_load', []], - ])); + ]); $this->container->set('module_handler', $this->moduleHandler); } diff --git a/core/tests/Drupal/Tests/Core/EventSubscriber/CustomPageExceptionHtmlSubscriberTest.php b/core/tests/Drupal/Tests/Core/EventSubscriber/CustomPageExceptionHtmlSubscriberTest.php index 7480c2b7765..5367e6523b5 100644 --- a/core/tests/Drupal/Tests/Core/EventSubscriber/CustomPageExceptionHtmlSubscriberTest.php +++ b/core/tests/Drupal/Tests/Core/EventSubscriber/CustomPageExceptionHtmlSubscriberTest.php @@ -135,9 +135,9 @@ class CustomPageExceptionHtmlSubscriberTest extends UnitTestCase { ->method('getContext') ->willReturn($request_context); - $this->kernel->expects($this->once())->method('handle')->will($this->returnCallback(function (Request $request) { + $this->kernel->expects($this->once())->method('handle')->willReturnCallback(function (Request $request) { return new HtmlResponse($request->getMethod()); - })); + }); $event = new ExceptionEvent($this->kernel, $request, HttpKernelInterface::MASTER_REQUEST, new NotFoundHttpException('foo')); @@ -162,9 +162,9 @@ class CustomPageExceptionHtmlSubscriberTest extends UnitTestCase { ->method('getContext') ->willReturn($request_context); - $this->kernel->expects($this->once())->method('handle')->will($this->returnCallback(function (Request $request) { + $this->kernel->expects($this->once())->method('handle')->willReturnCallback(function (Request $request) { return new Response($request->getMethod() . ' ' . UrlHelper::buildQuery($request->query->all())); - })); + }); $event = new ExceptionEvent($this->kernel, $request, HttpKernelInterface::MASTER_REQUEST, new NotFoundHttpException('foo')); $this->customPageSubscriber->onException($event); diff --git a/core/tests/Drupal/Tests/Core/EventSubscriber/ModuleRouteSubscriberTest.php b/core/tests/Drupal/Tests/Core/EventSubscriber/ModuleRouteSubscriberTest.php index 6964f00b6ce..aff4ecc174b 100644 --- a/core/tests/Drupal/Tests/Core/EventSubscriber/ModuleRouteSubscriberTest.php +++ b/core/tests/Drupal/Tests/Core/EventSubscriber/ModuleRouteSubscriberTest.php @@ -31,7 +31,7 @@ class ModuleRouteSubscriberTest extends UnitTestCase { $this->moduleHandler->expects($this->any()) ->method('moduleExists') - ->will($this->returnValueMap($value_map)); + ->willReturnMap($value_map); } /** diff --git a/core/tests/Drupal/Tests/Core/Form/FormBuilderTest.php b/core/tests/Drupal/Tests/Core/Form/FormBuilderTest.php index 8060341d32e..7ec676ef858 100644 --- a/core/tests/Drupal/Tests/Core/Form/FormBuilderTest.php +++ b/core/tests/Drupal/Tests/Core/Form/FormBuilderTest.php @@ -145,9 +145,9 @@ class FormBuilderTest extends FormTestBase { $form_arg = $this->getMockForm($form_id, $expected_form); $form_arg->expects($this->any()) ->method('submitForm') - ->will($this->returnCallback(function ($form, FormStateInterface $form_state) use ($response, $form_state_key) { + ->willReturnCallback(function ($form, FormStateInterface $form_state) use ($response, $form_state_key) { $form_state->setFormState([$form_state_key => $response]); - })); + }); $form_state = new FormState(); try { @@ -192,11 +192,11 @@ class FormBuilderTest extends FormTestBase { $form_arg = $this->getMockForm($form_id, $expected_form); $form_arg->expects($this->any()) ->method('submitForm') - ->will($this->returnCallback(function ($form, FormStateInterface $form_state) use ($response, $redirect) { + ->willReturnCallback(function ($form, FormStateInterface $form_state) use ($response, $redirect) { // Set both the response and the redirect. $form_state->setResponse($response); $form_state->set('redirect', $redirect); - })); + }); $form_state = new FormState(); try { diff --git a/core/tests/Drupal/Tests/Core/Form/FormCacheTest.php b/core/tests/Drupal/Tests/Core/Form/FormCacheTest.php index f589f89c404..765fcfe2814 100644 --- a/core/tests/Drupal/Tests/Core/Form/FormCacheTest.php +++ b/core/tests/Drupal/Tests/Core/Form/FormCacheTest.php @@ -105,10 +105,10 @@ class FormCacheTest extends UnitTestCase { $this->keyValueExpirableFactory = $this->createMock('Drupal\Core\KeyValueStore\KeyValueExpirableFactoryInterface'); $this->keyValueExpirableFactory->expects($this->any()) ->method('get') - ->will($this->returnValueMap([ + ->willReturnMap([ ['form', $this->formCacheStore], ['form_state', $this->formStateCacheStore], - ])); + ]); $this->csrfToken = $this->getMockBuilder('Drupal\Core\Access\CsrfTokenGenerator') ->disableOriginalConstructor() diff --git a/core/tests/Drupal/Tests/Core/Form/FormSubmitterTest.php b/core/tests/Drupal/Tests/Core/Form/FormSubmitterTest.php index 60a7c041277..668452d16e6 100644 --- a/core/tests/Drupal/Tests/Core/Form/FormSubmitterTest.php +++ b/core/tests/Drupal/Tests/Core/Form/FormSubmitterTest.php @@ -138,10 +138,17 @@ class FormSubmitterTest extends UnitTestCase { $form_submitter = $this->getFormSubmitter(); $this->urlGenerator->expects($this->once()) ->method('generateFromRoute') - ->will($this->returnValueMap([ + ->willReturnMap( + [ ['test_route_a', [], ['absolute' => TRUE], FALSE, 'test-route'], - ['test_route_b', ['key' => 'value'], ['absolute' => TRUE], FALSE, 'test-route/value'], - ]) + [ + 'test_route_b', + ['key' => 'value'], + ['absolute' => TRUE], + FALSE, + 'test-route/value', + ], + ] ); $form_state = $this->createMock('Drupal\Core\Form\FormStateInterface'); diff --git a/core/tests/Drupal/Tests/Core/Form/FormTestBase.php b/core/tests/Drupal/Tests/Core/Form/FormTestBase.php index c5db4a1f9de..ac01e8872cf 100644 --- a/core/tests/Drupal/Tests/Core/Form/FormTestBase.php +++ b/core/tests/Drupal/Tests/Core/Form/FormTestBase.php @@ -163,7 +163,7 @@ abstract class FormTestBase extends UnitTestCase { ->getMock(); $this->elementInfo->expects($this->any()) ->method('getInfo') - ->will($this->returnCallback([$this, 'getInfo'])); + ->willReturnCallback([$this, 'getInfo']); $this->csrfToken = $this->getMockBuilder('Drupal\Core\Access\CsrfTokenGenerator') ->disableOriginalConstructor() diff --git a/core/tests/Drupal/Tests/Core/Logger/LoggerChannelTest.php b/core/tests/Drupal/Tests/Core/Logger/LoggerChannelTest.php index 641f9f9c83e..920bd6bc68b 100644 --- a/core/tests/Drupal/Tests/Core/Logger/LoggerChannelTest.php +++ b/core/tests/Drupal/Tests/Core/Logger/LoggerChannelTest.php @@ -84,11 +84,11 @@ class LoggerChannelTest extends UnitTestCase { $logger = $this->createMock('Psr\Log\LoggerInterface'); $logger->expects($this->once()) ->method('log') - ->will($this->returnCallback(function () use ($i, &$index_order) { + ->willReturnCallback(function () use ($i, &$index_order) { // Append the $i to the index order, so that we know the order that // loggers got called with. $index_order .= $i; - })); + }); $channel->addLogger($logger, $i); } diff --git a/core/tests/Drupal/Tests/Core/Menu/ContextualLinkManagerTest.php b/core/tests/Drupal/Tests/Core/Menu/ContextualLinkManagerTest.php index cc780e6ba5c..30a7971233d 100644 --- a/core/tests/Drupal/Tests/Core/Menu/ContextualLinkManagerTest.php +++ b/core/tests/Drupal/Tests/Core/Menu/ContextualLinkManagerTest.php @@ -283,7 +283,7 @@ class ContextualLinkManagerTest extends UnitTestCase { } $this->factory->expects($this->any()) ->method('createInstance') - ->will($this->returnValueMap($map)); + ->willReturnMap($map); $this->moduleHandler->expects($this->exactly(2)) ->method('alter') @@ -336,10 +336,10 @@ class ContextualLinkManagerTest extends UnitTestCase { $this->accessManager->expects($this->any()) ->method('checkNamedRoute') - ->will($this->returnValueMap([ + ->willReturnMap([ ['test_route', ['key' => 'value'], $this->account, FALSE, TRUE], ['test_route2', ['key' => 'value'], $this->account, FALSE, FALSE], - ])); + ]); // Set up mocking of the plugin factory. $map = []; @@ -361,7 +361,7 @@ class ContextualLinkManagerTest extends UnitTestCase { } $this->factory->expects($this->any()) ->method('createInstance') - ->will($this->returnValueMap($map)); + ->willReturnMap($map); $result = $this->contextualLinkManager->getContextualLinksArrayByGroup('group1', ['key' => 'value']); diff --git a/core/tests/Drupal/Tests/Core/Menu/DefaultMenuLinkTreeManipulatorsTest.php b/core/tests/Drupal/Tests/Core/Menu/DefaultMenuLinkTreeManipulatorsTest.php index 73b008f7738..64da52d11a4 100644 --- a/core/tests/Drupal/Tests/Core/Menu/DefaultMenuLinkTreeManipulatorsTest.php +++ b/core/tests/Drupal/Tests/Core/Menu/DefaultMenuLinkTreeManipulatorsTest.php @@ -165,13 +165,25 @@ class DefaultMenuLinkTreeManipulatorsTest extends UnitTestCase { // calls will be made. $this->accessManager->expects($this->exactly(5)) ->method('checkNamedRoute') - ->will($this->returnValueMap([ + ->willReturnMap([ ['example1', [], $this->currentUser, TRUE, AccessResult::forbidden()], - ['example2', ['foo' => 'bar'], $this->currentUser, TRUE, AccessResult::allowed()->cachePerPermissions()], - ['example3', ['baz' => 'qux'], $this->currentUser, TRUE, AccessResult::neutral()], + [ + 'example2', + ['foo' => 'bar'], + $this->currentUser, + TRUE, + AccessResult::allowed()->cachePerPermissions(), + ], + [ + 'example3', + ['baz' => 'qux'], + $this->currentUser, + TRUE, + AccessResult::neutral(), + ], ['example5', [], $this->currentUser, TRUE, AccessResult::allowed()], ['user.logout', [], $this->currentUser, TRUE, AccessResult::allowed()], - ])); + ]); $this->mockTree(); $this->originalTree[5]->subtree[7]->access = AccessResult::neutral(); diff --git a/core/tests/Drupal/Tests/Core/Menu/LocalActionManagerTest.php b/core/tests/Drupal/Tests/Core/Menu/LocalActionManagerTest.php index 496c6fe55f1..545c0e12105 100644 --- a/core/tests/Drupal/Tests/Core/Menu/LocalActionManagerTest.php +++ b/core/tests/Drupal/Tests/Core/Menu/LocalActionManagerTest.php @@ -188,7 +188,7 @@ class LocalActionManagerTest extends UnitTestCase { } $this->factory->expects($this->any()) ->method('createInstance') - ->will($this->returnValueMap($map)); + ->willReturnMap($map); $this->assertEquals($expected_actions, $this->localActionManager->getActionsForRoute($route_appears)); } diff --git a/core/tests/Drupal/Tests/Core/Menu/LocalTaskIntegrationTestBase.php b/core/tests/Drupal/Tests/Core/Menu/LocalTaskIntegrationTestBase.php index f37e6fcccee..b419db2676d 100644 --- a/core/tests/Drupal/Tests/Core/Menu/LocalTaskIntegrationTestBase.php +++ b/core/tests/Drupal/Tests/Core/Menu/LocalTaskIntegrationTestBase.php @@ -91,9 +91,9 @@ abstract class LocalTaskIntegrationTestBase extends UnitTestCase { // Set all the modules as being existent. $module_handler->expects($this->any()) ->method('moduleExists') - ->will($this->returnCallback(function ($module) use ($module_dirs) { + ->willReturnCallback(function ($module) use ($module_dirs) { return isset($module_dirs[$module]); - })); + }); $pluginDiscovery = new YamlDiscovery('links.task', $module_dirs); $pluginDiscovery = new ContainerDerivativeDiscoveryDecorator($pluginDiscovery); diff --git a/core/tests/Drupal/Tests/Core/Menu/LocalTaskManagerTest.php b/core/tests/Drupal/Tests/Core/Menu/LocalTaskManagerTest.php index 4de8170aaa1..e7c58a847c4 100644 --- a/core/tests/Drupal/Tests/Core/Menu/LocalTaskManagerTest.php +++ b/core/tests/Drupal/Tests/Core/Menu/LocalTaskManagerTest.php @@ -336,7 +336,7 @@ class LocalTaskManagerTest extends UnitTestCase { } $this->factory->expects($this->any()) ->method('createInstance') - ->will($this->returnValueMap($map)); + ->willReturnMap($map); } /** @@ -468,7 +468,7 @@ class LocalTaskManagerTest extends UnitTestCase { $this->factory->expects($this->any()) ->method('createInstance') - ->will($this->returnValueMap($map)); + ->willReturnMap($map); } protected function setupNullCacheabilityMetadataValidation() { diff --git a/core/tests/Drupal/Tests/Core/Menu/MenuActiveTrailTest.php b/core/tests/Drupal/Tests/Core/Menu/MenuActiveTrailTest.php index cf0483cc5d1..ecf62a1fe33 100644 --- a/core/tests/Drupal/Tests/Core/Menu/MenuActiveTrailTest.php +++ b/core/tests/Drupal/Tests/Core/Menu/MenuActiveTrailTest.php @@ -173,9 +173,9 @@ class MenuActiveTrailTest extends UnitTestCase { if ($expected_link !== NULL) { $this->menuLinkManager->expects($this->exactly(2)) ->method('getParentIds') - ->will($this->returnValueMap([ + ->willReturnMap([ [$expected_link->getPluginId(), $expected_trail_ids], - ])); + ]); } } @@ -213,9 +213,9 @@ class MenuActiveTrailTest extends UnitTestCase { $this->menuLinkManager->expects($this->any()) ->method('getParentIds') - ->will($this->returnValueMap([ + ->willReturnMap([ [$expected_link->getPluginId(), $expected_trail_ids], - ])); + ]); $this->assertSame($expected_trail_ids, $this->menuActiveTrail->getActiveTrailIds($data[2])); diff --git a/core/tests/Drupal/Tests/Core/PathProcessor/PathProcessorTest.php b/core/tests/Drupal/Tests/Core/PathProcessor/PathProcessorTest.php index 92f500379b0..14814b67557 100644 --- a/core/tests/Drupal/Tests/Core/PathProcessor/PathProcessorTest.php +++ b/core/tests/Drupal/Tests/Core/PathProcessor/PathProcessorTest.php @@ -90,7 +90,7 @@ class PathProcessorTest extends UnitTestCase { $alias_manager->expects($this->any()) ->method('getPathByAlias') - ->will($this->returnValueMap($system_path_map)); + ->willReturnMap($system_path_map); // Create a stub config factory with all config settings that will be checked // during this test. diff --git a/core/tests/Drupal/Tests/Core/Plugin/Discovery/HookDiscoveryTest.php b/core/tests/Drupal/Tests/Core/Plugin/Discovery/HookDiscoveryTest.php index 90505343775..9b3e1abef6c 100644 --- a/core/tests/Drupal/Tests/Core/Plugin/Discovery/HookDiscoveryTest.php +++ b/core/tests/Drupal/Tests/Core/Plugin/Discovery/HookDiscoveryTest.php @@ -92,11 +92,20 @@ class HookDiscoveryTest extends UnitTestCase { $this->moduleHandler->expects($this->any()) ->method('invoke') - ->will($this->returnValueMap([ - ['hook_discovery_test', 'test_plugin', [], $this->hookDiscoveryTestTestPlugin()], - ['hook_discovery_test2', 'test_plugin', [], $this->hookDiscoveryTest2TestPlugin()], - ] - )); + ->willReturnMap([ + [ + 'hook_discovery_test', + 'test_plugin', + [], + $this->hookDiscoveryTestTestPlugin(), + ], + [ + 'hook_discovery_test2', + 'test_plugin', + [], + $this->hookDiscoveryTest2TestPlugin(), + ], + ]); $this->assertNull($this->hookDiscovery->getDefinition('test_non_existent', FALSE)); diff --git a/core/tests/Drupal/Tests/Core/Plugin/LazyPluginCollectionTestBase.php b/core/tests/Drupal/Tests/Core/Plugin/LazyPluginCollectionTestBase.php index 38c00cefee9..45132288d7c 100644 --- a/core/tests/Drupal/Tests/Core/Plugin/LazyPluginCollectionTestBase.php +++ b/core/tests/Drupal/Tests/Core/Plugin/LazyPluginCollectionTestBase.php @@ -71,7 +71,7 @@ abstract class LazyPluginCollectionTestBase extends UnitTestCase { $create_count = $create_count ?: $this->never(); $this->pluginManager->expects($create_count) ->method('createInstance') - ->will($this->returnCallback([$this, 'returnPluginMap'])); + ->willReturnCallback([$this, 'returnPluginMap']); $this->defaultPluginCollection = new DefaultLazyPluginCollection($this->pluginManager, $this->config); } diff --git a/core/tests/Drupal/Tests/Core/Routing/RouteBuilderTest.php b/core/tests/Drupal/Tests/Core/Routing/RouteBuilderTest.php index 8f8fb5aefa5..66b00d5da72 100644 --- a/core/tests/Drupal/Tests/Core/Routing/RouteBuilderTest.php +++ b/core/tests/Drupal/Tests/Core/Routing/RouteBuilderTest.php @@ -208,18 +208,19 @@ class RouteBuilderTest extends UnitTestCase { $container->set('test_module.route_service', new TestRouteSubscriber()); $this->controllerResolver->expects($this->any()) ->method('getControllerFromDefinition') - ->will($this->returnCallback(function ($controller) use ($container) { + ->willReturnCallback(function ($controller) use ($container) { $count = substr_count($controller, ':'); if ($count == 1) { - list($service, $method) = explode(':', $controller, 2); + [$service, $method] = explode(':', $controller, 2); $object = $container->get($service); } else { - list($class, $method) = explode('::', $controller, 2); + [$class, $method] = explode('::', $controller, 2); $object = new $class(); } + return [$object, $method]; - })); + }); $route_collection_filled = new RouteCollection(); $route_collection_filled->add('test_route.1', new Route('/test-route/1')); diff --git a/core/tests/Drupal/Tests/Core/Routing/UrlGeneratorTest.php b/core/tests/Drupal/Tests/Core/Routing/UrlGeneratorTest.php index fc4ea09e3d7..108eb7f7164 100644 --- a/core/tests/Drupal/Tests/Core/Routing/UrlGeneratorTest.php +++ b/core/tests/Drupal/Tests/Core/Routing/UrlGeneratorTest.php @@ -137,10 +137,10 @@ class UrlGeneratorTest extends UnitTestCase { $this->provider = $provider; $this->provider->expects($this->any()) ->method('getRouteByName') - ->will($this->returnValueMap($route_name_return_map)); + ->willReturnMap($route_name_return_map); $provider->expects($this->any()) ->method('getRoutesByNames') - ->will($this->returnValueMap($routes_names_return_map)); + ->willReturnMap($routes_names_return_map); // Create an alias manager stub. $alias_manager = $this->getMockBuilder('Drupal\path_alias\AliasManager') @@ -149,7 +149,7 @@ class UrlGeneratorTest extends UnitTestCase { $alias_manager->expects($this->any()) ->method('getAliasByPath') - ->will($this->returnCallback([$this, 'aliasManagerCallback'])); + ->willReturnCallback([$this, 'aliasManagerCallback']); $this->aliasManager = $alias_manager; diff --git a/core/tests/Drupal/Tests/Core/Session/UserSessionTest.php b/core/tests/Drupal/Tests/Core/Session/UserSessionTest.php index 8a504176d53..e161d41cd2f 100644 --- a/core/tests/Drupal/Tests/Core/Session/UserSessionTest.php +++ b/core/tests/Drupal/Tests/Core/Session/UserSessionTest.php @@ -64,11 +64,11 @@ class UserSessionTest extends UnitTestCase { ->getMock(); $roles['role_one']->expects($this->any()) ->method('hasPermission') - ->will($this->returnValueMap([ + ->willReturnMap([ ['example permission', TRUE], ['another example permission', FALSE], ['last example permission', FALSE], - ])); + ]); $roles['role_two'] = $this->getMockBuilder('Drupal\user\Entity\Role') ->disableOriginalConstructor() @@ -76,11 +76,11 @@ class UserSessionTest extends UnitTestCase { ->getMock(); $roles['role_two']->expects($this->any()) ->method('hasPermission') - ->will($this->returnValueMap([ + ->willReturnMap([ ['example permission', TRUE], ['another example permission', TRUE], ['last example permission', FALSE], - ])); + ]); $roles['anonymous'] = $this->getMockBuilder('Drupal\user\Entity\Role') ->disableOriginalConstructor() @@ -88,11 +88,11 @@ class UserSessionTest extends UnitTestCase { ->getMock(); $roles['anonymous']->expects($this->any()) ->method('hasPermission') - ->will($this->returnValueMap([ + ->willReturnMap([ ['example permission', FALSE], ['another example permission', FALSE], ['last example permission', FALSE], - ])); + ]); $role_storage = $this->getMockBuilder('Drupal\user\RoleStorage') ->setConstructorArgs(['role', new MemoryCache()]) @@ -101,14 +101,17 @@ class UserSessionTest extends UnitTestCase { ->getMock(); $role_storage->expects($this->any()) ->method('loadMultiple') - ->will($this->returnValueMap([ + ->willReturnMap([ [[], []], [NULL, $roles], [['anonymous'], [$roles['anonymous']]], [['anonymous', 'role_one'], [$roles['role_one']]], [['anonymous', 'role_two'], [$roles['role_two']]], - [['anonymous', 'role_one', 'role_two'], [$roles['role_one'], $roles['role_two']]], - ])); + [ + ['anonymous', 'role_one', 'role_two'], + [$roles['role_one'], $roles['role_two']], + ], + ]); $entity_type_manager = $this->createMock('Drupal\Core\Entity\EntityTypeManagerInterface'); $entity_type_manager->expects($this->any()) diff --git a/core/tests/Drupal/Tests/Core/StringTranslation/TranslationManagerTest.php b/core/tests/Drupal/Tests/Core/StringTranslation/TranslationManagerTest.php index 1910d562b69..3b98ab4d2f7 100644 --- a/core/tests/Drupal/Tests/Core/StringTranslation/TranslationManagerTest.php +++ b/core/tests/Drupal/Tests/Core/StringTranslation/TranslationManagerTest.php @@ -56,9 +56,9 @@ class TranslationManagerTest extends UnitTestCase { $translator->expects($this->once()) ->method('getStringTranslation') ->with($langcode, $this->anything(), $this->anything()) - ->will($this->returnCallback(function ($langcode, $string, $context) { + ->willReturnCallback(function ($langcode, $string, $context) { return $string; - })); + }); $this->translationManager->setDefaultLangcode('fr'); $this->translationManager->addTranslator($translator); $result = $this->translationManager->formatPlural($count, $singular, $plural, $args, $options); diff --git a/core/tests/Drupal/Tests/Core/Template/TwigExtensionTest.php b/core/tests/Drupal/Tests/Core/Template/TwigExtensionTest.php index cd367d128b7..5b1cba9ef8f 100644 --- a/core/tests/Drupal/Tests/Core/Template/TwigExtensionTest.php +++ b/core/tests/Drupal/Tests/Core/Template/TwigExtensionTest.php @@ -155,9 +155,9 @@ class TwigExtensionTest extends UnitTestCase { public function testFormatDate() { $this->dateFormatter->expects($this->exactly(1)) ->method('format') - ->will($this->returnCallback(function ($timestamp) { + ->willReturnCallback(function ($timestamp) { return date('Y-m-d', $timestamp); - })); + }); $loader = new StringLoader(); $twig = new Environment($loader); diff --git a/core/tests/Drupal/Tests/Core/Transliteration/PhpTransliterationTest.php b/core/tests/Drupal/Tests/Core/Transliteration/PhpTransliterationTest.php index 58182f9352f..8c7aa9252a0 100644 --- a/core/tests/Drupal/Tests/Core/Transliteration/PhpTransliterationTest.php +++ b/core/tests/Drupal/Tests/Core/Transliteration/PhpTransliterationTest.php @@ -40,7 +40,7 @@ class PhpTransliterationTest extends UnitTestCase { $module_handler = $this->createMock('Drupal\Core\Extension\ModuleHandlerInterface'); $module_handler->expects($this->any()) ->method('alter') - ->will($this->returnCallback(function ($hook, &$overrides, $langcode) { + ->willReturnCallback(function ($hook, &$overrides, $langcode) { if ($langcode == 'zz') { // The default transliteration of Ä is A, but change it to Z for testing. $overrides[0xC4] = 'Z'; @@ -49,7 +49,7 @@ class PhpTransliterationTest extends UnitTestCase { $overrides[0x10330] = 'A'; $overrides[0x10338] = 'Th'; } - })); + }); $transliteration = new PhpTransliteration(NULL, $module_handler); $actual = $transliteration->transliterate($original, $langcode); diff --git a/core/tests/Drupal/Tests/Core/UrlTest.php b/core/tests/Drupal/Tests/Core/UrlTest.php index e1a747eb413..fcdabf14c95 100644 --- a/core/tests/Drupal/Tests/Core/UrlTest.php +++ b/core/tests/Drupal/Tests/Core/UrlTest.php @@ -99,12 +99,12 @@ class UrlTest extends UnitTestCase { $this->urlGenerator = $this->createMock('Drupal\Core\Routing\UrlGeneratorInterface'); $this->urlGenerator->expects($this->any()) ->method('generateFromRoute') - ->will($this->returnValueMap($generate_from_route_map)); + ->willReturnMap($generate_from_route_map); $this->pathAliasManager = $this->createMock('Drupal\path_alias\AliasManagerInterface'); $this->pathAliasManager->expects($this->any()) ->method('getPathByAlias') - ->will($this->returnValueMap($alias_map)); + ->willReturnMap($alias_map); $this->router = $this->createMock('Drupal\Tests\Core\Routing\TestRouterInterface'); $this->pathValidator = $this->createMock('Drupal\Core\Path\PathValidatorInterface'); diff --git a/core/tests/Drupal/Tests/Core/Utility/LinkGeneratorTest.php b/core/tests/Drupal/Tests/Core/Utility/LinkGeneratorTest.php index f9f1dee7115..cc466edd644 100644 --- a/core/tests/Drupal/Tests/Core/Utility/LinkGeneratorTest.php +++ b/core/tests/Drupal/Tests/Core/Utility/LinkGeneratorTest.php @@ -477,11 +477,11 @@ class LinkGeneratorTest extends UnitTestCase { $this->urlGenerator->expects($this->exactly(4)) ->method('getPathFromRoute') - ->will($this->returnValueMap([ + ->willReturnMap([ ['test_route_1', [], 'test-route-1'], ['test_route_3', [], 'test-route-3'], ['test_route_4', ['object' => '1'], 'test-route-4/1'], - ])); + ]); $this->moduleHandler->expects($this->exactly(5)) ->method('alter'); @@ -553,9 +553,15 @@ class LinkGeneratorTest extends UnitTestCase { $options = ['query' => [], 'language' => NULL, 'set_active_class' => FALSE, 'absolute' => FALSE]; $this->urlGenerator->expects($this->any()) ->method('generateFromRoute') - ->will($this->returnValueMap([ - ['test_route_1', [], $options, TRUE, (new GeneratedUrl())->setGeneratedUrl('/test-route-1')], - ])); + ->willReturnMap([ + [ + 'test_route_1', + [], + $options, + TRUE, + (new GeneratedUrl())->setGeneratedUrl('/test-route-1'), + ], + ]); $url = new Url('test_route_1'); $url->setUrlGenerator($this->urlGenerator); @@ -584,10 +590,22 @@ class LinkGeneratorTest extends UnitTestCase { $options = ['query' => [], 'language' => NULL, 'set_active_class' => FALSE, 'absolute' => FALSE]; $this->urlGenerator->expects($this->any()) ->method('generateFromRoute') - ->will($this->returnValueMap([ - ['test_route_1', [], $options, TRUE, (new GeneratedUrl())->setGeneratedUrl('/test-route-1')], - ['test_route_2', [], $options, TRUE, (new GeneratedUrl())->setGeneratedUrl('/test-route-2')], - ])); + ->willReturnMap([ + [ + 'test_route_1', + [], + $options, + TRUE, + (new GeneratedUrl())->setGeneratedUrl('/test-route-1'), + ], + [ + 'test_route_2', + [], + $options, + TRUE, + (new GeneratedUrl())->setGeneratedUrl('/test-route-2'), + ], + ]); $url = new Url('test_route_2'); $url->setUrlGenerator($this->urlGenerator); diff --git a/core/tests/Drupal/Tests/UnitTestCase.php b/core/tests/Drupal/Tests/UnitTestCase.php index 7d81c84cd22..b06ae8dd2b0 100644 --- a/core/tests/Drupal/Tests/UnitTestCase.php +++ b/core/tests/Drupal/Tests/UnitTestCase.php @@ -159,7 +159,7 @@ abstract class UnitTestCase extends TestCase { ->getMock(); $immutable_config_object->expects($this->any()) ->method('get') - ->will($this->returnCallback($config_get)); + ->willReturnCallback($config_get); $config_get_map[] = [$config_name, $immutable_config_object]; $mutable_config_object = $this->getMockBuilder('Drupal\Core\Config\Config') @@ -167,7 +167,7 @@ abstract class UnitTestCase extends TestCase { ->getMock(); $mutable_config_object->expects($this->any()) ->method('get') - ->will($this->returnCallback($config_get)); + ->willReturnCallback($config_get); $config_editable_map[] = [$config_name, $mutable_config_object]; } // Construct a config factory with the array of configuration object stubs @@ -175,10 +175,10 @@ abstract class UnitTestCase extends TestCase { $config_factory = $this->createMock('Drupal\Core\Config\ConfigFactoryInterface'); $config_factory->expects($this->any()) ->method('get') - ->will($this->returnValueMap($config_get_map)); + ->willReturnMap($config_get_map); $config_factory->expects($this->any()) ->method('getEditable') - ->will($this->returnValueMap($config_editable_map)); + ->willReturnMap($config_editable_map); return $config_factory; } @@ -265,14 +265,14 @@ abstract class UnitTestCase extends TestCase { $class_resolver = $this->createMock('Drupal\Core\DependencyInjection\ClassResolverInterface'); $class_resolver->expects($this->any()) ->method('getInstanceFromDefinition') - ->will($this->returnCallback(function ($class) { + ->willReturnCallback(function ($class) { if (is_subclass_of($class, 'Drupal\Core\DependencyInjection\ContainerInjectionInterface')) { return $class::create(new ContainerBuilder()); } else { return new $class(); } - })); + }); return $class_resolver; }