Issue #3295880 by Spokje, longwave: ->willReturn(...) would make more sense here

merge-requests/2439/merge
Alex Pott 2022-10-03 15:40:43 +01:00
parent 06d6ed5381
commit cdcba2c1b0
No known key found for this signature in database
GPG Key ID: BDA67E7EE836E5CE
183 changed files with 1044 additions and 1026 deletions

View File

@ -54,7 +54,12 @@ class AggregatorPluginSettingsBaseTest extends UnitTestCase {
->getMock(); ->getMock();
$this->managers[$type]->expects($this->once()) $this->managers[$type]->expects($this->once())
->method('getDefinitions') ->method('getDefinitions')
->will($this->returnValue(['aggregator_test' => ['title' => '', 'description' => '']])); ->willReturn([
'aggregator_test' => [
'title' => '',
'description' => '',
],
]);
} }
/** @var \Drupal\Core\Messenger\MessengerInterface|\PHPUnit\Framework\MockObject\MockBuilder $messenger */ /** @var \Drupal\Core\Messenger\MessengerInterface|\PHPUnit\Framework\MockObject\MockBuilder $messenger */
@ -102,7 +107,7 @@ class AggregatorPluginSettingsBaseTest extends UnitTestCase {
$this->managers['processor']->expects($this->once()) $this->managers['processor']->expects($this->once())
->method('createInstance') ->method('createInstance')
->with($this->equalTo('aggregator_test')) ->with($this->equalTo('aggregator_test'))
->will($this->returnValue($test_processor)); ->willReturn($test_processor);
$form = $this->settingsForm->buildForm([], $form_state); $form = $this->settingsForm->buildForm([], $form_state);
$this->settingsForm->validateForm($form, $form_state); $this->settingsForm->validateForm($form, $form_state);

View File

@ -66,13 +66,13 @@ class BlockConfigEntityUnitTest extends UnitTestCase {
$this->entityType = $this->createMock('\Drupal\Core\Entity\EntityTypeInterface'); $this->entityType = $this->createMock('\Drupal\Core\Entity\EntityTypeInterface');
$this->entityType->expects($this->any()) $this->entityType->expects($this->any())
->method('getProvider') ->method('getProvider')
->will($this->returnValue('block')); ->willReturn('block');
$this->entityTypeManager = $this->createMock(EntityTypeManagerInterface::class); $this->entityTypeManager = $this->createMock(EntityTypeManagerInterface::class);
$this->entityTypeManager->expects($this->any()) $this->entityTypeManager->expects($this->any())
->method('getDefinition') ->method('getDefinition')
->with($this->entityTypeId) ->with($this->entityTypeId)
->will($this->returnValue($this->entityType)); ->willReturn($this->entityType);
$this->uuid = $this->createMock('\Drupal\Component\Uuid\UuidInterface'); $this->uuid = $this->createMock('\Drupal\Component\Uuid\UuidInterface');
@ -111,13 +111,13 @@ class BlockConfigEntityUnitTest extends UnitTestCase {
$plugin_collection->expects($this->atLeastOnce()) $plugin_collection->expects($this->atLeastOnce())
->method('get') ->method('get')
->with($instance_id) ->with($instance_id)
->will($this->returnValue($instance)); ->willReturn($instance);
$plugin_collection->addInstanceId($instance_id); $plugin_collection->addInstanceId($instance_id);
// Return the mocked plugin collection. // Return the mocked plugin collection.
$entity->expects($this->once()) $entity->expects($this->once())
->method('getPluginCollections') ->method('getPluginCollections')
->will($this->returnValue([$plugin_collection])); ->willReturn([$plugin_collection]);
$dependencies = $entity->calculateDependencies()->getDependencies(); $dependencies = $entity->calculateDependencies()->getDependencies();
$this->assertContains('test', $dependencies['module']); $this->assertContains('test', $dependencies['module']);

View File

@ -79,7 +79,7 @@ class BlockFormTest extends UnitTestCase {
$this->themeHandler = $this->createMock('Drupal\Core\Extension\ThemeHandlerInterface'); $this->themeHandler = $this->createMock('Drupal\Core\Extension\ThemeHandlerInterface');
$this->entityTypeManager->expects($this->any()) $this->entityTypeManager->expects($this->any())
->method('getStorage') ->method('getStorage')
->will($this->returnValue($this->storage)); ->willReturn($this->storage);
$this->pluginFormFactory = $this->prophesize(PluginFormFactoryInterface::class); $this->pluginFormFactory = $this->prophesize(PluginFormFactoryInterface::class);
} }
@ -99,14 +99,14 @@ class BlockFormTest extends UnitTestCase {
->getMock(); ->getMock();
$plugin->expects($this->any()) $plugin->expects($this->any())
->method('getMachineNameSuggestion') ->method('getMachineNameSuggestion')
->will($this->returnValue($machine_name)); ->willReturn($machine_name);
$block = $this->getMockBuilder(Block::class) $block = $this->getMockBuilder(Block::class)
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
$block->expects($this->any()) $block->expects($this->any())
->method('getPlugin') ->method('getPlugin')
->will($this->returnValue($plugin)); ->willReturn($plugin);
return $block; return $block;
} }
@ -126,15 +126,15 @@ class BlockFormTest extends UnitTestCase {
$query = $this->createMock('Drupal\Core\Entity\Query\QueryInterface'); $query = $this->createMock('Drupal\Core\Entity\Query\QueryInterface');
$query->expects($this->exactly(5)) $query->expects($this->exactly(5))
->method('condition') ->method('condition')
->will($this->returnValue($query)); ->willReturn($query);
$query->expects($this->exactly(5)) $query->expects($this->exactly(5))
->method('execute') ->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)) $this->storage->expects($this->exactly(5))
->method('getQuery') ->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()); $block_form_controller = new BlockForm($this->entityTypeManager, $this->conditionManager, $this->contextRepository, $this->language, $this->themeHandler, $this->pluginFormFactory->reveal());

View File

@ -56,7 +56,7 @@ class BlockRepositoryTest extends UnitTestCase {
$theme_manager = $this->createMock('Drupal\Core\Theme\ThemeManagerInterface'); $theme_manager = $this->createMock('Drupal\Core\Theme\ThemeManagerInterface');
$theme_manager->expects($this->atLeastOnce()) $theme_manager->expects($this->atLeastOnce())
->method('getActiveTheme') ->method('getActiveTheme')
->will($this->returnValue($active_theme)); ->willReturn($active_theme);
$this->contextHandler = $this->createMock('Drupal\Core\Plugin\Context\ContextHandlerInterface'); $this->contextHandler = $this->createMock('Drupal\Core\Plugin\Context\ContextHandlerInterface');
$this->blockStorage = $this->createMock('Drupal\Core\Entity\EntityStorageInterface'); $this->blockStorage = $this->createMock('Drupal\Core\Entity\EntityStorageInterface');
@ -82,7 +82,7 @@ class BlockRepositoryTest extends UnitTestCase {
$block = $this->createMock('Drupal\block\BlockInterface'); $block = $this->createMock('Drupal\block\BlockInterface');
$block->expects($this->once()) $block->expects($this->once())
->method('access') ->method('access')
->will($this->returnValue($block_config[0])); ->willReturn($block_config[0]);
$block->expects($block_config[0] ? $this->atLeastOnce() : $this->never()) $block->expects($block_config[0] ? $this->atLeastOnce() : $this->never())
->method('getRegion') ->method('getRegion')
->willReturn($block_config[1]); ->willReturn($block_config[1]);

View File

@ -27,7 +27,7 @@ class CategoryAutocompleteTest extends UnitTestCase {
$block_manager = $this->createMock('Drupal\Core\Block\BlockManagerInterface'); $block_manager = $this->createMock('Drupal\Core\Block\BlockManagerInterface');
$block_manager->expects($this->any()) $block_manager->expects($this->any())
->method('getCategories') ->method('getCategories')
->will($this->returnValue(['Comment', 'Node', 'None & Such', 'User'])); ->willReturn(['Comment', 'Node', 'None & Such', 'User']);
$this->autocompleteController = new CategoryAutocompleteController($block_manager); $this->autocompleteController = new CategoryAutocompleteController($block_manager);
} }

View File

@ -46,7 +46,7 @@ class BlockLocalTasksTest extends LocalTaskIntegrationTestBase {
$theme_handler = $this->createMock('Drupal\Core\Extension\ThemeHandlerInterface'); $theme_handler = $this->createMock('Drupal\Core\Extension\ThemeHandlerInterface');
$theme_handler->expects($this->any()) $theme_handler->expects($this->any())
->method('listInfo') ->method('listInfo')
->will($this->returnValue($themes)); ->willReturn($themes);
$theme_handler->expects($this->any()) $theme_handler->expects($this->any())
->method('hasUi') ->method('hasUi')
->willReturnMap([ ->willReturnMap([

View File

@ -219,7 +219,7 @@ class BlockPageVariantTest extends UnitTestCase {
} }
$this->blockViewBuilder->expects($this->exactly($visible_block_count)) $this->blockViewBuilder->expects($this->exactly($visible_block_count))
->method('view') ->method('view')
->will($this->returnValue([])); ->willReturn([]);
$this->blockRepository->expects($this->once()) $this->blockRepository->expects($this->once())
->method('getVisibleBlocksPerRegion') ->method('getVisibleBlocksPerRegion')
->willReturnCallback(function (&$cacheable_metadata) use ($blocks) { ->willReturnCallback(function (&$cacheable_metadata) use ($blocks) {

View File

@ -45,7 +45,7 @@ class BlockContentLocalTasksTest extends LocalTaskIntegrationTestBase {
$theme_handler = $this->createMock('Drupal\Core\Extension\ThemeHandlerInterface'); $theme_handler = $this->createMock('Drupal\Core\Extension\ThemeHandlerInterface');
$theme_handler->expects($this->any()) $theme_handler->expects($this->any())
->method('listInfo') ->method('listInfo')
->will($this->returnValue($themes)); ->willReturn($themes);
$container = new ContainerBuilder(); $container = new ContainerBuilder();
$container->set('config.factory', $config_factory); $container->set('config.factory', $config_factory);

View File

@ -26,28 +26,28 @@ class CommentManagerTest extends UnitTestCase {
$entity_type = $this->createMock('Drupal\Core\Entity\ContentEntityTypeInterface'); $entity_type = $this->createMock('Drupal\Core\Entity\ContentEntityTypeInterface');
$entity_type->expects($this->any()) $entity_type->expects($this->any())
->method('getClass') ->method('getClass')
->will($this->returnValue('Node')); ->willReturn('Node');
$entity_type->expects($this->any()) $entity_type->expects($this->any())
->method('entityClassImplements') ->method('entityClassImplements')
->with(FieldableEntityInterface::class) ->with(FieldableEntityInterface::class)
->will($this->returnValue(TRUE)); ->willReturn(TRUE);
$entity_field_manager = $this->createMock(EntityFieldManagerInterface::class); $entity_field_manager = $this->createMock(EntityFieldManagerInterface::class);
$entity_type_manager = $this->createMock(EntityTypeManagerInterface::class); $entity_type_manager = $this->createMock(EntityTypeManagerInterface::class);
$entity_field_manager->expects($this->once()) $entity_field_manager->expects($this->once())
->method('getFieldMapByFieldType') ->method('getFieldMapByFieldType')
->will($this->returnValue([ ->willReturn([
'node' => [ 'node' => [
'field_foobar' => [ 'field_foobar' => [
'type' => 'comment', 'type' => 'comment',
], ],
], ],
])); ]);
$entity_type_manager->expects($this->any()) $entity_type_manager->expects($this->any())
->method('getDefinition') ->method('getDefinition')
->will($this->returnValue($entity_type)); ->willReturn($entity_type);
$comment_manager = new CommentManager( $comment_manager = new CommentManager(
$entity_type_manager, $entity_type_manager,

View File

@ -73,7 +73,7 @@ class CommentStatisticsUnitTest extends UnitTestCase {
$this->select->expects($this->any()) $this->select->expects($this->any())
->method('execute') ->method('execute')
->will($this->returnValue($this->statement)); ->willReturn($this->statement);
$this->database = $this->getMockBuilder('Drupal\Core\Database\Connection') $this->database = $this->getMockBuilder('Drupal\Core\Database\Connection')
->disableOriginalConstructor() ->disableOriginalConstructor()
@ -81,7 +81,7 @@ class CommentStatisticsUnitTest extends UnitTestCase {
$this->database->expects($this->once()) $this->database->expects($this->once())
->method('select') ->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); $this->commentStatistics = new CommentStatistics($this->database, $this->createMock('Drupal\Core\Session\AccountInterface'), $this->createMock(EntityTypeManagerInterface::class), $this->createMock('Drupal\Core\State\StateInterface'), $this->database);
} }

View File

@ -33,7 +33,7 @@ class CommentLockTest extends UnitTestCase {
$lock->expects($this->once()) $lock->expects($this->once())
->method('acquire') ->method('acquire')
->with($lock_name, 30) ->with($lock_name, 30)
->will($this->returnValue(TRUE)); ->willReturn(TRUE);
$lock->expects($this->once()) $lock->expects($this->once())
->method('release') ->method('release')
->with($lock_name); ->with($lock_name);
@ -55,27 +55,27 @@ class CommentLockTest extends UnitTestCase {
->getMock(); ->getMock();
$comment->expects($this->once()) $comment->expects($this->once())
->method('isNew') ->method('isNew')
->will($this->returnValue(TRUE)); ->willReturn(TRUE);
$comment->expects($this->once()) $comment->expects($this->once())
->method('hasParentComment') ->method('hasParentComment')
->will($this->returnValue(TRUE)); ->willReturn(TRUE);
$comment->expects($this->once()) $comment->expects($this->once())
->method('getParentComment') ->method('getParentComment')
->will($this->returnValue($comment)); ->willReturn($comment);
$comment->expects($this->once()) $comment->expects($this->once())
->method('getCommentedEntityId') ->method('getCommentedEntityId')
->will($this->returnValue($cid)); ->willReturn($cid);
$comment->expects($this->any()) $comment->expects($this->any())
->method('getThread') ->method('getThread')
->will($this->returnValue('')); ->willReturn('');
$anon_user = $this->createMock('Drupal\Core\Session\AccountInterface'); $anon_user = $this->createMock('Drupal\Core\Session\AccountInterface');
$anon_user->expects($this->any()) $anon_user->expects($this->any())
->method('isAnonymous') ->method('isAnonymous')
->will($this->returnValue(TRUE)); ->willReturn(TRUE);
$comment->expects($this->any()) $comment->expects($this->any())
->method('getOwner') ->method('getOwner')
->will($this->returnValue($anon_user)); ->willReturn($anon_user);
$parent_entity = $this->createMock('\Drupal\Core\Entity\ContentEntityInterface'); $parent_entity = $this->createMock('\Drupal\Core\Entity\ContentEntityInterface');
$parent_entity->expects($this->atLeastOnce()) $parent_entity->expects($this->atLeastOnce())
@ -88,7 +88,7 @@ class CommentLockTest extends UnitTestCase {
$entity_type = $this->createMock('\Drupal\Core\Entity\EntityTypeInterface'); $entity_type = $this->createMock('\Drupal\Core\Entity\EntityTypeInterface');
$comment->expects($this->any()) $comment->expects($this->any())
->method('getEntityType') ->method('getEntityType')
->will($this->returnValue($entity_type)); ->willReturn($entity_type);
$storage = $this->createMock('Drupal\comment\CommentStorageInterface'); $storage = $this->createMock('Drupal\comment\CommentStorageInterface');
// preSave() should acquire the lock. (This is what's really being tested.) // preSave() should acquire the lock. (This is what's really being tested.)

View File

@ -33,26 +33,26 @@ class CommentBulkFormTest extends UnitTestCase {
$action = $this->createMock('\Drupal\system\ActionConfigEntityInterface'); $action = $this->createMock('\Drupal\system\ActionConfigEntityInterface');
$action->expects($this->any()) $action->expects($this->any())
->method('getType') ->method('getType')
->will($this->returnValue('comment')); ->willReturn('comment');
$actions[$i] = $action; $actions[$i] = $action;
} }
$action = $this->createMock('\Drupal\system\ActionConfigEntityInterface'); $action = $this->createMock('\Drupal\system\ActionConfigEntityInterface');
$action->expects($this->any()) $action->expects($this->any())
->method('getType') ->method('getType')
->will($this->returnValue('user')); ->willReturn('user');
$actions[] = $action; $actions[] = $action;
$entity_storage = $this->createMock('Drupal\Core\Entity\EntityStorageInterface'); $entity_storage = $this->createMock('Drupal\Core\Entity\EntityStorageInterface');
$entity_storage->expects($this->any()) $entity_storage->expects($this->any())
->method('loadMultiple') ->method('loadMultiple')
->will($this->returnValue($actions)); ->willReturn($actions);
$entity_type_manager = $this->createMock(EntityTypeManagerInterface::class); $entity_type_manager = $this->createMock(EntityTypeManagerInterface::class);
$entity_type_manager->expects($this->once()) $entity_type_manager->expects($this->once())
->method('getStorage') ->method('getStorage')
->with('action') ->with('action')
->will($this->returnValue($entity_storage)); ->willReturn($entity_storage);
$entity_repository = $this->createMock(EntityRepositoryInterface::class); $entity_repository = $this->createMock(EntityRepositoryInterface::class);
@ -66,7 +66,7 @@ class CommentBulkFormTest extends UnitTestCase {
$views_data->expects($this->any()) $views_data->expects($this->any())
->method('get') ->method('get')
->with('comment') ->with('comment')
->will($this->returnValue(['table' => ['entity type' => 'comment']])); ->willReturn(['table' => ['entity type' => 'comment']]);
$container = new ContainerBuilder(); $container = new ContainerBuilder();
$container->set('views.views_data', $views_data); $container->set('views.views_data', $views_data);
$container->set('string_translation', $this->getStringTranslationStub()); $container->set('string_translation', $this->getStringTranslationStub());
@ -76,7 +76,7 @@ class CommentBulkFormTest extends UnitTestCase {
$storage->expects($this->any()) $storage->expects($this->any())
->method('get') ->method('get')
->with('base_table') ->with('base_table')
->will($this->returnValue('comment')); ->willReturn('comment');
$executable = $this->getMockBuilder('Drupal\views\ViewExecutable') $executable = $this->getMockBuilder('Drupal\views\ViewExecutable')
->disableOriginalConstructor() ->disableOriginalConstructor()

View File

@ -70,7 +70,7 @@ class ConfigEntityMapperTest extends UnitTestCase {
->expects($this->any()) ->expects($this->any())
->method('getRouteByName') ->method('getRouteByName')
->with('entity.configurable_language.edit_form') ->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 = [ $definition = [
'class' => '\Drupal\config_translation\ConfigEntityMapper', 'class' => '\Drupal\config_translation\ConfigEntityMapper',
@ -114,18 +114,18 @@ class ConfigEntityMapperTest extends UnitTestCase {
->expects($this->once()) ->expects($this->once())
->method('id') ->method('id')
->with() ->with()
->will($this->returnValue('entity_id')); ->willReturn('entity_id');
$entity_type = $this->createMock('Drupal\Core\Config\Entity\ConfigEntityTypeInterface'); $entity_type = $this->createMock('Drupal\Core\Config\Entity\ConfigEntityTypeInterface');
$entity_type $entity_type
->expects($this->any()) ->expects($this->any())
->method('getConfigPrefix') ->method('getConfigPrefix')
->will($this->returnValue('config_prefix')); ->willReturn('config_prefix');
$this->entityTypeManager $this->entityTypeManager
->expects($this->once()) ->expects($this->once())
->method('getDefinition') ->method('getDefinition')
->with('configurable_language') ->with('configurable_language')
->will($this->returnValue($entity_type)); ->willReturn($entity_type);
// No entity is set. // No entity is set.
$this->assertNull($this->configEntityMapper->getEntity()); $this->assertNull($this->configEntityMapper->getEntity());
@ -154,14 +154,14 @@ class ConfigEntityMapperTest extends UnitTestCase {
->expects($this->once()) ->expects($this->once())
->method('getDefinition') ->method('getDefinition')
->with('configurable_language') ->with('configurable_language')
->will($this->returnValue($entity_type)); ->willReturn($entity_type);
$this->configEntityMapper->setEntity($this->entity); $this->configEntityMapper->setEntity($this->entity);
$this->entity $this->entity
->expects($this->once()) ->expects($this->once())
->method('id') ->method('id')
->with() ->with()
->will($this->returnValue('entity_id')); ->willReturn('entity_id');
$result = $this->configEntityMapper->getOverviewRouteParameters(); $result = $this->configEntityMapper->getOverviewRouteParameters();
@ -183,12 +183,12 @@ class ConfigEntityMapperTest extends UnitTestCase {
$entity_type = $this->createMock('Drupal\Core\Config\Entity\ConfigEntityTypeInterface'); $entity_type = $this->createMock('Drupal\Core\Config\Entity\ConfigEntityTypeInterface');
$entity_type->expects($this->once()) $entity_type->expects($this->once())
->method('getLabel') ->method('getLabel')
->will($this->returnValue('test')); ->willReturn('test');
$this->entityTypeManager $this->entityTypeManager
->expects($this->once()) ->expects($this->once())
->method('getDefinition') ->method('getDefinition')
->with('configurable_language') ->with('configurable_language')
->will($this->returnValue($entity_type)); ->willReturn($entity_type);
$result = $this->configEntityMapper->getTypeName(); $result = $this->configEntityMapper->getTypeName();
$this->assertSame('test', $result); $this->assertSame('test', $result);
@ -201,12 +201,12 @@ class ConfigEntityMapperTest extends UnitTestCase {
$entity_type = $this->createMock('Drupal\Core\Config\Entity\ConfigEntityTypeInterface'); $entity_type = $this->createMock('Drupal\Core\Config\Entity\ConfigEntityTypeInterface');
$entity_type->expects($this->once()) $entity_type->expects($this->once())
->method('getLabel') ->method('getLabel')
->will($this->returnValue('test')); ->willReturn('test');
$this->entityTypeManager $this->entityTypeManager
->expects($this->once()) ->expects($this->once())
->method('getDefinition') ->method('getDefinition')
->with('configurable_language') ->with('configurable_language')
->will($this->returnValue($entity_type)); ->willReturn($entity_type);
$result = $this->configEntityMapper->getTypeLabel(); $result = $this->configEntityMapper->getTypeLabel();
$this->assertSame('test', $result); $this->assertSame('test', $result);

View File

@ -88,23 +88,23 @@ class ConfigFieldMapperTest extends UnitTestCase {
$entity_type $entity_type
->expects($this->any()) ->expects($this->any())
->method('getConfigPrefix') ->method('getConfigPrefix')
->will($this->returnValue('config_prefix')); ->willReturn('config_prefix');
$this->entityTypeManager $this->entityTypeManager
->expects($this->any()) ->expects($this->any())
->method('getDefinition') ->method('getDefinition')
->will($this->returnValue($entity_type)); ->willReturn($entity_type);
$field_storage = $this->createMock('Drupal\field\FieldStorageConfigInterface'); $field_storage = $this->createMock('Drupal\field\FieldStorageConfigInterface');
$field_storage $field_storage
->expects($this->any()) ->expects($this->any())
->method('id') ->method('id')
->will($this->returnValue('field_storage_id')); ->willReturn('field_storage_id');
$this->entity $this->entity
->expects($this->any()) ->expects($this->any())
->method('getFieldStorageDefinition') ->method('getFieldStorageDefinition')
->will($this->returnValue($field_storage)); ->willReturn($field_storage);
$result = $this->configFieldMapper->setEntity($this->entity); $result = $this->configFieldMapper->setEntity($this->entity);
$this->assertTrue($result); $this->assertTrue($result);

View File

@ -39,7 +39,7 @@ class ConfigMapperManagerTest extends UnitTestCase {
$language_manager->expects($this->once()) $language_manager->expects($this->once())
->method('getCurrentLanguage') ->method('getCurrentLanguage')
->with(LanguageInterface::TYPE_INTERFACE) ->with(LanguageInterface::TYPE_INTERFACE)
->will($this->returnValue($language)); ->willReturn($language);
$this->typedConfigManager = $this->getMockBuilder('Drupal\Core\Config\TypedConfigManagerInterface') $this->typedConfigManager = $this->getMockBuilder('Drupal\Core\Config\TypedConfigManagerInterface')
->getMock(); ->getMock();
@ -71,7 +71,7 @@ class ConfigMapperManagerTest extends UnitTestCase {
->expects($this->once()) ->expects($this->once())
->method('get') ->method('get')
->with('test') ->with('test')
->will($this->returnValue($element)); ->willReturn($element);
$result = $this->configMapperManager->hasTranslatable('test'); $result = $this->configMapperManager->hasTranslatable('test');
$this->assertSame($expected, $result); $this->assertSame($expected, $result);
@ -154,7 +154,7 @@ class ConfigMapperManagerTest extends UnitTestCase {
$element = $this->createMock('Drupal\Core\TypedData\TypedDataInterface'); $element = $this->createMock('Drupal\Core\TypedData\TypedDataInterface');
$element->expects($this->any()) $element->expects($this->any())
->method('getDataDefinition') ->method('getDataDefinition')
->will($this->returnValue($data_definition)); ->willReturn($data_definition);
return $element; return $element;
} }
@ -179,7 +179,7 @@ class ConfigMapperManagerTest extends UnitTestCase {
->getMock(); ->getMock();
$nested_element->expects($this->once()) $nested_element->expects($this->once())
->method('getIterator') ->method('getIterator')
->will($this->returnValue(new \ArrayIterator($elements))); ->willReturn(new \ArrayIterator($elements));
return $nested_element; return $nested_element;
} }

View File

@ -128,7 +128,7 @@ class ConfigNamesMapperTest extends UnitTestCase {
->expects($this->any()) ->expects($this->any())
->method('getRouteByName') ->method('getRouteByName')
->with('system.site_information_settings') ->with('system.site_information_settings')
->will($this->returnValue($this->baseRoute)); ->willReturn($this->baseRoute);
$this->languageManager = $this->createMock('Drupal\Core\Language\LanguageManagerInterface'); $this->languageManager = $this->createMock('Drupal\Core\Language\LanguageManagerInterface');

View File

@ -86,11 +86,11 @@ class MailHandlerTest extends UnitTestCase {
$this->languageManager->expects($this->any()) $this->languageManager->expects($this->any())
->method('getDefaultLanguage') ->method('getDefaultLanguage')
->will($this->returnValue($language)); ->willReturn($language);
$this->languageManager->expects($this->any()) $this->languageManager->expects($this->any())
->method('getCurrentLanguage') ->method('getCurrentLanguage')
->will($this->returnValue($language)); ->willReturn($language);
} }
/** /**

View File

@ -42,14 +42,14 @@ class ContentModerationRouteSubscriberTest extends UnitTestCase {
$definition = $this->createMock(EntityTypeInterface::class); $definition = $this->createMock(EntityTypeInterface::class);
$definition->expects($this->any()) $definition->expects($this->any())
->method('getClass') ->method('getClass')
->will($this->returnValue(SimpleTestEntity::class)); ->willReturn(SimpleTestEntity::class);
$definition->expects($this->any()) $definition->expects($this->any())
->method('isRevisionable') ->method('isRevisionable')
->willReturn(FALSE); ->willReturn(FALSE);
$revisionable_definition = $this->createMock(EntityTypeInterface::class); $revisionable_definition = $this->createMock(EntityTypeInterface::class);
$revisionable_definition->expects($this->any()) $revisionable_definition->expects($this->any())
->method('getClass') ->method('getClass')
->will($this->returnValue(SimpleTestEntity::class)); ->willReturn(SimpleTestEntity::class);
$revisionable_definition->expects($this->any()) $revisionable_definition->expects($this->any())
->method('isRevisionable') ->method('isRevisionable')
->willReturn(TRUE); ->willReturn(TRUE);

View File

@ -53,13 +53,13 @@ class ContentTranslationManageAccessCheckTest extends UnitTestCase {
$translation_handler = $this->createMock('\Drupal\content_translation\ContentTranslationHandlerInterface'); $translation_handler = $this->createMock('\Drupal\content_translation\ContentTranslationHandlerInterface');
$translation_handler->expects($this->once()) $translation_handler->expects($this->once())
->method('getTranslationAccess') ->method('getTranslationAccess')
->will($this->returnValue(AccessResult::allowed())); ->willReturn(AccessResult::allowed());
$entity_type_manager = $this->createMock(EntityTypeManagerInterface::class); $entity_type_manager = $this->createMock(EntityTypeManagerInterface::class);
$entity_type_manager->expects($this->once()) $entity_type_manager->expects($this->once())
->method('getHandler') ->method('getHandler')
->withAnyParameters() ->withAnyParameters()
->will($this->returnValue($translation_handler)); ->willReturn($translation_handler);
// Set our source and target languages. // Set our source and target languages.
$source = 'en'; $source = 'en';
@ -87,7 +87,7 @@ class ContentTranslationManageAccessCheckTest extends UnitTestCase {
$entity->expects($this->once()) $entity->expects($this->once())
->method('getTranslationLanguages') ->method('getTranslationLanguages')
->with() ->with()
->will($this->returnValue([])); ->willReturn([]);
$entity->expects($this->once()) $entity->expects($this->once())
->method('getCacheContexts') ->method('getCacheContexts')
->willReturn([]); ->willReturn([]);
@ -96,7 +96,7 @@ class ContentTranslationManageAccessCheckTest extends UnitTestCase {
->willReturn(Cache::PERMANENT); ->willReturn(Cache::PERMANENT);
$entity->expects($this->once()) $entity->expects($this->once())
->method('getCacheTags') ->method('getCacheTags')
->will($this->returnValue(['node:1337'])); ->willReturn(['node:1337']);
$entity->expects($this->once()) $entity->expects($this->once())
->method('getCacheContexts') ->method('getCacheContexts')
->willReturn([]); ->willReturn([]);
@ -110,7 +110,7 @@ class ContentTranslationManageAccessCheckTest extends UnitTestCase {
$route_match->expects($this->once()) $route_match->expects($this->once())
->method('getParameter') ->method('getParameter')
->with('node') ->with('node')
->will($this->returnValue($entity)); ->willReturn($entity);
// Set the mock account. // Set the mock account.
$account = $this->createMock('Drupal\Core\Session\AccountInterface'); $account = $this->createMock('Drupal\Core\Session\AccountInterface');

View File

@ -34,9 +34,9 @@ class ContentTranslationLocalTasksTest extends LocalTaskIntegrationTestBase {
$content_translation_manager = $this->createMock('Drupal\content_translation\ContentTranslationManagerInterface'); $content_translation_manager = $this->createMock('Drupal\content_translation\ContentTranslationManagerInterface');
$content_translation_manager->expects($this->any()) $content_translation_manager->expects($this->any())
->method('getSupportedEntityTypes') ->method('getSupportedEntityTypes')
->will($this->returnValue([ ->willReturn([
'node' => $entity_type, 'node' => $entity_type,
])); ]);
\Drupal::getContainer()->set('content_translation.manager', $content_translation_manager); \Drupal::getContainer()->set('content_translation.manager', $content_translation_manager);
\Drupal::getContainer()->set('string_translation', $this->getStringTranslationStub()); \Drupal::getContainer()->set('string_translation', $this->getStringTranslationStub());
} }

View File

@ -55,7 +55,7 @@ class DateFieldTest extends UnitTestCase {
$migration->expects($this->once()) $migration->expects($this->once())
->method('mergeProcessOfProperty') ->method('mergeProcessOfProperty')
->with('field_date', $pipeline) ->with('field_date', $pipeline)
->will($this->returnValue($migration)); ->willReturn($migration);
$plugin = new DateField([], '', []); $plugin = new DateField([], '', []);
$plugin->defineValueProcessPipeline($migration, 'field_date', $data); $plugin->defineValueProcessPipeline($migration, 'field_date', $data);

View File

@ -65,13 +65,13 @@ class EditorConfigEntityUnitTest extends UnitTestCase {
$this->entityType = $this->createMock('\Drupal\Core\Entity\EntityTypeInterface'); $this->entityType = $this->createMock('\Drupal\Core\Entity\EntityTypeInterface');
$this->entityType->expects($this->any()) $this->entityType->expects($this->any())
->method('getProvider') ->method('getProvider')
->will($this->returnValue('editor')); ->willReturn('editor');
$this->entityTypeManager = $this->createMock(EntityTypeManagerInterface::class); $this->entityTypeManager = $this->createMock(EntityTypeManagerInterface::class);
$this->entityTypeManager->expects($this->any()) $this->entityTypeManager->expects($this->any())
->method('getDefinition') ->method('getDefinition')
->with($this->entityTypeId) ->with($this->entityTypeId)
->will($this->returnValue($this->entityType)); ->willReturn($this->entityType);
$this->uuid = $this->createMock('\Drupal\Component\Uuid\UuidInterface'); $this->uuid = $this->createMock('\Drupal\Component\Uuid\UuidInterface');
@ -98,33 +98,33 @@ class EditorConfigEntityUnitTest extends UnitTestCase {
->getMock(); ->getMock();
$plugin->expects($this->once()) $plugin->expects($this->once())
->method('getPluginDefinition') ->method('getPluginDefinition')
->will($this->returnValue(['provider' => 'test_module'])); ->willReturn(['provider' => 'test_module']);
$plugin->expects($this->once()) $plugin->expects($this->once())
->method('getDefaultSettings') ->method('getDefaultSettings')
->will($this->returnValue([])); ->willReturn([]);
$this->editorPluginManager->expects($this->any()) $this->editorPluginManager->expects($this->any())
->method('createInstance') ->method('createInstance')
->with($this->editorId) ->with($this->editorId)
->will($this->returnValue($plugin)); ->willReturn($plugin);
$entity = new Editor($values, $this->entityTypeId); $entity = new Editor($values, $this->entityTypeId);
$filter_format = $this->createMock('Drupal\Core\Config\Entity\ConfigEntityInterface'); $filter_format = $this->createMock('Drupal\Core\Config\Entity\ConfigEntityInterface');
$filter_format->expects($this->once()) $filter_format->expects($this->once())
->method('getConfigDependencyName') ->method('getConfigDependencyName')
->will($this->returnValue('filter.format.test')); ->willReturn('filter.format.test');
$storage = $this->createMock('Drupal\Core\Entity\EntityStorageInterface'); $storage = $this->createMock('Drupal\Core\Entity\EntityStorageInterface');
$storage->expects($this->once()) $storage->expects($this->once())
->method('load') ->method('load')
->with($format_id) ->with($format_id)
->will($this->returnValue($filter_format)); ->willReturn($filter_format);
$this->entityTypeManager->expects($this->once()) $this->entityTypeManager->expects($this->once())
->method('getStorage') ->method('getStorage')
->with('filter_format') ->with('filter_format')
->will($this->returnValue($storage)); ->willReturn($storage);
$dependencies = $entity->calculateDependencies()->getDependencies(); $dependencies = $entity->calculateDependencies()->getDependencies();
$this->assertContains('test_module', $dependencies['module']); $this->assertContains('test_module', $dependencies['module']);

View File

@ -34,7 +34,7 @@ class StandardTest extends UnitTestCase {
->getMock(); ->getMock();
$this->format->expects($this->any()) $this->format->expects($this->any())
->method('getFilterTypes') ->method('getFilterTypes')
->will($this->returnValue([FilterInterface::TYPE_HTML_RESTRICTOR])); ->willReturn([FilterInterface::TYPE_HTML_RESTRICTOR]);
$restrictions = [ $restrictions = [
'allowed' => [ 'allowed' => [
'p' => TRUE, 'p' => TRUE,
@ -47,7 +47,7 @@ class StandardTest extends UnitTestCase {
]; ];
$this->format->expects($this->any()) $this->format->expects($this->any())
->method('getHtmlRestrictions') ->method('getHtmlRestrictions')
->will($this->returnValue($restrictions)); ->willReturn($restrictions);
} }
/** /**

View File

@ -95,10 +95,10 @@ class FieldConfigEntityUnitTest extends UnitTestCase {
$this->fieldStorage = $this->createMock('\Drupal\field\FieldStorageConfigInterface'); $this->fieldStorage = $this->createMock('\Drupal\field\FieldStorageConfigInterface');
$this->fieldStorage->expects($this->any()) $this->fieldStorage->expects($this->any())
->method('getType') ->method('getType')
->will($this->returnValue('test_field')); ->willReturn('test_field');
$this->fieldStorage->expects($this->any()) $this->fieldStorage->expects($this->any())
->method('getName') ->method('getName')
->will($this->returnValue('field_test')); ->willReturn('field_test');
$this->fieldStorage->expects($this->any()) $this->fieldStorage->expects($this->any())
->method('getSettings') ->method('getSettings')
->willReturn([]); ->willReturn([]);
@ -106,9 +106,9 @@ class FieldConfigEntityUnitTest extends UnitTestCase {
$this->entityFieldManager->expects($this->any()) $this->entityFieldManager->expects($this->any())
->method('getFieldStorageDefinitions') ->method('getFieldStorageDefinitions')
->with('test_entity_type') ->with('test_entity_type')
->will($this->returnValue([ ->willReturn([
$this->fieldStorage->getName() => $this->fieldStorage, $this->fieldStorage->getName() => $this->fieldStorage,
])); ]);
} }
/** /**
@ -119,7 +119,7 @@ class FieldConfigEntityUnitTest extends UnitTestCase {
$target_entity_type = $this->createMock('\Drupal\Core\Entity\EntityTypeInterface'); $target_entity_type = $this->createMock('\Drupal\Core\Entity\EntityTypeInterface');
$target_entity_type->expects($this->any()) $target_entity_type->expects($this->any())
->method('getBundleConfigDependency') ->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()) $this->entityTypeManager->expects($this->any())
->method('getDefinition') ->method('getDefinition')
@ -135,7 +135,7 @@ class FieldConfigEntityUnitTest extends UnitTestCase {
$this->fieldStorage->expects($this->once()) $this->fieldStorage->expects($this->once())
->method('getConfigDependencyName') ->method('getConfigDependencyName')
->will($this->returnValue('field.storage.test_entity_type.test_field')); ->willReturn('field.storage.test_entity_type.test_field');
$field = new FieldConfig([ $field = new FieldConfig([
'field_name' => $this->fieldStorage->getName(), 'field_name' => $this->fieldStorage->getName(),
@ -157,12 +157,12 @@ class FieldConfigEntityUnitTest extends UnitTestCase {
$storage->expects($this->any()) $storage->expects($this->any())
->method('load') ->method('load')
->with('test_bundle_not_exists') ->with('test_bundle_not_exists')
->will($this->returnValue(NULL)); ->willReturn(NULL);
$this->entityTypeManager->expects($this->any()) $this->entityTypeManager->expects($this->any())
->method('getStorage') ->method('getStorage')
->with('bundle_entity_type') ->with('bundle_entity_type')
->will($this->returnValue($storage)); ->willReturn($storage);
$target_entity_type = new EntityType([ $target_entity_type = new EntityType([
'id' => 'test_entity_type', 'id' => 'test_entity_type',
@ -252,15 +252,15 @@ class FieldConfigEntityUnitTest extends UnitTestCase {
$this->entityTypeManager->expects($this->any()) $this->entityTypeManager->expects($this->any())
->method('getDefinition') ->method('getDefinition')
->with($this->entityTypeId) ->with($this->entityTypeId)
->will($this->returnValue($this->entityType)); ->willReturn($this->entityType);
$this->entityType->expects($this->once()) $this->entityType->expects($this->once())
->method('getKey') ->method('getKey')
->with('id') ->with('id')
->will($this->returnValue('id')); ->willReturn('id');
$this->entityType->expects($this->once()) $this->entityType->expects($this->once())
->method('getPropertiesToExport') ->method('getPropertiesToExport')
->with('test_entity_type.test_bundle.field_test') ->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(); $export = $field->toArray();
$this->assertEquals($expected, $export); $this->assertEquals($expected, $export);

View File

@ -68,11 +68,11 @@ class FieldStorageConfigAccessControlHandlerTest extends UnitTestCase {
$this->anon $this->anon
->expects($this->any()) ->expects($this->any())
->method('hasPermission') ->method('hasPermission')
->will($this->returnValue(FALSE)); ->willReturn(FALSE);
$this->anon $this->anon
->expects($this->any()) ->expects($this->any())
->method('id') ->method('id')
->will($this->returnValue(0)); ->willReturn(0);
$this->member = $this->createMock(AccountInterface::class); $this->member = $this->createMock(AccountInterface::class);
$this->member $this->member
@ -84,23 +84,23 @@ class FieldStorageConfigAccessControlHandlerTest extends UnitTestCase {
$this->member $this->member
->expects($this->any()) ->expects($this->any())
->method('id') ->method('id')
->will($this->returnValue(2)); ->willReturn(2);
$storageType = $this->createMock(ConfigEntityTypeInterface::class); $storageType = $this->createMock(ConfigEntityTypeInterface::class);
$storageType $storageType
->expects($this->any()) ->expects($this->any())
->method('getProvider') ->method('getProvider')
->will($this->returnValue('field')); ->willReturn('field');
$storageType $storageType
->expects($this->any()) ->expects($this->any())
->method('getConfigPrefix') ->method('getConfigPrefix')
->will($this->returnValue('field.storage')); ->willReturn('field.storage');
$entityType = $this->createMock(ConfigEntityTypeInterface::class); $entityType = $this->createMock(ConfigEntityTypeInterface::class);
$entityType $entityType
->expects($this->any()) ->expects($this->any())
->method('getProvider') ->method('getProvider')
->will($this->returnValue('node')); ->willReturn('node');
$entityType $entityType
->expects($this->any()) ->expects($this->any())
->method('getConfigPrefix') ->method('getConfigPrefix')
@ -110,7 +110,7 @@ class FieldStorageConfigAccessControlHandlerTest extends UnitTestCase {
$this->moduleHandler $this->moduleHandler
->expects($this->any()) ->expects($this->any())
->method('invokeAll') ->method('invokeAll')
->will($this->returnValue([])); ->willReturn([]);
$storage_access_control_handler = new FieldStorageConfigAccessControlHandler($storageType); $storage_access_control_handler = new FieldStorageConfigAccessControlHandler($storageType);
$storage_access_control_handler->setModuleHandler($this->moduleHandler); $storage_access_control_handler->setModuleHandler($this->moduleHandler);

View File

@ -73,14 +73,14 @@ class FieldStorageConfigEntityUnitTest extends UnitTestCase {
$fieldStorageConfigentityType = $this->createMock('\Drupal\Core\Config\Entity\ConfigEntityTypeInterface'); $fieldStorageConfigentityType = $this->createMock('\Drupal\Core\Config\Entity\ConfigEntityTypeInterface');
$fieldStorageConfigentityType->expects($this->any()) $fieldStorageConfigentityType->expects($this->any())
->method('getProvider') ->method('getProvider')
->will($this->returnValue('field')); ->willReturn('field');
// Create a mock entity type to attach the field to. // Create a mock entity type to attach the field to.
$attached_entity_type_id = $this->randomMachineName(); $attached_entity_type_id = $this->randomMachineName();
$attached_entity_type = $this->createMock('\Drupal\Core\Entity\EntityTypeInterface'); $attached_entity_type = $this->createMock('\Drupal\Core\Entity\EntityTypeInterface');
$attached_entity_type->expects($this->any()) $attached_entity_type->expects($this->any())
->method('getProvider') ->method('getProvider')
->will($this->returnValue('entity_provider_module')); ->willReturn('entity_provider_module');
// Get definition is called three times. Twice in // Get definition is called three times. Twice in
// ConfigEntityBase::addDependency() to get the provider of the field config // ConfigEntityBase::addDependency() to get the provider of the field config

View File

@ -57,7 +57,7 @@ class ForumListingBreadcrumbBuilderTest extends UnitTestCase {
$route_match = $this->createMock('Drupal\Core\Routing\RouteMatchInterface'); $route_match = $this->createMock('Drupal\Core\Routing\RouteMatchInterface');
$route_match->expects($this->once()) $route_match->expects($this->once())
->method('getRouteName') ->method('getRouteName')
->will($this->returnValue($route_name)); ->willReturn($route_name);
$route_match->expects($this->any()) $route_match->expects($this->any())
->method('getParameter') ->method('getParameter')
->willReturnMap($parameter_map); ->willReturnMap($parameter_map);
@ -196,7 +196,7 @@ class ForumListingBreadcrumbBuilderTest extends UnitTestCase {
$route_match->expects($this->exactly(2)) $route_match->expects($this->exactly(2))
->method('getParameter') ->method('getParameter')
->with('taxonomy_term') ->with('taxonomy_term')
->will($this->returnValue($forum_listing)); ->willReturn($forum_listing);
// First test. // First test.
$expected1 = [ $expected1 = [

View File

@ -52,7 +52,7 @@ class ForumNodeBreadcrumbBuilderTest extends UnitTestCase {
$forum_manager = $this->createMock('Drupal\forum\ForumManagerInterface'); $forum_manager = $this->createMock('Drupal\forum\ForumManagerInterface');
$forum_manager->expects($this->any()) $forum_manager->expects($this->any())
->method('checkNodeType') ->method('checkNodeType')
->will($this->returnValue(TRUE)); ->willReturn(TRUE);
$translation_manager = $this->createMock('Drupal\Core\StringTranslation\TranslationInterface'); $translation_manager = $this->createMock('Drupal\Core\StringTranslation\TranslationInterface');
@ -62,7 +62,7 @@ class ForumNodeBreadcrumbBuilderTest extends UnitTestCase {
$route_match = $this->createMock('Drupal\Core\Routing\RouteMatchInterface'); $route_match = $this->createMock('Drupal\Core\Routing\RouteMatchInterface');
$route_match->expects($this->once()) $route_match->expects($this->once())
->method('getRouteName') ->method('getRouteName')
->will($this->returnValue($route_name)); ->willReturn($route_name);
$route_match->expects($this->any()) $route_match->expects($this->any())
->method('getParameter') ->method('getParameter')
->willReturnMap($parameter_map); ->willReturnMap($parameter_map);
@ -201,7 +201,7 @@ class ForumNodeBreadcrumbBuilderTest extends UnitTestCase {
$route_match->expects($this->exactly(2)) $route_match->expects($this->exactly(2))
->method('getParameter') ->method('getParameter')
->with('node') ->with('node')
->will($this->returnValue($forum_node)); ->willReturn($forum_node);
// First test. // First test.
$expected1 = [ $expected1 = [

View File

@ -31,22 +31,22 @@ class ForumManagerTest extends UnitTestCase {
$config_factory->expects($this->once()) $config_factory->expects($this->once())
->method('get') ->method('get')
->will($this->returnValue($config)); ->willReturn($config);
$config->expects($this->once()) $config->expects($this->once())
->method('get') ->method('get')
->will($this->returnValue('forums')); ->willReturn('forums');
$entity_type_manager->expects($this->once()) $entity_type_manager->expects($this->once())
->method('getStorage') ->method('getStorage')
->will($this->returnValue($storage)); ->willReturn($storage);
// This is sufficient for testing purposes. // This is sufficient for testing purposes.
$term = new \stdClass(); $term = new \stdClass();
$storage->expects($this->once()) $storage->expects($this->once())
->method('create') ->method('create')
->will($this->returnValue($term)); ->willReturn($term);
$connection = $this->getMockBuilder('\Drupal\Core\Database\Connection') $connection = $this->getMockBuilder('\Drupal\Core\Database\Connection')
->disableOriginalConstructor() ->disableOriginalConstructor()
@ -74,7 +74,7 @@ class ForumManagerTest extends UnitTestCase {
$manager->expects($this->once()) $manager->expects($this->once())
->method('getChildren') ->method('getChildren')
->will($this->returnValue([])); ->willReturn([]);
// Get the index once. // Get the index once.
$index1 = $manager->getIndex(); $index1 = $manager->getIndex();

View File

@ -57,7 +57,7 @@ class FieldNormalizerDenormalizeExceptionsTest extends UnitTestCase {
->getMock(); ->getMock();
$mock->expects($this->any()) $mock->expects($this->any())
->method('getParent') ->method('getParent')
->will($this->returnValue(NULL)); ->willReturn(NULL);
return [ return [
[[]], [[]],
[['target_instance' => $mock]], [['target_instance' => $mock]],

View File

@ -53,7 +53,7 @@ class ImageStyleTest extends UnitTestCase {
$effectManager->expects($this->any()) $effectManager->expects($this->any())
->method('createInstance') ->method('createInstance')
->with($image_effect_id) ->with($image_effect_id)
->will($this->returnValue($image_effect)); ->willReturn($image_effect);
$default_stubs = ['getImageEffectPluginManager', 'fileDefaultScheme']; $default_stubs = ['getImageEffectPluginManager', 'fileDefaultScheme'];
$image_style = $this->getMockBuilder('\Drupal\image\Entity\ImageStyle') $image_style = $this->getMockBuilder('\Drupal\image\Entity\ImageStyle')
->setConstructorArgs([ ->setConstructorArgs([
@ -65,7 +65,7 @@ class ImageStyleTest extends UnitTestCase {
$image_style->expects($this->any()) $image_style->expects($this->any())
->method('getImageEffectPluginManager') ->method('getImageEffectPluginManager')
->will($this->returnValue($effectManager)); ->willReturn($effectManager);
$image_style->expects($this->any()) $image_style->expects($this->any())
->method('fileDefaultScheme') ->method('fileDefaultScheme')
->willReturnCallback([$this, 'fileDefaultScheme']); ->willReturnCallback([$this, 'fileDefaultScheme']);
@ -82,12 +82,12 @@ class ImageStyleTest extends UnitTestCase {
$this->entityType = $this->createMock('\Drupal\Core\Entity\EntityTypeInterface'); $this->entityType = $this->createMock('\Drupal\Core\Entity\EntityTypeInterface');
$this->entityType->expects($this->any()) $this->entityType->expects($this->any())
->method('getProvider') ->method('getProvider')
->will($this->returnValue($provider)); ->willReturn($provider);
$this->entityTypeManager = $this->createMock('\Drupal\Core\Entity\EntityTypeManagerInterface'); $this->entityTypeManager = $this->createMock('\Drupal\Core\Entity\EntityTypeManagerInterface');
$this->entityTypeManager->expects($this->any()) $this->entityTypeManager->expects($this->any())
->method('getDefinition') ->method('getDefinition')
->with($this->entityTypeId) ->with($this->entityTypeId)
->will($this->returnValue($this->entityType)); ->willReturn($this->entityType);
} }
/** /**
@ -101,7 +101,7 @@ class ImageStyleTest extends UnitTestCase {
->getMock(); ->getMock();
$image_effect->expects($this->any()) $image_effect->expects($this->any())
->method('getDerivativeExtension') ->method('getDerivativeExtension')
->will($this->returnValue('png')); ->willReturn('png');
$image_style = $this->getImageStyleMock($image_effect_id, $image_effect); $image_style = $this->getImageStyleMock($image_effect_id, $image_effect);
@ -124,7 +124,7 @@ class ImageStyleTest extends UnitTestCase {
->getMock(); ->getMock();
$image_effect->expects($this->any()) $image_effect->expects($this->any())
->method('getDerivativeExtension') ->method('getDerivativeExtension')
->will($this->returnValue('png')); ->willReturn('png');
$image_style = $this->getImageStyleMock($image_effect_id, $image_effect); $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'); $this->assertEquals($image_style->buildUri('public://test.jpeg'), 'public://styles/' . $image_style->id() . '/public/test.jpeg.png');
@ -157,15 +157,15 @@ class ImageStyleTest extends UnitTestCase {
->getMock(); ->getMock();
$image_effect->expects($this->any()) $image_effect->expects($this->any())
->method('getDerivativeExtension') ->method('getDerivativeExtension')
->will($this->returnValue('png')); ->willReturn('png');
$image_style = $this->getImageStyleMock($image_effect_id, $image_effect, ['getPrivateKey', 'getHashSalt']); $image_style = $this->getImageStyleMock($image_effect_id, $image_effect, ['getPrivateKey', 'getHashSalt']);
$image_style->expects($this->any()) $image_style->expects($this->any())
->method('getPrivateKey') ->method('getPrivateKey')
->will($this->returnValue($private_key)); ->willReturn($private_key);
$image_style->expects($this->any()) $image_style->expects($this->any())
->method('getHashSalt') ->method('getHashSalt')
->will($this->returnValue($hash_salt)); ->willReturn($hash_salt);
// Assert the extension has been added to the URI before creating the token. // 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')); $this->assertEquals($image_style->getPathToken('public://test.jpeg.png'), $image_style->getPathToken('public://test.jpeg'));
@ -184,10 +184,10 @@ class ImageStyleTest extends UnitTestCase {
$image_style = $this->getImageStyleMock($image_effect_id, $image_effect, ['getPrivateKey', 'getHashSalt']); $image_style = $this->getImageStyleMock($image_effect_id, $image_effect, ['getPrivateKey', 'getHashSalt']);
$image_style->expects($this->any()) $image_style->expects($this->any())
->method('getPrivateKey') ->method('getPrivateKey')
->will($this->returnValue($private_key)); ->willReturn($private_key);
$image_style->expects($this->any()) $image_style->expects($this->any())
->method('getHashSalt') ->method('getHashSalt')
->will($this->returnValue($hash_salt)); ->willReturn($hash_salt);
// Assert no extension has been added to the uri before creating the token. // 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($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')); $this->assertNotEquals(substr(Crypt::hmacBase64($image_style->id() . ':' . 'public://test.jpeg.png', $private_key . $hash_salt), 0, 8), $image_style->getPathToken('public://test.jpeg'));

View File

@ -61,7 +61,7 @@ class DenyPrivateImageStyleDownloadTest extends UnitTestCase {
public function testPrivateImageStyleDownloadPolicy($expected_result, $route_name) { public function testPrivateImageStyleDownloadPolicy($expected_result, $route_name) {
$this->routeMatch->expects($this->once()) $this->routeMatch->expects($this->once())
->method('getRouteName') ->method('getRouteName')
->will($this->returnValue($route_name)); ->willReturn($route_name);
$actual_result = $this->policy->check($this->response, $this->request); $actual_result = $this->policy->check($this->response, $this->request);
$this->assertSame($expected_result, $actual_result); $this->assertSame($expected_result, $actual_result);

View File

@ -88,12 +88,12 @@ class ContentLanguageSettingsUnitTest extends UnitTestCase {
$target_entity_type = $this->createMock('\Drupal\Core\Entity\EntityTypeInterface'); $target_entity_type = $this->createMock('\Drupal\Core\Entity\EntityTypeInterface');
$target_entity_type->expects($this->any()) $target_entity_type->expects($this->any())
->method('getBundleConfigDependency') ->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()) $this->entityTypeManager->expects($this->any())
->method('getDefinition') ->method('getDefinition')
->with('test_entity_type') ->with('test_entity_type')
->will($this->returnValue($target_entity_type)); ->willReturn($target_entity_type);
$config = new ContentLanguageSettings([ $config = new ContentLanguageSettings([
'target_entity_type_id' => 'test_entity_type', 'target_entity_type_id' => 'test_entity_type',
@ -250,17 +250,17 @@ class ContentLanguageSettingsUnitTest extends UnitTestCase {
->expects($this->any()) ->expects($this->any())
->method('load') ->method('load')
->with($config_id) ->with($config_id)
->will($this->returnValue($existing_config)); ->willReturn($existing_config);
$this->configEntityStorageInterface $this->configEntityStorageInterface
->expects($this->any()) ->expects($this->any())
->method('create') ->method('create')
->will($this->returnValue($nullConfig)); ->willReturn($nullConfig);
$this->entityTypeManager $this->entityTypeManager
->expects($this->any()) ->expects($this->any())
->method('getStorage') ->method('getStorage')
->with('language_content_settings') ->with('language_content_settings')
->will($this->returnValue($this->configEntityStorageInterface)); ->willReturn($this->configEntityStorageInterface);
$entity_type_repository = $this->getMockForAbstractClass(EntityTypeRepositoryInterface::class); $entity_type_repository = $this->getMockForAbstractClass(EntityTypeRepositoryInterface::class);
$entity_type_repository->expects($this->any()) $entity_type_repository->expects($this->any())

View File

@ -29,11 +29,11 @@ class LanguageNegotiationUrlTest extends UnitTestCase {
$language_de = $this->createMock('\Drupal\Core\Language\LanguageInterface'); $language_de = $this->createMock('\Drupal\Core\Language\LanguageInterface');
$language_de->expects($this->any()) $language_de->expects($this->any())
->method('getId') ->method('getId')
->will($this->returnValue('de')); ->willReturn('de');
$language_en = $this->createMock('\Drupal\Core\Language\LanguageInterface'); $language_en = $this->createMock('\Drupal\Core\Language\LanguageInterface');
$language_en->expects($this->any()) $language_en->expects($this->any())
->method('getId') ->method('getId')
->will($this->returnValue('en')); ->willReturn('en');
$languages = [ $languages = [
'de' => $language_de, 'de' => $language_de,
'en' => $language_en, 'en' => $language_en,
@ -45,7 +45,7 @@ class LanguageNegotiationUrlTest extends UnitTestCase {
->getMock(); ->getMock();
$language_manager->expects($this->any()) $language_manager->expects($this->any())
->method('getLanguages') ->method('getLanguages')
->will($this->returnValue($languages)); ->willReturn($languages);
$this->languageManager = $language_manager; $this->languageManager = $language_manager;
// Create a user stub. // Create a user stub.
@ -69,7 +69,10 @@ class LanguageNegotiationUrlTest extends UnitTestCase {
public function testPathPrefix($prefix, $prefixes, $expected_langcode) { public function testPathPrefix($prefix, $prefixes, $expected_langcode) {
$this->languageManager->expects($this->any()) $this->languageManager->expects($this->any())
->method('getCurrentLanguage') ->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([ $config = $this->getConfigFactoryStub([
'language.negotiation' => [ 'language.negotiation' => [
@ -158,7 +161,7 @@ class LanguageNegotiationUrlTest extends UnitTestCase {
public function testDomain($http_host, $domains, $expected_langcode) { public function testDomain($http_host, $domains, $expected_langcode) {
$this->languageManager->expects($this->any()) $this->languageManager->expects($this->any())
->method('getCurrentLanguage') ->method('getCurrentLanguage')
->will($this->returnValue($this->languages['en'])); ->willReturn($this->languages['en']);
$config = $this->getConfigFactoryStub([ $config = $this->getConfigFactoryStub([
'language.negotiation' => [ 'language.negotiation' => [

View File

@ -32,7 +32,7 @@ class LanguageDomainsTest extends MigrateProcessTestCase {
// to return TRUE to be able to test the process. // to return TRUE to be able to test the process.
$this->row->expects($this->once()) $this->row->expects($this->once())
->method('getSourceProperty') ->method('getSourceProperty')
->will($this->returnValue(TRUE)); ->willReturn(TRUE);
// The language_domains plugin use $base_url to fill empty domains. // The language_domains plugin use $base_url to fill empty domains.
global $base_url; global $base_url;

View File

@ -77,7 +77,7 @@ class LocaleLookupTest extends UnitTestCase {
$this->user = $this->createMock('Drupal\Core\Session\AccountInterface'); $this->user = $this->createMock('Drupal\Core\Session\AccountInterface');
$this->user->expects($this->any()) $this->user->expects($this->any())
->method('getRoles') ->method('getRoles')
->will($this->returnValue(['anonymous'])); ->willReturn(['anonymous']);
$this->configFactory = $this->getConfigFactoryStub(['locale.settings' => ['cache_strings' => FALSE]]); $this->configFactory = $this->getConfigFactoryStub(['locale.settings' => ['cache_strings' => FALSE]]);
@ -112,7 +112,7 @@ class LocaleLookupTest extends UnitTestCase {
$this->storage->expects($this->once()) $this->storage->expects($this->once())
->method('findTranslation') ->method('findTranslation')
->with($this->equalTo($args)) ->with($this->equalTo($args))
->will($this->returnValue($result)); ->willReturn($result);
$locale_lookup = $this->getMockBuilder('Drupal\locale\LocaleLookup') $locale_lookup = $this->getMockBuilder('Drupal\locale\LocaleLookup')
->setConstructorArgs(['en', 'irrelevant', $this->storage, $this->cache, $this->lock, $this->configFactory, $this->languageManager, $this->requestStack]) ->setConstructorArgs(['en', 'irrelevant', $this->storage, $this->cache, $this->lock, $this->configFactory, $this->languageManager, $this->requestStack])
@ -229,7 +229,7 @@ class LocaleLookupTest extends UnitTestCase {
$this->storage->expects($this->once()) $this->storage->expects($this->once())
->method('findTranslation') ->method('findTranslation')
->with($this->equalTo($args)) ->with($this->equalTo($args))
->will($this->returnValue($result)); ->willReturn($result);
$this->configFactory = $this->getConfigFactoryStub(['locale.settings' => ['cache_strings' => TRUE]]); $this->configFactory = $this->getConfigFactoryStub(['locale.settings' => ['cache_strings' => TRUE]]);
$locale_lookup = $this->getMockBuilder('Drupal\locale\LocaleLookup') $locale_lookup = $this->getMockBuilder('Drupal\locale\LocaleLookup')
@ -254,10 +254,10 @@ class LocaleLookupTest extends UnitTestCase {
->will($this->returnSelf()); ->will($this->returnSelf());
$this->storage->expects($this->once()) $this->storage->expects($this->once())
->method('findTranslation') ->method('findTranslation')
->will($this->returnValue(NULL)); ->willReturn(NULL);
$this->storage->expects($this->once()) $this->storage->expects($this->once())
->method('createString') ->method('createString')
->will($this->returnValue($string)); ->willReturn($string);
$request = Request::create('/test'); $request = Request::create('/test');
$this->requestStack->push($request); $this->requestStack->push($request);
@ -349,7 +349,7 @@ class LocaleLookupTest extends UnitTestCase {
$this->user = $this->createMock('Drupal\Core\Session\AccountInterface'); $this->user = $this->createMock('Drupal\Core\Session\AccountInterface');
$this->user->expects($this->any()) $this->user->expects($this->any())
->method('getRoles') ->method('getRoles')
->will($this->returnValue($roles)); ->willReturn($roles);
$container = new ContainerBuilder(); $container = new ContainerBuilder();
$container->set('current_user', $this->user); $container->set('current_user', $this->user);

View File

@ -36,7 +36,7 @@ class MenuLinkContentEntityAccessTest extends UnitTestCase {
$language = $this->createMock(LanguageInterface::class); $language = $this->createMock(LanguageInterface::class);
$language->expects($this->any()) $language->expects($this->any())
->method('getId') ->method('getId')
->will($this->returnValue('de')); ->willReturn('de');
$entity = $this->createMock(ContentEntityInterface::class); $entity = $this->createMock(ContentEntityInterface::class);
$entity->expects($this->any()) $entity->expects($this->any())

View File

@ -89,7 +89,7 @@ class MigrateExecutableTest extends MigrateTestCase {
$this->migration->expects($this->any()) $this->migration->expects($this->any())
->method('getSourcePlugin') ->method('getSourcePlugin')
->will($this->returnValue($source)); ->willReturn($source);
// Ensure that a message with the proper message was added. // Ensure that a message with the proper message was added.
$exception_message .= " in " . __FILE__ . " line $line"; $exception_message .= " in " . __FILE__ . " line $line";
@ -115,7 +115,7 @@ class MigrateExecutableTest extends MigrateTestCase {
$this->migration->expects($this->once()) $this->migration->expects($this->once())
->method('getProcessPlugins') ->method('getProcessPlugins')
->will($this->returnValue([])); ->willReturn([]);
$destination = $this->createMock('Drupal\migrate\Plugin\MigrateDestinationInterface'); $destination = $this->createMock('Drupal\migrate\Plugin\MigrateDestinationInterface');
@ -140,7 +140,7 @@ class MigrateExecutableTest extends MigrateTestCase {
$this->migration->expects($this->once()) $this->migration->expects($this->once())
->method('getProcessPlugins') ->method('getProcessPlugins')
->will($this->returnValue([])); ->willReturn([]);
$destination = $this->createMock('Drupal\migrate\Plugin\MigrateDestinationInterface'); $destination = $this->createMock('Drupal\migrate\Plugin\MigrateDestinationInterface');
@ -168,7 +168,7 @@ class MigrateExecutableTest extends MigrateTestCase {
$this->migration->expects($this->once()) $this->migration->expects($this->once())
->method('getProcessPlugins') ->method('getProcessPlugins')
->will($this->returnValue([])); ->willReturn([]);
$destination = $this->createMock('Drupal\migrate\Plugin\MigrateDestinationInterface'); $destination = $this->createMock('Drupal\migrate\Plugin\MigrateDestinationInterface');
@ -196,7 +196,7 @@ class MigrateExecutableTest extends MigrateTestCase {
$this->migration->expects($this->once()) $this->migration->expects($this->once())
->method('getProcessPlugins') ->method('getProcessPlugins')
->will($this->returnValue([])); ->willReturn([]);
$destination = $this->createMock('Drupal\migrate\Plugin\MigrateDestinationInterface'); $destination = $this->createMock('Drupal\migrate\Plugin\MigrateDestinationInterface');
@ -270,7 +270,7 @@ class MigrateExecutableTest extends MigrateTestCase {
$this->migration->expects($this->once()) $this->migration->expects($this->once())
->method('getProcessPlugins') ->method('getProcessPlugins')
->will($this->returnValue([])); ->willReturn([]);
$destination = $this->createMock('Drupal\migrate\Plugin\MigrateDestinationInterface'); $destination = $this->createMock('Drupal\migrate\Plugin\MigrateDestinationInterface');
@ -293,15 +293,15 @@ class MigrateExecutableTest extends MigrateTestCase {
$plugins[$key][0] = $this->createMock('Drupal\migrate\Plugin\MigrateProcessInterface'); $plugins[$key][0] = $this->createMock('Drupal\migrate\Plugin\MigrateProcessInterface');
$plugins[$key][0]->expects($this->once()) $plugins[$key][0]->expects($this->once())
->method('getPluginDefinition') ->method('getPluginDefinition')
->will($this->returnValue([])); ->willReturn([]);
$plugins[$key][0]->expects($this->once()) $plugins[$key][0]->expects($this->once())
->method('transform') ->method('transform')
->will($this->returnValue($value)); ->willReturn($value);
} }
$this->migration->expects($this->once()) $this->migration->expects($this->once())
->method('getProcessPlugins') ->method('getProcessPlugins')
->with(NULL) ->with(NULL)
->will($this->returnValue($plugins)); ->willReturn($plugins);
$row = new Row(); $row = new Row();
$this->executable->processRow($row); $this->executable->processRow($row);
foreach ($expected as $key => $value) { foreach ($expected as $key => $value) {
@ -317,7 +317,7 @@ class MigrateExecutableTest extends MigrateTestCase {
$this->migration->expects($this->once()) $this->migration->expects($this->once())
->method('getProcessPlugins') ->method('getProcessPlugins')
->with(NULL) ->with(NULL)
->will($this->returnValue(['test' => []])); ->willReturn(['test' => []]);
$row = new Row(); $row = new Row();
$this->executable->processRow($row); $this->executable->processRow($row);
$this->assertSame($row->getDestination(), []); $this->assertSame($row->getDestination(), []);
@ -386,10 +386,10 @@ class MigrateExecutableTest extends MigrateTestCase {
->getMockForAbstractClass(); ->getMockForAbstractClass();
$source->expects($this->once()) $source->expects($this->once())
->method('rewind') ->method('rewind')
->will($this->returnValue(TRUE)); ->willReturn(TRUE);
$source->expects($this->any()) $source->expects($this->any())
->method('initializeIterator') ->method('initializeIterator')
->will($this->returnValue([])); ->willReturn([]);
$source->expects($this->any()) $source->expects($this->any())
->method('valid') ->method('valid')
->will($this->onConsecutiveCalls(TRUE, FALSE)); ->will($this->onConsecutiveCalls(TRUE, FALSE));

View File

@ -29,7 +29,7 @@ class ConfigTest extends UnitTestCase {
$config->expects($this->once()) $config->expects($this->once())
->method('set') ->method('set')
->with($this->equalTo($key), $this->equalTo($val)) ->with($this->equalTo($key), $this->equalTo($val))
->will($this->returnValue($config)); ->willReturn($config);
} }
$config->expects($this->once()) $config->expects($this->once())
->method('save'); ->method('save');
@ -40,20 +40,20 @@ class ConfigTest extends UnitTestCase {
$config_factory->expects($this->once()) $config_factory->expects($this->once())
->method('getEditable') ->method('getEditable')
->with('d8_config') ->with('d8_config')
->will($this->returnValue($config)); ->willReturn($config);
$row = $this->getMockBuilder('Drupal\migrate\Row') $row = $this->getMockBuilder('Drupal\migrate\Row')
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
$row->expects($this->any()) $row->expects($this->any())
->method('getRawDestination') ->method('getRawDestination')
->will($this->returnValue($source)); ->willReturn($source);
$language_manager = $this->getMockBuilder('Drupal\language\ConfigurableLanguageManagerInterface') $language_manager = $this->getMockBuilder('Drupal\language\ConfigurableLanguageManagerInterface')
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
$language_manager->expects($this->never()) $language_manager->expects($this->never())
->method('getLanguageConfigOverride') ->method('getLanguageConfigOverride')
->with('fr', 'd8_config') ->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 = new Config(['config_name' => 'd8_config'], 'd8_config', ['pluginId' => 'd8_config'], $migration, $config_factory, $language_manager);
$destination_id = $destination->import($row); $destination_id = $destination->import($row);
$this->assertEquals(['d8_config'], $destination_id); $this->assertEquals(['d8_config'], $destination_id);
@ -76,7 +76,7 @@ class ConfigTest extends UnitTestCase {
$config->expects($this->once()) $config->expects($this->once())
->method('set') ->method('set')
->with($this->equalTo($key), $this->equalTo($val)) ->with($this->equalTo($key), $this->equalTo($val))
->will($this->returnValue($config)); ->willReturn($config);
} }
$config->expects($this->once()) $config->expects($this->once())
->method('save'); ->method('save');
@ -87,23 +87,23 @@ class ConfigTest extends UnitTestCase {
$config_factory->expects($this->once()) $config_factory->expects($this->once())
->method('getEditable') ->method('getEditable')
->with('d8_config') ->with('d8_config')
->will($this->returnValue($config)); ->willReturn($config);
$row = $this->getMockBuilder('Drupal\migrate\Row') $row = $this->getMockBuilder('Drupal\migrate\Row')
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
$row->expects($this->any()) $row->expects($this->any())
->method('getRawDestination') ->method('getRawDestination')
->will($this->returnValue($source)); ->willReturn($source);
$row->expects($this->any()) $row->expects($this->any())
->method('getDestinationProperty') ->method('getDestinationProperty')
->will($this->returnValue($source['langcode'])); ->willReturn($source['langcode']);
$language_manager = $this->getMockBuilder('Drupal\language\ConfigurableLanguageManagerInterface') $language_manager = $this->getMockBuilder('Drupal\language\ConfigurableLanguageManagerInterface')
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
$language_manager->expects($this->any()) $language_manager->expects($this->any())
->method('getLanguageConfigOverride') ->method('getLanguageConfigOverride')
->with('mi', 'd8_config') ->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 = new Config(['config_name' => 'd8_config', 'translations' => 'true'], 'd8_config', ['pluginId' => 'd8_config'], $migration, $config_factory, $language_manager);
$destination_id = $destination->import($row); $destination_id = $destination->import($row);
$this->assertEquals(['d8_config', 'mi'], $destination_id); $this->assertEquals(['d8_config', 'mi'], $destination_id);

View File

@ -18,7 +18,7 @@ class GetTest extends MigrateProcessTestCase {
$this->row->expects($this->once()) $this->row->expects($this->once())
->method('get') ->method('get')
->with('test') ->with('test')
->will($this->returnValue('source_value')); ->willReturn('source_value');
$this->plugin = new Get(['source' => 'test'], '', []); $this->plugin = new Get(['source' => 'test'], '', []);
$value = $this->plugin->transform(NULL, $this->migrateExecutable, $this->row, 'destination_property'); $value = $this->plugin->transform(NULL, $this->migrateExecutable, $this->row, 'destination_property');
$this->assertSame('source_value', $value); $this->assertSame('source_value', $value);
@ -49,7 +49,7 @@ class GetTest extends MigrateProcessTestCase {
$this->row->expects($this->once()) $this->row->expects($this->once())
->method('get') ->method('get')
->with('@@test') ->with('@@test')
->will($this->returnValue('source_value')); ->willReturn('source_value');
$this->plugin = new Get(['source' => '@@test'], '', []); $this->plugin = new Get(['source' => '@@test'], '', []);
$value = $this->plugin->transform(NULL, $this->migrateExecutable, $this->row, 'destination_property'); $value = $this->plugin->transform(NULL, $this->migrateExecutable, $this->row, 'destination_property');
$this->assertSame('source_value', $value); $this->assertSame('source_value', $value);

View File

@ -162,10 +162,10 @@ class MakeUniqueEntityFieldTest extends MigrateProcessTestCase {
protected function entityQueryExpects($count) { protected function entityQueryExpects($count) {
$this->entityQuery->expects($this->exactly($count + 1)) $this->entityQuery->expects($this->exactly($count + 1))
->method('condition') ->method('condition')
->will($this->returnValue($this->entityQuery)); ->willReturn($this->entityQuery);
$this->entityQuery->expects($this->exactly($count + 1)) $this->entityQuery->expects($this->exactly($count + 1))
->method('count') ->method('count')
->will($this->returnValue($this->entityQuery)); ->willReturn($this->entityQuery);
$this->entityQuery->expects($this->exactly($count + 1)) $this->entityQuery->expects($this->exactly($count + 1))
->method('execute') ->method('execute')
->willReturnCallback(function () use (&$count) { ->willReturnCallback(function () use (&$count) {

View File

@ -71,7 +71,7 @@ class NodeOperationAccessTest extends UnitTestCase {
$language = $this->createMock(LanguageInterface::class); $language = $this->createMock(LanguageInterface::class);
$language->expects($this->any()) $language->expects($this->any())
->method('getId') ->method('getId')
->will($this->returnValue('de')); ->willReturn('de');
$nid = 333; $nid = 333;
/** @var \Drupal\node\NodeInterface|\PHPUnit\Framework\MockObject\MockObject $node */ /** @var \Drupal\node\NodeInterface|\PHPUnit\Framework\MockObject\MockObject $node */

View File

@ -61,7 +61,7 @@ class DenyNodePreviewTest extends UnitTestCase {
public function testPrivateImageStyleDownloadPolicy($expected_result, $route_name) { public function testPrivateImageStyleDownloadPolicy($expected_result, $route_name) {
$this->routeMatch->expects($this->once()) $this->routeMatch->expects($this->once())
->method('getRouteName') ->method('getRouteName')
->will($this->returnValue($route_name)); ->willReturn($route_name);
$actual_result = $this->policy->check($this->response, $this->request); $actual_result = $this->policy->check($this->response, $this->request);
$this->assertSame($expected_result, $actual_result); $this->assertSame($expected_result, $actual_result);

View File

@ -33,26 +33,26 @@ class NodeBulkFormTest extends UnitTestCase {
$action = $this->createMock('\Drupal\system\ActionConfigEntityInterface'); $action = $this->createMock('\Drupal\system\ActionConfigEntityInterface');
$action->expects($this->any()) $action->expects($this->any())
->method('getType') ->method('getType')
->will($this->returnValue('node')); ->willReturn('node');
$actions[$i] = $action; $actions[$i] = $action;
} }
$action = $this->createMock('\Drupal\system\ActionConfigEntityInterface'); $action = $this->createMock('\Drupal\system\ActionConfigEntityInterface');
$action->expects($this->any()) $action->expects($this->any())
->method('getType') ->method('getType')
->will($this->returnValue('user')); ->willReturn('user');
$actions[] = $action; $actions[] = $action;
$entity_storage = $this->createMock('Drupal\Core\Entity\EntityStorageInterface'); $entity_storage = $this->createMock('Drupal\Core\Entity\EntityStorageInterface');
$entity_storage->expects($this->any()) $entity_storage->expects($this->any())
->method('loadMultiple') ->method('loadMultiple')
->will($this->returnValue($actions)); ->willReturn($actions);
$entity_type_manager = $this->createMock(EntityTypeManagerInterface::class); $entity_type_manager = $this->createMock(EntityTypeManagerInterface::class);
$entity_type_manager->expects($this->once()) $entity_type_manager->expects($this->once())
->method('getStorage') ->method('getStorage')
->with('action') ->with('action')
->will($this->returnValue($entity_storage)); ->willReturn($entity_storage);
$entity_repository = $this->createMock(EntityRepositoryInterface::class); $entity_repository = $this->createMock(EntityRepositoryInterface::class);
@ -66,7 +66,7 @@ class NodeBulkFormTest extends UnitTestCase {
$views_data->expects($this->any()) $views_data->expects($this->any())
->method('get') ->method('get')
->with('node') ->with('node')
->will($this->returnValue(['table' => ['entity type' => 'node']])); ->willReturn(['table' => ['entity type' => 'node']]);
$container = new ContainerBuilder(); $container = new ContainerBuilder();
$container->set('views.views_data', $views_data); $container->set('views.views_data', $views_data);
$container->set('string_translation', $this->getStringTranslationStub()); $container->set('string_translation', $this->getStringTranslationStub());
@ -76,7 +76,7 @@ class NodeBulkFormTest extends UnitTestCase {
$storage->expects($this->any()) $storage->expects($this->any())
->method('get') ->method('get')
->with('base_table') ->with('base_table')
->will($this->returnValue('node')); ->willReturn('node');
$executable = $this->getMockBuilder('Drupal\views\ViewExecutable') $executable = $this->getMockBuilder('Drupal\views\ViewExecutable')
->disableOriginalConstructor() ->disableOriginalConstructor()

View File

@ -91,12 +91,12 @@ class AliasManagerTest extends UnitTestCase {
$this->languageManager->expects($this->any()) $this->languageManager->expects($this->any())
->method('getCurrentLanguage') ->method('getCurrentLanguage')
->with(LanguageInterface::TYPE_URL) ->with(LanguageInterface::TYPE_URL)
->will($this->returnValue($language)); ->willReturn($language);
$this->aliasRepository->expects($this->once()) $this->aliasRepository->expects($this->once())
->method('lookupByAlias') ->method('lookupByAlias')
->with($alias, $language->getId()) ->with($alias, $language->getId())
->will($this->returnValue(NULL)); ->willReturn(NULL);
$this->assertEquals($alias, $this->aliasManager->getPathByAlias($alias)); $this->assertEquals($alias, $this->aliasManager->getPathByAlias($alias));
// Call it twice to test the static cache. // Call it twice to test the static cache.
@ -117,7 +117,7 @@ class AliasManagerTest extends UnitTestCase {
$this->aliasRepository->expects($this->once()) $this->aliasRepository->expects($this->once())
->method('lookupByAlias') ->method('lookupByAlias')
->with($alias, $language->getId()) ->with($alias, $language->getId())
->will($this->returnValue(['path' => $path])); ->willReturn(['path' => $path]);
$this->assertEquals($path, $this->aliasManager->getPathByAlias($alias)); $this->assertEquals($path, $this->aliasManager->getPathByAlias($alias));
// Call it twice to test the static cache. // Call it twice to test the static cache.
@ -139,7 +139,7 @@ class AliasManagerTest extends UnitTestCase {
$this->aliasRepository->expects($this->once()) $this->aliasRepository->expects($this->once())
->method('lookupByAlias') ->method('lookupByAlias')
->with($alias, 'de') ->with($alias, 'de')
->will($this->returnValue(['path' => $path])); ->willReturn(['path' => $path]);
$this->assertEquals($path, $this->aliasManager->getPathByAlias($alias, 'de')); $this->assertEquals($path, $this->aliasManager->getPathByAlias($alias, 'de'));
// Call it twice to test the static cache. // Call it twice to test the static cache.
@ -161,7 +161,7 @@ class AliasManagerTest extends UnitTestCase {
$this->aliasWhitelist->expects($this->any()) $this->aliasWhitelist->expects($this->any())
->method('get') ->method('get')
->with($path_part1) ->with($path_part1)
->will($this->returnValue(FALSE)); ->willReturn(FALSE);
// The whitelist returns FALSE for that path part, so the storage should // The whitelist returns FALSE for that path part, so the storage should
// never be called. // never be called.
@ -188,12 +188,12 @@ class AliasManagerTest extends UnitTestCase {
$this->aliasWhitelist->expects($this->any()) $this->aliasWhitelist->expects($this->any())
->method('get') ->method('get')
->with($path_part1) ->with($path_part1)
->will($this->returnValue(TRUE)); ->willReturn(TRUE);
$this->aliasRepository->expects($this->once()) $this->aliasRepository->expects($this->once())
->method('lookupBySystemPath') ->method('lookupBySystemPath')
->with($path, $language->getId()) ->with($path, $language->getId())
->will($this->returnValue(NULL)); ->willReturn(NULL);
$this->assertEquals($path, $this->aliasManager->getAliasByPath($path)); $this->assertEquals($path, $this->aliasManager->getAliasByPath($path));
// Call it twice to test the static cache. // Call it twice to test the static cache.
@ -226,12 +226,12 @@ class AliasManagerTest extends UnitTestCase {
$this->aliasWhitelist->expects($this->any()) $this->aliasWhitelist->expects($this->any())
->method('get') ->method('get')
->with($path_part1) ->with($path_part1)
->will($this->returnValue(TRUE)); ->willReturn(TRUE);
$this->aliasRepository->expects($this->once()) $this->aliasRepository->expects($this->once())
->method('lookupBySystemPath') ->method('lookupBySystemPath')
->with($path, $language->getId()) ->with($path, $language->getId())
->will($this->returnValue(['alias' => $alias])); ->willReturn(['alias' => $alias]);
$this->assertEquals($alias, $this->aliasManager->getAliasByPath($path)); $this->assertEquals($alias, $this->aliasManager->getAliasByPath($path));
// Call it twice to test the static cache. // Call it twice to test the static cache.
@ -263,7 +263,7 @@ class AliasManagerTest extends UnitTestCase {
$this->cache->expects($this->once()) $this->cache->expects($this->once())
->method('get') ->method('get')
->with($this->cacheKey) ->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. // Simulate a request so that the preloaded paths are fetched.
$this->aliasManager->setCacheKey($this->path); $this->aliasManager->setCacheKey($this->path);
@ -271,12 +271,12 @@ class AliasManagerTest extends UnitTestCase {
$this->aliasWhitelist->expects($this->any()) $this->aliasWhitelist->expects($this->any())
->method('get') ->method('get')
->with($path_part1) ->with($path_part1)
->will($this->returnValue(TRUE)); ->willReturn(TRUE);
$this->aliasRepository->expects($this->once()) $this->aliasRepository->expects($this->once())
->method('preloadPathAlias') ->method('preloadPathAlias')
->with($cached_paths[$language->getId()], $language->getId()) ->with($cached_paths[$language->getId()], $language->getId())
->will($this->returnValue([$path => $alias])); ->willReturn([$path => $alias]);
// LookupPathAlias should not be called. // LookupPathAlias should not be called.
$this->aliasRepository->expects($this->never()) $this->aliasRepository->expects($this->never())
@ -311,7 +311,7 @@ class AliasManagerTest extends UnitTestCase {
$this->cache->expects($this->once()) $this->cache->expects($this->once())
->method('get') ->method('get')
->with($this->cacheKey) ->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. // Simulate a request so that the preloaded paths are fetched.
$this->aliasManager->setCacheKey($this->path); $this->aliasManager->setCacheKey($this->path);
@ -319,7 +319,7 @@ class AliasManagerTest extends UnitTestCase {
$this->aliasWhitelist->expects($this->any()) $this->aliasWhitelist->expects($this->any())
->method('get') ->method('get')
->with($path_part1) ->with($path_part1)
->will($this->returnValue(TRUE)); ->willReturn(TRUE);
// The requested language is different than the cached, so this will // The requested language is different than the cached, so this will
// need to load. // need to load.
@ -328,7 +328,7 @@ class AliasManagerTest extends UnitTestCase {
$this->aliasRepository->expects($this->once()) $this->aliasRepository->expects($this->once())
->method('lookupBySystemPath') ->method('lookupBySystemPath')
->with($path, $language->getId()) ->with($path, $language->getId())
->will($this->returnValue(['alias' => $alias])); ->willReturn(['alias' => $alias]);
$this->assertEquals($alias, $this->aliasManager->getAliasByPath($path)); $this->assertEquals($alias, $this->aliasManager->getAliasByPath($path));
// Call it twice to test the static cache. // Call it twice to test the static cache.
@ -360,7 +360,7 @@ class AliasManagerTest extends UnitTestCase {
$this->cache->expects($this->once()) $this->cache->expects($this->once())
->method('get') ->method('get')
->with($this->cacheKey) ->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. // Simulate a request so that the preloaded paths are fetched.
$this->aliasManager->setCacheKey($this->path); $this->aliasManager->setCacheKey($this->path);
@ -368,12 +368,12 @@ class AliasManagerTest extends UnitTestCase {
$this->aliasWhitelist->expects($this->any()) $this->aliasWhitelist->expects($this->any())
->method('get') ->method('get')
->with($path_part1) ->with($path_part1)
->will($this->returnValue(TRUE)); ->willReturn(TRUE);
$this->aliasRepository->expects($this->once()) $this->aliasRepository->expects($this->once())
->method('preloadPathAlias') ->method('preloadPathAlias')
->with($cached_paths[$language->getId()], $language->getId()) ->with($cached_paths[$language->getId()], $language->getId())
->will($this->returnValue([$cached_path => $cached_alias])); ->willReturn([$cached_path => $cached_alias]);
// LookupPathAlias() should not be called. // LookupPathAlias() should not be called.
$this->aliasRepository->expects($this->never()) $this->aliasRepository->expects($this->never())
@ -408,7 +408,7 @@ class AliasManagerTest extends UnitTestCase {
$this->cache->expects($this->once()) $this->cache->expects($this->once())
->method('get') ->method('get')
->with($this->cacheKey) ->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. // Simulate a request so that the preloaded paths are fetched.
$this->aliasManager->setCacheKey($this->path); $this->aliasManager->setCacheKey($this->path);
@ -416,17 +416,17 @@ class AliasManagerTest extends UnitTestCase {
$this->aliasWhitelist->expects($this->any()) $this->aliasWhitelist->expects($this->any())
->method('get') ->method('get')
->with($path_part1) ->with($path_part1)
->will($this->returnValue(TRUE)); ->willReturn(TRUE);
$this->aliasRepository->expects($this->once()) $this->aliasRepository->expects($this->once())
->method('preloadPathAlias') ->method('preloadPathAlias')
->with($cached_paths[$language->getId()], $language->getId()) ->with($cached_paths[$language->getId()], $language->getId())
->will($this->returnValue([$cached_path => $cached_alias])); ->willReturn([$cached_path => $cached_alias]);
$this->aliasRepository->expects($this->once()) $this->aliasRepository->expects($this->once())
->method('lookupBySystemPath') ->method('lookupBySystemPath')
->with($path, $language->getId()) ->with($path, $language->getId())
->will($this->returnValue(NULL)); ->willReturn(NULL);
$this->assertEquals($path, $this->aliasManager->getAliasByPath($path)); $this->assertEquals($path, $this->aliasManager->getAliasByPath($path));
// Call it twice to test the static cache. // Call it twice to test the static cache.
@ -494,7 +494,7 @@ class AliasManagerTest extends UnitTestCase {
$this->cache->expects($this->once()) $this->cache->expects($this->once())
->method('get') ->method('get')
->with($this->cacheKey) ->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. // Simulate a request so that the preloaded paths are fetched.
$this->aliasManager->setCacheKey($this->path); $this->aliasManager->setCacheKey($this->path);
@ -502,17 +502,17 @@ class AliasManagerTest extends UnitTestCase {
$this->aliasWhitelist->expects($this->any()) $this->aliasWhitelist->expects($this->any())
->method('get') ->method('get')
->with($path_part1) ->with($path_part1)
->will($this->returnValue(TRUE)); ->willReturn(TRUE);
$this->aliasRepository->expects($this->once()) $this->aliasRepository->expects($this->once())
->method('preloadPathAlias') ->method('preloadPathAlias')
->with($cached_paths[$language->getId()], $language->getId()) ->with($cached_paths[$language->getId()], $language->getId())
->will($this->returnValue([$cached_path => $cached_alias])); ->willReturn([$cached_path => $cached_alias]);
$this->aliasRepository->expects($this->once()) $this->aliasRepository->expects($this->once())
->method('lookupBySystemPath') ->method('lookupBySystemPath')
->with($path, $language->getId()) ->with($path, $language->getId())
->will($this->returnValue(['alias' => $new_alias])); ->willReturn(['alias' => $new_alias]);
$this->assertEquals($new_alias, $this->aliasManager->getAliasByPath($path)); $this->assertEquals($new_alias, $this->aliasManager->getAliasByPath($path));
// Call it twice to test the static cache. // Call it twice to test the static cache.
@ -537,7 +537,7 @@ class AliasManagerTest extends UnitTestCase {
$this->languageManager->expects($this->any()) $this->languageManager->expects($this->any())
->method('getCurrentLanguage') ->method('getCurrentLanguage')
->with(LanguageInterface::TYPE_URL) ->with(LanguageInterface::TYPE_URL)
->will($this->returnValue($language)); ->willReturn($language);
return $language; return $language;
} }

View File

@ -83,11 +83,11 @@ class QuickEditEntityFieldAccessCheckTest extends UnitTestCase {
$entity_with_field->expects($this->any()) $entity_with_field->expects($this->any())
->method('get') ->method('get')
->with($field_name) ->with($field_name)
->will($this->returnValue($field_storage)); ->willReturn($field_storage);
$entity_with_field->expects($this->once()) $entity_with_field->expects($this->once())
->method('hasTranslation') ->method('hasTranslation')
->with(LanguageInterface::LANGCODE_NOT_SPECIFIED) ->with(LanguageInterface::LANGCODE_NOT_SPECIFIED)
->will($this->returnValue(TRUE)); ->willReturn(TRUE);
$account = $this->createMock('Drupal\Core\Session\AccountInterface'); $account = $this->createMock('Drupal\Core\Session\AccountInterface');
$access = $this->editAccessCheck->access($entity_with_field, $field_name, LanguageInterface::LANGCODE_NOT_SPECIFIED, $account); $access = $this->editAccessCheck->access($entity_with_field, $field_name, LanguageInterface::LANGCODE_NOT_SPECIFIED, $account);

View File

@ -51,7 +51,7 @@ class RdfMappingConfigEntityUnitTest extends UnitTestCase {
$this->entityType = $this->createMock('\Drupal\Core\Entity\EntityTypeInterface'); $this->entityType = $this->createMock('\Drupal\Core\Entity\EntityTypeInterface');
$this->entityType->expects($this->any()) $this->entityType->expects($this->any())
->method('getProvider') ->method('getProvider')
->will($this->returnValue('entity')); ->willReturn('entity');
$this->entityTypeManager = $this->createMock(EntityTypeManagerInterface::class); $this->entityTypeManager = $this->createMock(EntityTypeManagerInterface::class);
@ -73,14 +73,14 @@ class RdfMappingConfigEntityUnitTest extends UnitTestCase {
$target_entity_type = $this->createMock('\Drupal\Core\Entity\EntityTypeInterface'); $target_entity_type = $this->createMock('\Drupal\Core\Entity\EntityTypeInterface');
$target_entity_type->expects($this->any()) $target_entity_type->expects($this->any())
->method('getProvider') ->method('getProvider')
->will($this->returnValue('test_module')); ->willReturn('test_module');
$values = ['targetEntityType' => $target_entity_type_id]; $values = ['targetEntityType' => $target_entity_type_id];
$target_entity_type->expects($this->any()) $target_entity_type->expects($this->any())
->method('getBundleEntityType') ->method('getBundleEntityType')
->will($this->returnValue(NULL)); ->willReturn(NULL);
$target_entity_type->expects($this->any()) $target_entity_type->expects($this->any())
->method('getBundleConfigDependency') ->method('getBundleConfigDependency')
->will($this->returnValue(['type' => 'module', 'name' => 'test_module'])); ->willReturn(['type' => 'module', 'name' => 'test_module']);
$this->entityTypeManager->expects($this->any()) $this->entityTypeManager->expects($this->any())
->method('getDefinition') ->method('getDefinition')
@ -103,13 +103,16 @@ class RdfMappingConfigEntityUnitTest extends UnitTestCase {
$target_entity_type = $this->createMock('\Drupal\Core\Entity\EntityTypeInterface'); $target_entity_type = $this->createMock('\Drupal\Core\Entity\EntityTypeInterface');
$target_entity_type->expects($this->any()) $target_entity_type->expects($this->any())
->method('getProvider') ->method('getProvider')
->will($this->returnValue('test_module')); ->willReturn('test_module');
$bundle_id = $this->randomMachineName(10); $bundle_id = $this->randomMachineName(10);
$values = ['targetEntityType' => $target_entity_type_id , 'bundle' => $bundle_id]; $values = ['targetEntityType' => $target_entity_type_id , 'bundle' => $bundle_id];
$target_entity_type->expects($this->any()) $target_entity_type->expects($this->any())
->method('getBundleConfigDependency') ->method('getBundleConfigDependency')
->will($this->returnValue(['type' => 'config', 'name' => 'test_module.type.' . $bundle_id])); ->willReturn([
'type' => 'config',
'name' => 'test_module.type.' . $bundle_id,
]);
$this->entityTypeManager->expects($this->any()) $this->entityTypeManager->expects($this->any())
->method('getDefinition') ->method('getDefinition')

View File

@ -42,13 +42,13 @@ class ResponsiveImageStyleConfigEntityUnitTest extends UnitTestCase {
$this->entityType = $this->createMock('\Drupal\Core\Entity\EntityTypeInterface'); $this->entityType = $this->createMock('\Drupal\Core\Entity\EntityTypeInterface');
$this->entityType->expects($this->any()) $this->entityType->expects($this->any())
->method('getProvider') ->method('getProvider')
->will($this->returnValue('responsive_image')); ->willReturn('responsive_image');
$this->entityTypeManager = $this->createMock(EntityTypeManagerInterface::class); $this->entityTypeManager = $this->createMock(EntityTypeManagerInterface::class);
$this->entityTypeManager->expects($this->any()) $this->entityTypeManager->expects($this->any())
->method('getDefinition') ->method('getDefinition')
->with('responsive_image_style') ->with('responsive_image_style')
->will($this->returnValue($this->entityType)); ->willReturn($this->entityType);
$this->breakpointManager = $this->createMock('\Drupal\breakpoint\BreakpointManagerInterface'); $this->breakpointManager = $this->createMock('\Drupal\breakpoint\BreakpointManagerInterface');

View File

@ -85,7 +85,7 @@ class CollectRoutesTest extends UnitTestCase {
$container->set('authentication_collector', $authentication_collector); $container->set('authentication_collector', $authentication_collector);
$authentication_collector->expects($this->any()) $authentication_collector->expects($this->any())
->method('getSortedProviders') ->method('getSortedProviders')
->will($this->returnValue(['basic_auth' => 'data', 'cookie' => 'data'])); ->willReturn(['basic_auth' => 'data', 'cookie' => 'data']);
$container->setParameter('serializer.format_providers', ['json']); $container->setParameter('serializer.format_providers', ['json']);
@ -105,7 +105,7 @@ class CollectRoutesTest extends UnitTestCase {
$display_manager->expects($this->once()) $display_manager->expects($this->once())
->method('getDefinition') ->method('getDefinition')
->will($this->returnValue(['id' => 'test', 'provider' => 'test'])); ->willReturn(['id' => 'test', 'provider' => 'test']);
$none = $this->getMockBuilder('\Drupal\views\Plugin\views\access\None') $none = $this->getMockBuilder('\Drupal\views\Plugin\views\access\None')
->disableOriginalConstructor() ->disableOriginalConstructor()
@ -113,7 +113,7 @@ class CollectRoutesTest extends UnitTestCase {
$access_manager->expects($this->once()) $access_manager->expects($this->once())
->method('createInstance') ->method('createInstance')
->will($this->returnValue($none)); ->willReturn($none);
$style_plugin = $this->getMockBuilder('\Drupal\rest\Plugin\views\style\Serializer') $style_plugin = $this->getMockBuilder('\Drupal\rest\Plugin\views\style\Serializer')
->onlyMethods(['getFormats', 'init']) ->onlyMethods(['getFormats', 'init'])
@ -122,16 +122,16 @@ class CollectRoutesTest extends UnitTestCase {
$style_plugin->expects($this->once()) $style_plugin->expects($this->once())
->method('getFormats') ->method('getFormats')
->will($this->returnValue(['json'])); ->willReturn(['json']);
$style_plugin->expects($this->once()) $style_plugin->expects($this->once())
->method('init') ->method('init')
->with($view_executable) ->with($view_executable)
->will($this->returnValue(TRUE)); ->willReturn(TRUE);
$style_manager->expects($this->once()) $style_manager->expects($this->once())
->method('createInstance') ->method('createInstance')
->will($this->returnValue($style_plugin)); ->willReturn($style_plugin);
$this->routes = new RouteCollection(); $this->routes = new RouteCollection();
$this->routes->add('test_1', new Route('/test/1')); $this->routes->add('test_1', new Route('/test/1'));

View File

@ -56,7 +56,7 @@ class EntityResourceValidationTraitTest extends UnitTestCase {
$violations->expects($this->once()) $violations->expects($this->once())
->method('filterByFieldAccess') ->method('filterByFieldAccess')
->will($this->returnValue([])); ->willReturn([]);
$entity->validate()->willReturn($violations); $entity->validate()->willReturn($violations);

View File

@ -55,13 +55,13 @@ class SearchPageRepositoryTest extends UnitTestCase {
$this->storage = $this->createMock('Drupal\Core\Config\Entity\ConfigEntityStorageInterface'); $this->storage = $this->createMock('Drupal\Core\Config\Entity\ConfigEntityStorageInterface');
$this->storage->expects($this->any()) $this->storage->expects($this->any())
->method('getQuery') ->method('getQuery')
->will($this->returnValue($this->query)); ->willReturn($this->query);
/** @var \Drupal\Core\Entity\EntityTypeManagerInterface|\PHPUnit\Framework\MockObject\MockObject $entity_type_manager */ /** @var \Drupal\Core\Entity\EntityTypeManagerInterface|\PHPUnit\Framework\MockObject\MockObject $entity_type_manager */
$entity_type_manager = $this->createMock(EntityTypeManagerInterface::class); $entity_type_manager = $this->createMock(EntityTypeManagerInterface::class);
$entity_type_manager->expects($this->any()) $entity_type_manager->expects($this->any())
->method('getStorage') ->method('getStorage')
->will($this->returnValue($this->storage)); ->willReturn($this->storage);
$this->configFactory = $this->createMock('Drupal\Core\Config\ConfigFactoryInterface'); $this->configFactory = $this->createMock('Drupal\Core\Config\ConfigFactoryInterface');
$this->searchPageRepository = new SearchPageRepository($this->configFactory, $entity_type_manager); $this->searchPageRepository = new SearchPageRepository($this->configFactory, $entity_type_manager);
@ -74,10 +74,10 @@ class SearchPageRepositoryTest extends UnitTestCase {
$this->query->expects($this->once()) $this->query->expects($this->once())
->method('condition') ->method('condition')
->with('status', TRUE) ->with('status', TRUE)
->will($this->returnValue($this->query)); ->willReturn($this->query);
$this->query->expects($this->once()) $this->query->expects($this->once())
->method('execute') ->method('execute')
->will($this->returnValue(['test' => 'test', 'other_test' => 'other_test'])); ->willReturn(['test' => 'test', 'other_test' => 'other_test']);
$entities = []; $entities = [];
$entities['test'] = $this->createMock('Drupal\search\SearchPageInterface'); $entities['test'] = $this->createMock('Drupal\search\SearchPageInterface');
@ -85,7 +85,7 @@ class SearchPageRepositoryTest extends UnitTestCase {
$this->storage->expects($this->once()) $this->storage->expects($this->once())
->method('loadMultiple') ->method('loadMultiple')
->with(['test' => 'test', 'other_test' => 'other_test']) ->with(['test' => 'test', 'other_test' => 'other_test'])
->will($this->returnValue($entities)); ->willReturn($entities);
$result = $this->searchPageRepository->getActiveSearchPages(); $result = $this->searchPageRepository->getActiveSearchPages();
$this->assertSame($entities, $result); $this->assertSame($entities, $result);
@ -98,14 +98,14 @@ class SearchPageRepositoryTest extends UnitTestCase {
$this->query->expects($this->once()) $this->query->expects($this->once())
->method('condition') ->method('condition')
->with('status', TRUE) ->with('status', TRUE)
->will($this->returnValue($this->query)); ->willReturn($this->query);
$this->query->expects($this->once()) $this->query->expects($this->once())
->method('range') ->method('range')
->with(0, 1) ->with(0, 1)
->will($this->returnValue($this->query)); ->willReturn($this->query);
$this->query->expects($this->once()) $this->query->expects($this->once())
->method('execute') ->method('execute')
->will($this->returnValue(['test' => 'test'])); ->willReturn(['test' => 'test']);
$this->assertTrue($this->searchPageRepository->isSearchActive()); $this->assertTrue($this->searchPageRepository->isSearchActive());
} }
@ -117,24 +117,24 @@ class SearchPageRepositoryTest extends UnitTestCase {
$this->query->expects($this->once()) $this->query->expects($this->once())
->method('condition') ->method('condition')
->with('status', TRUE) ->with('status', TRUE)
->will($this->returnValue($this->query)); ->willReturn($this->query);
$this->query->expects($this->once()) $this->query->expects($this->once())
->method('execute') ->method('execute')
->will($this->returnValue(['test' => 'test', 'other_test' => 'other_test'])); ->willReturn(['test' => 'test', 'other_test' => 'other_test']);
$entities = []; $entities = [];
$entities['test'] = $this->createMock('Drupal\search\SearchPageInterface'); $entities['test'] = $this->createMock('Drupal\search\SearchPageInterface');
$entities['test']->expects($this->once()) $entities['test']->expects($this->once())
->method('isIndexable') ->method('isIndexable')
->will($this->returnValue(TRUE)); ->willReturn(TRUE);
$entities['other_test'] = $this->createMock('Drupal\search\SearchPageInterface'); $entities['other_test'] = $this->createMock('Drupal\search\SearchPageInterface');
$entities['other_test']->expects($this->once()) $entities['other_test']->expects($this->once())
->method('isIndexable') ->method('isIndexable')
->will($this->returnValue(FALSE)); ->willReturn(FALSE);
$this->storage->expects($this->once()) $this->storage->expects($this->once())
->method('loadMultiple') ->method('loadMultiple')
->with(['test' => 'test', 'other_test' => 'other_test']) ->with(['test' => 'test', 'other_test' => 'other_test'])
->will($this->returnValue($entities)); ->willReturn($entities);
$result = $this->searchPageRepository->getIndexableSearchPages(); $result = $this->searchPageRepository->getIndexableSearchPages();
$this->assertCount(1, $result); $this->assertCount(1, $result);
@ -151,11 +151,11 @@ class SearchPageRepositoryTest extends UnitTestCase {
$config->expects($this->once()) $config->expects($this->once())
->method('clear') ->method('clear')
->with('default_page') ->with('default_page')
->will($this->returnValue($config)); ->willReturn($config);
$this->configFactory->expects($this->once()) $this->configFactory->expects($this->once())
->method('getEditable') ->method('getEditable')
->with('search.settings') ->with('search.settings')
->will($this->returnValue($config)); ->willReturn($config);
$this->searchPageRepository->clearDefaultSearchPage(); $this->searchPageRepository->clearDefaultSearchPage();
} }
@ -166,10 +166,10 @@ class SearchPageRepositoryTest extends UnitTestCase {
$this->query->expects($this->once()) $this->query->expects($this->once())
->method('condition') ->method('condition')
->with('status', TRUE) ->with('status', TRUE)
->will($this->returnValue($this->query)); ->willReturn($this->query);
$this->query->expects($this->once()) $this->query->expects($this->once())
->method('execute') ->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') $config = $this->getMockBuilder('Drupal\Core\Config\Config')
->disableOriginalConstructor() ->disableOriginalConstructor()
@ -177,11 +177,11 @@ class SearchPageRepositoryTest extends UnitTestCase {
$config->expects($this->once()) $config->expects($this->once())
->method('get') ->method('get')
->with('default_page') ->with('default_page')
->will($this->returnValue('test')); ->willReturn('test');
$this->configFactory->expects($this->once()) $this->configFactory->expects($this->once())
->method('get') ->method('get')
->with('search.settings') ->with('search.settings')
->will($this->returnValue($config)); ->willReturn($config);
$this->assertSame('test', $this->searchPageRepository->getDefaultSearchPage()); $this->assertSame('test', $this->searchPageRepository->getDefaultSearchPage());
} }
@ -193,10 +193,10 @@ class SearchPageRepositoryTest extends UnitTestCase {
$this->query->expects($this->once()) $this->query->expects($this->once())
->method('condition') ->method('condition')
->with('status', TRUE) ->with('status', TRUE)
->will($this->returnValue($this->query)); ->willReturn($this->query);
$this->query->expects($this->once()) $this->query->expects($this->once())
->method('execute') ->method('execute')
->will($this->returnValue(['test' => 'test'])); ->willReturn(['test' => 'test']);
$config = $this->getMockBuilder('Drupal\Core\Config\Config') $config = $this->getMockBuilder('Drupal\Core\Config\Config')
->disableOriginalConstructor() ->disableOriginalConstructor()
@ -204,11 +204,11 @@ class SearchPageRepositoryTest extends UnitTestCase {
$config->expects($this->once()) $config->expects($this->once())
->method('get') ->method('get')
->with('default_page') ->with('default_page')
->will($this->returnValue('other_test')); ->willReturn('other_test');
$this->configFactory->expects($this->once()) $this->configFactory->expects($this->once())
->method('get') ->method('get')
->with('search.settings') ->with('search.settings')
->will($this->returnValue($config)); ->willReturn($config);
$this->assertSame('test', $this->searchPageRepository->getDefaultSearchPage()); $this->assertSame('test', $this->searchPageRepository->getDefaultSearchPage());
} }
@ -224,25 +224,25 @@ class SearchPageRepositoryTest extends UnitTestCase {
$config->expects($this->once()) $config->expects($this->once())
->method('set') ->method('set')
->with('default_page', $id) ->with('default_page', $id)
->will($this->returnValue($config)); ->willReturn($config);
$config->expects($this->once()) $config->expects($this->once())
->method('save') ->method('save')
->will($this->returnValue($config)); ->willReturn($config);
$this->configFactory->expects($this->once()) $this->configFactory->expects($this->once())
->method('getEditable') ->method('getEditable')
->with('search.settings') ->with('search.settings')
->will($this->returnValue($config)); ->willReturn($config);
$search_page = $this->createMock('Drupal\search\SearchPageInterface'); $search_page = $this->createMock('Drupal\search\SearchPageInterface');
$search_page->expects($this->once()) $search_page->expects($this->once())
->method('id') ->method('id')
->will($this->returnValue($id)); ->willReturn($id);
$search_page->expects($this->once()) $search_page->expects($this->once())
->method('enable') ->method('enable')
->will($this->returnValue($search_page)); ->willReturn($search_page);
$search_page->expects($this->once()) $search_page->expects($this->once())
->method('save') ->method('save')
->will($this->returnValue($search_page)); ->willReturn($search_page);
$this->searchPageRepository->setDefaultSearchPage($search_page); $this->searchPageRepository->setDefaultSearchPage($search_page);
} }
@ -253,10 +253,10 @@ class SearchPageRepositoryTest extends UnitTestCase {
$entity_type = $this->createMock('Drupal\Core\Entity\EntityTypeInterface'); $entity_type = $this->createMock('Drupal\Core\Entity\EntityTypeInterface');
$entity_type->expects($this->any()) $entity_type->expects($this->any())
->method('getClass') ->method('getClass')
->will($this->returnValue('Drupal\Tests\search\Unit\TestSearchPage')); ->willReturn('Drupal\Tests\search\Unit\TestSearchPage');
$this->storage->expects($this->once()) $this->storage->expects($this->once())
->method('getEntityType') ->method('getEntityType')
->will($this->returnValue($entity_type)); ->willReturn($entity_type);
// Declare entities out of their expected order so we can be sure they were // Declare entities out of their expected order so we can be sure they were
// sorted. We cannot mock these because of uasort(), see // sorted. We cannot mock these because of uasort(), see

View File

@ -47,7 +47,7 @@ class SearchPluginCollectionTest extends UnitTestCase {
$plugin = $this->createMock('Drupal\search\Plugin\SearchInterface'); $plugin = $this->createMock('Drupal\search\Plugin\SearchInterface');
$this->pluginManager->expects($this->once()) $this->pluginManager->expects($this->once())
->method('createInstance') ->method('createInstance')
->will($this->returnValue($plugin)); ->willReturn($plugin);
$this->assertSame($plugin, $this->searchPluginCollection->get('banana')); $this->assertSame($plugin, $this->searchPluginCollection->get('banana'));
} }
@ -59,11 +59,11 @@ class SearchPluginCollectionTest extends UnitTestCase {
$plugin->expects($this->once()) $plugin->expects($this->once())
->method('setSearchPageId') ->method('setSearchPageId')
->with('fruit_stand') ->with('fruit_stand')
->will($this->returnValue($plugin)); ->willReturn($plugin);
$this->pluginManager->expects($this->once()) $this->pluginManager->expects($this->once())
->method('createInstance') ->method('createInstance')
->will($this->returnValue($plugin)); ->willReturn($plugin);
$this->assertSame($plugin, $this->searchPluginCollection->get('banana')); $this->assertSame($plugin, $this->searchPluginCollection->get('banana'));
} }

View File

@ -65,7 +65,7 @@ class XmlEncoderTest extends UnitTestCase {
$this->baseEncoder->expects($this->once()) $this->baseEncoder->expects($this->once())
->method('encode') ->method('encode')
->with($this->testArray, 'test', []) ->with($this->testArray, 'test', [])
->will($this->returnValue('test')); ->willReturn('test');
$this->assertEquals('test', $this->encoder->encode($this->testArray, 'test')); $this->assertEquals('test', $this->encoder->encode($this->testArray, 'test'));
} }
@ -77,7 +77,7 @@ class XmlEncoderTest extends UnitTestCase {
$this->baseEncoder->expects($this->once()) $this->baseEncoder->expects($this->once())
->method('decode') ->method('decode')
->with('test', 'test', []) ->with('test', 'test', [])
->will($this->returnValue($this->testArray)); ->willReturn($this->testArray);
$this->assertEquals($this->testArray, $this->encoder->decode('test', 'test')); $this->assertEquals($this->testArray, $this->encoder->decode('test', 'test'));
} }

View File

@ -140,7 +140,7 @@ class ChainEntityResolverTest extends UnitTestCase {
$mock->expects($this->once()) $mock->expects($this->once())
->method('resolve') ->method('resolve')
->with($this->testNormalizer, $this->testData, $this->testEntityType) ->with($this->testNormalizer, $this->testData, $this->testEntityType)
->will($this->returnValue($return)); ->willReturn($return);
} }
else { else {
$mock->expects($this->never()) $mock->expects($this->never())

View File

@ -57,7 +57,7 @@ class UuidResolverTest extends UnitTestCase {
$normalizer->expects($this->once()) $normalizer->expects($this->once())
->method('getUuid') ->method('getUuid')
->with([]) ->with([])
->will($this->returnValue(NULL)); ->willReturn(NULL);
$this->assertNull($this->resolver->resolve($normalizer, [], 'test_type')); $this->assertNull($this->resolver->resolve($normalizer, [], 'test_type'));
} }
@ -70,13 +70,13 @@ class UuidResolverTest extends UnitTestCase {
$this->entityRepository->expects($this->once()) $this->entityRepository->expects($this->once())
->method('loadEntityByUuid') ->method('loadEntityByUuid')
->with('test_type') ->with('test_type')
->will($this->returnValue(NULL)); ->willReturn(NULL);
$normalizer = $this->createMock('Drupal\serialization\EntityResolver\UuidReferenceInterface'); $normalizer = $this->createMock('Drupal\serialization\EntityResolver\UuidReferenceInterface');
$normalizer->expects($this->once()) $normalizer->expects($this->once())
->method('getUuid') ->method('getUuid')
->with([]) ->with([])
->will($this->returnValue($uuid)); ->willReturn($uuid);
$this->assertNull($this->resolver->resolve($normalizer, [], 'test_type')); $this->assertNull($this->resolver->resolve($normalizer, [], 'test_type'));
} }
@ -90,18 +90,18 @@ class UuidResolverTest extends UnitTestCase {
$entity = $this->createMock('Drupal\Core\Entity\EntityInterface'); $entity = $this->createMock('Drupal\Core\Entity\EntityInterface');
$entity->expects($this->once()) $entity->expects($this->once())
->method('id') ->method('id')
->will($this->returnValue(1)); ->willReturn(1);
$this->entityRepository->expects($this->once()) $this->entityRepository->expects($this->once())
->method('loadEntityByUuid') ->method('loadEntityByUuid')
->with('test_type', $uuid) ->with('test_type', $uuid)
->will($this->returnValue($entity)); ->willReturn($entity);
$normalizer = $this->createMock('Drupal\serialization\EntityResolver\UuidReferenceInterface'); $normalizer = $this->createMock('Drupal\serialization\EntityResolver\UuidReferenceInterface');
$normalizer->expects($this->once()) $normalizer->expects($this->once())
->method('getUuid') ->method('getUuid')
->with([]) ->with([])
->will($this->returnValue($uuid)); ->willReturn($uuid);
$this->assertSame(1, $this->resolver->resolve($normalizer, [], 'test_type')); $this->assertSame(1, $this->resolver->resolve($normalizer, [], 'test_type'));
} }

View File

@ -42,7 +42,7 @@ class ConfigEntityNormalizerTest extends UnitTestCase {
$config_entity = $this->createMock('Drupal\Core\Config\Entity\ConfigEntityInterface'); $config_entity = $this->createMock('Drupal\Core\Config\Entity\ConfigEntityInterface');
$config_entity->expects($this->once()) $config_entity->expects($this->once())
->method('toArray') ->method('toArray')
->will($this->returnValue($test_export_properties)); ->willReturn($test_export_properties);
$this->assertSame(['test' => 'test'], $normalizer->normalize($config_entity)); $this->assertSame(['test' => 'test'], $normalizer->normalize($config_entity));
} }

View File

@ -67,7 +67,7 @@ class ContentEntityNormalizerTest extends UnitTestCase {
$this->serializer->expects($this->any()) $this->serializer->expects($this->any())
->method('normalize') ->method('normalize')
->with($this->containsOnlyInstancesOf('Drupal\Core\Field\FieldItemListInterface'), 'test_format', ['account' => NULL]) ->with($this->containsOnlyInstancesOf('Drupal\Core\Field\FieldItemListInterface'), 'test_format', ['account' => NULL])
->will($this->returnValue('test')); ->willReturn('test');
$definitions = [ $definitions = [
'field_accessible_external' => $this->createMockFieldListItem(TRUE, FALSE), 'field_accessible_external' => $this->createMockFieldListItem(TRUE, FALSE),
@ -101,7 +101,7 @@ class ContentEntityNormalizerTest extends UnitTestCase {
$this->serializer->expects($this->any()) $this->serializer->expects($this->any())
->method('normalize') ->method('normalize')
->with($this->containsOnlyInstancesOf('Drupal\Core\Field\FieldItemListInterface'), 'test_format', $context) ->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 // The mock account should get passed directly into the access() method on
// field items from $context['account']. // field items from $context['account'].
@ -137,7 +137,7 @@ class ContentEntityNormalizerTest extends UnitTestCase {
->shouldBeCalled(); ->shouldBeCalled();
$content_entity_mock->expects($this->any()) $content_entity_mock->expects($this->any())
->method('getTypedData') ->method('getTypedData')
->will($this->returnValue($typed_data->reveal())); ->willReturn($typed_data->reveal());
return $content_entity_mock; return $content_entity_mock;
} }
@ -159,7 +159,7 @@ class ContentEntityNormalizerTest extends UnitTestCase {
$mock = $this->createMock('Drupal\Core\Field\FieldItemListInterface'); $mock = $this->createMock('Drupal\Core\Field\FieldItemListInterface');
$mock->expects($this->once()) $mock->expects($this->once())
->method('getDataDefinition') ->method('getDataDefinition')
->will($this->returnValue($data_definition->reveal())); ->willReturn($data_definition->reveal());
$data_definition->isInternal() $data_definition->isInternal()
->willReturn($internal) ->willReturn($internal)
->shouldBeCalled(); ->shouldBeCalled();
@ -167,7 +167,7 @@ class ContentEntityNormalizerTest extends UnitTestCase {
$mock->expects($this->once()) $mock->expects($this->once())
->method('access') ->method('access')
->with('view', $user_context) ->with('view', $user_context)
->will($this->returnValue($access)); ->willReturn($access);
} }
return $mock; return $mock;
} }

View File

@ -87,7 +87,7 @@ class EntityNormalizerTest extends UnitTestCase {
->getMockForAbstractClass(); ->getMockForAbstractClass();
$content_entity->expects($this->once()) $content_entity->expects($this->once())
->method('getFields') ->method('getFields')
->will($this->returnValue($definitions)); ->willReturn($definitions);
$serializer = $this->getMockBuilder('Symfony\Component\Serializer\Serializer') $serializer = $this->getMockBuilder('Symfony\Component\Serializer\Serializer')
->disableOriginalConstructor() ->disableOriginalConstructor()
@ -137,11 +137,11 @@ class EntityNormalizerTest extends UnitTestCase {
$entity_type->expects($this->once()) $entity_type->expects($this->once())
->method('hasKey') ->method('hasKey')
->with('bundle') ->with('bundle')
->will($this->returnValue(TRUE)); ->willReturn(TRUE);
$entity_type->expects($this->once()) $entity_type->expects($this->once())
->method('getKey') ->method('getKey')
->with('bundle') ->with('bundle')
->will($this->returnValue('test_type')); ->willReturn('test_type');
$entity_type->expects($this->once()) $entity_type->expects($this->once())
->method('entityClassImplements') ->method('entityClassImplements')
->with(FieldableEntityInterface::class) ->with(FieldableEntityInterface::class)
@ -149,17 +149,17 @@ class EntityNormalizerTest extends UnitTestCase {
$entity_type->expects($this->once()) $entity_type->expects($this->once())
->method('getBundleEntityType') ->method('getBundleEntityType')
->will($this->returnValue('test_bundle')); ->willReturn('test_bundle');
$entity_type_storage_definition = $this->createMock('Drupal\Core\Field\FieldStorageDefinitionInterface'); $entity_type_storage_definition = $this->createMock('Drupal\Core\Field\FieldStorageDefinitionInterface');
$entity_type_storage_definition->expects($this->once()) $entity_type_storage_definition->expects($this->once())
->method('getMainPropertyName') ->method('getMainPropertyName')
->will($this->returnValue('name')); ->willReturn('name');
$entity_type_definition = $this->createMock('Drupal\Core\Field\FieldDefinitionInterface'); $entity_type_definition = $this->createMock('Drupal\Core\Field\FieldDefinitionInterface');
$entity_type_definition->expects($this->once()) $entity_type_definition->expects($this->once())
->method('getFieldStorageDefinition') ->method('getFieldStorageDefinition')
->will($this->returnValue($entity_type_storage_definition)); ->willReturn($entity_type_storage_definition);
$base_definitions = [ $base_definitions = [
'test_type' => $entity_type_definition, 'test_type' => $entity_type_definition,
@ -168,21 +168,21 @@ class EntityNormalizerTest extends UnitTestCase {
$this->entityTypeManager->expects($this->once()) $this->entityTypeManager->expects($this->once())
->method('getDefinition') ->method('getDefinition')
->with('test') ->with('test')
->will($this->returnValue($entity_type)); ->willReturn($entity_type);
$this->entityFieldManager->expects($this->once()) $this->entityFieldManager->expects($this->once())
->method('getBaseFieldDefinitions') ->method('getBaseFieldDefinitions')
->with('test') ->with('test')
->will($this->returnValue($base_definitions)); ->willReturn($base_definitions);
$entity_query_mock = $this->createMock('Drupal\Core\Entity\Query\QueryInterface'); $entity_query_mock = $this->createMock('Drupal\Core\Entity\Query\QueryInterface');
$entity_query_mock->expects($this->once()) $entity_query_mock->expects($this->once())
->method('execute') ->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 = $this->createMock('Drupal\Core\Entity\EntityStorageInterface');
$entity_type_storage->expects($this->once()) $entity_type_storage->expects($this->once())
->method('getQuery') ->method('getQuery')
->will($this->returnValue($entity_query_mock)); ->willReturn($entity_query_mock);
$key_1 = $this->createMock(FieldItemListInterface::class); $key_1 = $this->createMock(FieldItemListInterface::class);
$key_2 = $this->createMock(FieldItemListInterface::class); $key_2 = $this->createMock(FieldItemListInterface::class);
@ -204,7 +204,7 @@ class EntityNormalizerTest extends UnitTestCase {
$storage->expects($this->once()) $storage->expects($this->once())
->method('create') ->method('create')
->with($expected_test_data) ->with($expected_test_data)
->will($this->returnValue($entity)); ->willReturn($entity);
$this->entityTypeManager->expects($this->exactly(2)) $this->entityTypeManager->expects($this->exactly(2))
->method('getStorage') ->method('getStorage')
@ -253,11 +253,11 @@ class EntityNormalizerTest extends UnitTestCase {
$entity_type->expects($this->once()) $entity_type->expects($this->once())
->method('hasKey') ->method('hasKey')
->with('bundle') ->with('bundle')
->will($this->returnValue(TRUE)); ->willReturn(TRUE);
$entity_type->expects($this->once()) $entity_type->expects($this->once())
->method('getKey') ->method('getKey')
->with('bundle') ->with('bundle')
->will($this->returnValue('test_type')); ->willReturn('test_type');
$entity_type->expects($this->once()) $entity_type->expects($this->once())
->method('entityClassImplements') ->method('entityClassImplements')
->with(FieldableEntityInterface::class) ->with(FieldableEntityInterface::class)
@ -265,17 +265,17 @@ class EntityNormalizerTest extends UnitTestCase {
$entity_type->expects($this->once()) $entity_type->expects($this->once())
->method('getBundleEntityType') ->method('getBundleEntityType')
->will($this->returnValue('test_bundle')); ->willReturn('test_bundle');
$entity_type_storage_definition = $this->createMock('Drupal\Core\Field\FieldStorageDefinitionInterface'); $entity_type_storage_definition = $this->createMock('Drupal\Core\Field\FieldStorageDefinitionInterface');
$entity_type_storage_definition->expects($this->once()) $entity_type_storage_definition->expects($this->once())
->method('getMainPropertyName') ->method('getMainPropertyName')
->will($this->returnValue('name')); ->willReturn('name');
$entity_type_definition = $this->createMock('Drupal\Core\Field\FieldDefinitionInterface'); $entity_type_definition = $this->createMock('Drupal\Core\Field\FieldDefinitionInterface');
$entity_type_definition->expects($this->once()) $entity_type_definition->expects($this->once())
->method('getFieldStorageDefinition') ->method('getFieldStorageDefinition')
->will($this->returnValue($entity_type_storage_definition)); ->willReturn($entity_type_storage_definition);
$base_definitions = [ $base_definitions = [
'test_type' => $entity_type_definition, 'test_type' => $entity_type_definition,
@ -284,26 +284,26 @@ class EntityNormalizerTest extends UnitTestCase {
$this->entityTypeManager->expects($this->once()) $this->entityTypeManager->expects($this->once())
->method('getDefinition') ->method('getDefinition')
->with('test') ->with('test')
->will($this->returnValue($entity_type)); ->willReturn($entity_type);
$this->entityFieldManager->expects($this->once()) $this->entityFieldManager->expects($this->once())
->method('getBaseFieldDefinitions') ->method('getBaseFieldDefinitions')
->with('test') ->with('test')
->will($this->returnValue($base_definitions)); ->willReturn($base_definitions);
$entity_query_mock = $this->createMock('Drupal\Core\Entity\Query\QueryInterface'); $entity_query_mock = $this->createMock('Drupal\Core\Entity\Query\QueryInterface');
$entity_query_mock->expects($this->once()) $entity_query_mock->expects($this->once())
->method('execute') ->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 = $this->createMock('Drupal\Core\Entity\EntityStorageInterface');
$entity_type_storage->expects($this->once()) $entity_type_storage->expects($this->once())
->method('getQuery') ->method('getQuery')
->will($this->returnValue($entity_query_mock)); ->willReturn($entity_query_mock);
$this->entityTypeManager->expects($this->once()) $this->entityTypeManager->expects($this->once())
->method('getStorage') ->method('getStorage')
->with('test_bundle') ->with('test_bundle')
->will($this->returnValue($entity_type_storage)); ->willReturn($entity_type_storage);
$this->expectException(UnexpectedValueException::class); $this->expectException(UnexpectedValueException::class);
$this->entityNormalizer->denormalize($test_data, 'Drupal\Core\Entity\ContentEntityBase', NULL, ['entity_type' => 'test']); $this->entityNormalizer->denormalize($test_data, 'Drupal\Core\Entity\ContentEntityBase', NULL, ['entity_type' => 'test']);
@ -328,14 +328,14 @@ class EntityNormalizerTest extends UnitTestCase {
$entity_type->expects($this->once()) $entity_type->expects($this->once())
->method('hasKey') ->method('hasKey')
->with('bundle') ->with('bundle')
->will($this->returnValue(FALSE)); ->willReturn(FALSE);
$entity_type->expects($this->never()) $entity_type->expects($this->never())
->method('getKey'); ->method('getKey');
$this->entityTypeManager->expects($this->once()) $this->entityTypeManager->expects($this->once())
->method('getDefinition') ->method('getDefinition')
->with('test') ->with('test')
->will($this->returnValue($entity_type)); ->willReturn($entity_type);
$key_1 = $this->createMock(FieldItemListInterface::class); $key_1 = $this->createMock(FieldItemListInterface::class);
$key_2 = $this->createMock(FieldItemListInterface::class); $key_2 = $this->createMock(FieldItemListInterface::class);
@ -352,12 +352,12 @@ class EntityNormalizerTest extends UnitTestCase {
$storage->expects($this->once()) $storage->expects($this->once())
->method('create') ->method('create')
->with([]) ->with([])
->will($this->returnValue($entity)); ->willReturn($entity);
$this->entityTypeManager->expects($this->once()) $this->entityTypeManager->expects($this->once())
->method('getStorage') ->method('getStorage')
->with('test') ->with('test')
->will($this->returnValue($storage)); ->willReturn($storage);
$this->entityFieldManager->expects($this->never()) $this->entityFieldManager->expects($this->never())
->method('getBaseFieldDefinitions'); ->method('getBaseFieldDefinitions');
@ -403,18 +403,18 @@ class EntityNormalizerTest extends UnitTestCase {
$this->entityTypeManager->expects($this->once()) $this->entityTypeManager->expects($this->once())
->method('getDefinition') ->method('getDefinition')
->with('test') ->with('test')
->will($this->returnValue($entity_type)); ->willReturn($entity_type);
$storage = $this->createMock('Drupal\Core\Entity\EntityStorageInterface'); $storage = $this->createMock('Drupal\Core\Entity\EntityStorageInterface');
$storage->expects($this->once()) $storage->expects($this->once())
->method('create') ->method('create')
->with($test_data) ->with($test_data)
->will($this->returnValue($this->createMock('Drupal\Core\Entity\EntityInterface'))); ->willReturn($this->createMock('Drupal\Core\Entity\EntityInterface'));
$this->entityTypeManager->expects($this->once()) $this->entityTypeManager->expects($this->once())
->method('getStorage') ->method('getStorage')
->with('test') ->with('test')
->will($this->returnValue($storage)); ->willReturn($storage);
$this->entityFieldManager->expects($this->never()) $this->entityFieldManager->expects($this->never())
->method('getBaseFieldDefinitions'); ->method('getBaseFieldDefinitions');

View File

@ -52,7 +52,7 @@ class ListNormalizerTest extends UnitTestCase {
$typed_data_manager = $this->createMock(TypedDataManagerInterface::class); $typed_data_manager = $this->createMock(TypedDataManagerInterface::class);
$typed_data_manager->expects($this->any()) $typed_data_manager->expects($this->any())
->method('getPropertyInstance') ->method('getPropertyInstance')
->will($this->returnValue($this->typedData)); ->willReturn($this->typedData);
// Set up a mock container as ItemList() will call for the 'typed_data_manager' // Set up a mock container as ItemList() will call for the 'typed_data_manager'
// service. // service.
@ -62,7 +62,7 @@ class ListNormalizerTest extends UnitTestCase {
$container->expects($this->any()) $container->expects($this->any())
->method('get') ->method('get')
->with($this->equalTo('typed_data_manager')) ->with($this->equalTo('typed_data_manager'))
->will($this->returnValue($typed_data_manager)); ->willReturn($typed_data_manager);
\Drupal::setContainer($container); \Drupal::setContainer($container);

View File

@ -48,7 +48,7 @@ class TypedDataNormalizerTest extends UnitTestCase {
public function testNormalize() { public function testNormalize() {
$this->typedData->expects($this->once()) $this->typedData->expects($this->once())
->method('getValue') ->method('getValue')
->will($this->returnValue('test')); ->willReturn('test');
$this->assertEquals('test', $this->normalizer->normalize($this->typedData)); $this->assertEquals('test', $this->normalizer->normalize($this->typedData));
} }

View File

@ -26,7 +26,7 @@ class ShortcutLocalTasksTest extends LocalTaskIntegrationTestBase {
$entity_type_manager = $this->createMock(EntityTypeManagerInterface::class); $entity_type_manager = $this->createMock(EntityTypeManagerInterface::class);
$entity_type_manager->expects($this->any()) $entity_type_manager->expects($this->any())
->method('getDefinitions') ->method('getDefinitions')
->will($this->returnValue([])); ->willReturn([]);
$this->container->set('entity_type.manager', $entity_type_manager); $this->container->set('entity_type.manager', $entity_type_manager);
$this->container->set('string_translation', $this->getStringTranslationStub()); $this->container->set('string_translation', $this->getStringTranslationStub());
} }

View File

@ -164,7 +164,7 @@ class PathBasedBreadcrumbBuilderTest extends UnitTestCase {
public function testBuildWithOnePathElement() { public function testBuildWithOnePathElement() {
$this->context->expects($this->once()) $this->context->expects($this->once())
->method('getPathInfo') ->method('getPathInfo')
->will($this->returnValue('/example')); ->willReturn('/example');
$breadcrumb = $this->builder->build($this->createMock('Drupal\Core\Routing\RouteMatchInterface')); $breadcrumb = $this->builder->build($this->createMock('Drupal\Core\Routing\RouteMatchInterface'));
$this->assertEquals([0 => new Link('Home', new Url('<front>'))], $breadcrumb->getLinks()); $this->assertEquals([0 => new Link('Home', new Url('<front>'))], $breadcrumb->getLinks());
@ -182,7 +182,7 @@ class PathBasedBreadcrumbBuilderTest extends UnitTestCase {
public function testBuildWithTwoPathElements() { public function testBuildWithTwoPathElements() {
$this->context->expects($this->once()) $this->context->expects($this->once())
->method('getPathInfo') ->method('getPathInfo')
->will($this->returnValue('/example/baz')); ->willReturn('/example/baz');
$this->setupStubPathProcessor(); $this->setupStubPathProcessor();
$route_1 = new Route('/example'); $route_1 = new Route('/example');
@ -221,7 +221,7 @@ class PathBasedBreadcrumbBuilderTest extends UnitTestCase {
public function testBuildWithThreePathElements() { public function testBuildWithThreePathElements() {
$this->context->expects($this->once()) $this->context->expects($this->once())
->method('getPathInfo') ->method('getPathInfo')
->will($this->returnValue('/example/bar/baz')); ->willReturn('/example/bar/baz');
$this->setupStubPathProcessor(); $this->setupStubPathProcessor();
$route_1 = new Route('/example/bar'); $route_1 = new Route('/example/bar');
@ -279,7 +279,7 @@ class PathBasedBreadcrumbBuilderTest extends UnitTestCase {
public function testBuildWithException($exception_class, $exception_argument) { public function testBuildWithException($exception_class, $exception_argument) {
$this->context->expects($this->once()) $this->context->expects($this->once())
->method('getPathInfo') ->method('getPathInfo')
->will($this->returnValue('/example/bar')); ->willReturn('/example/bar');
$this->setupStubPathProcessor(); $this->setupStubPathProcessor();
$this->requestMatcher->expects($this->any()) $this->requestMatcher->expects($this->any())
@ -320,15 +320,15 @@ class PathBasedBreadcrumbBuilderTest extends UnitTestCase {
public function testBuildWithNonProcessedPath() { public function testBuildWithNonProcessedPath() {
$this->context->expects($this->once()) $this->context->expects($this->once())
->method('getPathInfo') ->method('getPathInfo')
->will($this->returnValue('/example/bar')); ->willReturn('/example/bar');
$this->pathProcessor->expects($this->once()) $this->pathProcessor->expects($this->once())
->method('processInbound') ->method('processInbound')
->will($this->returnValue(FALSE)); ->willReturn(FALSE);
$this->requestMatcher->expects($this->any()) $this->requestMatcher->expects($this->any())
->method('matchRequest') ->method('matchRequest')
->will($this->returnValue([])); ->willReturn([]);
$breadcrumb = $this->builder->build($this->createMock('Drupal\Core\Routing\RouteMatchInterface')); $breadcrumb = $this->builder->build($this->createMock('Drupal\Core\Routing\RouteMatchInterface'));
@ -357,7 +357,7 @@ class PathBasedBreadcrumbBuilderTest extends UnitTestCase {
public function testBuildWithUserPath() { public function testBuildWithUserPath() {
$this->context->expects($this->once()) $this->context->expects($this->once())
->method('getPathInfo') ->method('getPathInfo')
->will($this->returnValue('/user/1/edit')); ->willReturn('/user/1/edit');
$this->setupStubPathProcessor(); $this->setupStubPathProcessor();
$route_1 = new Route('/user/1'); $route_1 = new Route('/user/1');
@ -378,7 +378,7 @@ class PathBasedBreadcrumbBuilderTest extends UnitTestCase {
$this->titleResolver->expects($this->once()) $this->titleResolver->expects($this->once())
->method('getTitle') ->method('getTitle')
->with($this->anything(), $route_1) ->with($this->anything(), $route_1)
->will($this->returnValue('Admin')); ->willReturn('Admin');
$breadcrumb = $this->builder->build($this->createMock('Drupal\Core\Routing\RouteMatchInterface')); $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()); $this->assertEquals([0 => new Link('Home', new Url('<front>')), 1 => new Link('Admin', new Url('user_page'))], $breadcrumb->getLinks());

View File

@ -36,9 +36,9 @@ class SystemLocalTasksTest extends LocalTaskIntegrationTestBase {
$theme->info = ['name' => 'olivero']; $theme->info = ['name' => 'olivero'];
$this->themeHandler->expects($this->any()) $this->themeHandler->expects($this->any())
->method('listInfo') ->method('listInfo')
->will($this->returnValue([ ->willReturn([
'olivero' => $theme, 'olivero' => $theme,
])); ]);
$this->themeHandler->expects($this->any()) $this->themeHandler->expects($this->any())
->method('hasUi') ->method('hasUi')
->with('olivero') ->with('olivero')

View File

@ -34,7 +34,7 @@ class TourTest extends UnitTestCase {
$tour->expects($this->any()) $tour->expects($this->any())
->method('getRoutes') ->method('getRoutes')
->will($this->returnValue($routes)); ->willReturn($routes);
$this->assertSame($result, $tour->hasMatchingRoute($route_name, $route_params)); $this->assertSame($result, $tour->hasMatchingRoute($route_name, $route_params));

View File

@ -91,7 +91,7 @@ class UpdateFetcherTest extends UnitTestCase implements LoggerInterface {
$container->expects($this->any()) $container->expects($this->any())
->method('get') ->method('get')
->with('logger.factory') ->with('logger.factory')
->will($this->returnValue($logger_factory)); ->willReturn($logger_factory);
\Drupal::setContainer($container); \Drupal::setContainer($container);
} }

View File

@ -23,7 +23,7 @@ class UserLocalTasksTest extends LocalTaskIntegrationTestBase {
$entity_type_manager = $this->createMock(EntityTypeManagerInterface::class); $entity_type_manager = $this->createMock(EntityTypeManagerInterface::class);
$entity_type_manager->expects($this->any()) $entity_type_manager->expects($this->any())
->method('getDefinitions') ->method('getDefinitions')
->will($this->returnValue([])); ->willReturn([]);
$this->container->set('entity_type.manager', $entity_type_manager); $this->container->set('entity_type.manager', $entity_type_manager);
$this->container->set('string_translation', $this->getStringTranslationStub()); $this->container->set('string_translation', $this->getStringTranslationStub());
} }

View File

@ -20,7 +20,7 @@ class AddRoleUserTest extends RoleUserTestBase {
$this->account->expects($this->any()) $this->account->expects($this->any())
->method('hasRole') ->method('hasRole')
->with($this->equalTo('test_role_1')) ->with($this->equalTo('test_role_1'))
->will($this->returnValue(TRUE)); ->willReturn(TRUE);
$config = ['rid' => 'test_role_1']; $config = ['rid' => 'test_role_1'];
$add_role_plugin = new AddRoleUser($config, 'user_add_role_action', ['type' => 'user'], $this->userRoleEntityType); $add_role_plugin = new AddRoleUser($config, 'user_add_role_action', ['type' => 'user'], $this->userRoleEntityType);
@ -38,7 +38,7 @@ class AddRoleUserTest extends RoleUserTestBase {
$this->account->expects($this->any()) $this->account->expects($this->any())
->method('hasRole') ->method('hasRole')
->with($this->equalTo('test_role_1')) ->with($this->equalTo('test_role_1'))
->will($this->returnValue(FALSE)); ->willReturn(FALSE);
$config = ['rid' => 'test_role_1']; $config = ['rid' => 'test_role_1'];
$add_role_plugin = new AddRoleUser($config, 'user_add_role_action', ['type' => 'user'], $this->userRoleEntityType); $add_role_plugin = new AddRoleUser($config, 'user_add_role_action', ['type' => 'user'], $this->userRoleEntityType);

View File

@ -20,7 +20,7 @@ class RemoveRoleUserTest extends RoleUserTestBase {
$this->account->expects($this->any()) $this->account->expects($this->any())
->method('hasRole') ->method('hasRole')
->with($this->equalTo('test_role_1')) ->with($this->equalTo('test_role_1'))
->will($this->returnValue(TRUE)); ->willReturn(TRUE);
$config = ['rid' => 'test_role_1']; $config = ['rid' => 'test_role_1'];
$remove_role_plugin = new RemoveRoleUser($config, 'user_remove_role_action', ['type' => 'user'], $this->userRoleEntityType); $remove_role_plugin = new RemoveRoleUser($config, 'user_remove_role_action', ['type' => 'user'], $this->userRoleEntityType);
@ -38,7 +38,7 @@ class RemoveRoleUserTest extends RoleUserTestBase {
$this->account->expects($this->any()) $this->account->expects($this->any())
->method('hasRole') ->method('hasRole')
->with($this->equalTo('test_role_1')) ->with($this->equalTo('test_role_1'))
->will($this->returnValue(FALSE)); ->willReturn(FALSE);
$config = ['rid' => 'test_role_1']; $config = ['rid' => 'test_role_1'];
$remove_role_plugin = new RemoveRoleUser($config, 'user_remove_role_action', ['type' => 'user'], $this->userRoleEntityType); $remove_role_plugin = new RemoveRoleUser($config, 'user_remove_role_action', ['type' => 'user'], $this->userRoleEntityType);

View File

@ -22,7 +22,7 @@ class UserTest extends UserSessionTest {
$user->expects($this->any()) $user->expects($this->any())
->method('id') ->method('id')
// @todo Also test the uid = 1 handling. // @todo Also test the uid = 1 handling.
->will($this->returnValue($authenticated ? 2 : 0)); ->willReturn($authenticated ? 2 : 0);
$roles = []; $roles = [];
foreach ($rids as $rid) { foreach ($rids as $rid) {
$roles[] = (object) [ $roles[] = (object) [
@ -32,7 +32,7 @@ class UserTest extends UserSessionTest {
$user->expects($this->any()) $user->expects($this->any())
->method('get') ->method('get')
->with('roles') ->with('roles')
->will($this->returnValue($roles)); ->willReturn($roles);
return $user; return $user;
} }

View File

@ -33,26 +33,26 @@ class UserBulkFormTest extends UnitTestCase {
$action = $this->createMock('\Drupal\system\ActionConfigEntityInterface'); $action = $this->createMock('\Drupal\system\ActionConfigEntityInterface');
$action->expects($this->any()) $action->expects($this->any())
->method('getType') ->method('getType')
->will($this->returnValue('user')); ->willReturn('user');
$actions[$i] = $action; $actions[$i] = $action;
} }
$action = $this->createMock('\Drupal\system\ActionConfigEntityInterface'); $action = $this->createMock('\Drupal\system\ActionConfigEntityInterface');
$action->expects($this->any()) $action->expects($this->any())
->method('getType') ->method('getType')
->will($this->returnValue('node')); ->willReturn('node');
$actions[] = $action; $actions[] = $action;
$entity_storage = $this->createMock('Drupal\Core\Entity\EntityStorageInterface'); $entity_storage = $this->createMock('Drupal\Core\Entity\EntityStorageInterface');
$entity_storage->expects($this->any()) $entity_storage->expects($this->any())
->method('loadMultiple') ->method('loadMultiple')
->will($this->returnValue($actions)); ->willReturn($actions);
$entity_type_manager = $this->createMock(EntityTypeManagerInterface::class); $entity_type_manager = $this->createMock(EntityTypeManagerInterface::class);
$entity_type_manager->expects($this->once()) $entity_type_manager->expects($this->once())
->method('getStorage') ->method('getStorage')
->with('action') ->with('action')
->will($this->returnValue($entity_storage)); ->willReturn($entity_storage);
$entity_repository = $this->createMock(EntityRepositoryInterface::class); $entity_repository = $this->createMock(EntityRepositoryInterface::class);
@ -66,7 +66,7 @@ class UserBulkFormTest extends UnitTestCase {
$views_data->expects($this->any()) $views_data->expects($this->any())
->method('get') ->method('get')
->with('users') ->with('users')
->will($this->returnValue(['table' => ['entity type' => 'user']])); ->willReturn(['table' => ['entity type' => 'user']]);
$container = new ContainerBuilder(); $container = new ContainerBuilder();
$container->set('views.views_data', $views_data); $container->set('views.views_data', $views_data);
$container->set('string_translation', $this->getStringTranslationStub()); $container->set('string_translation', $this->getStringTranslationStub());
@ -76,7 +76,7 @@ class UserBulkFormTest extends UnitTestCase {
$storage->expects($this->any()) $storage->expects($this->any())
->method('get') ->method('get')
->with('base_table') ->with('base_table')
->will($this->returnValue('users')); ->willReturn('users');
$executable = $this->getMockBuilder('Drupal\views\ViewExecutable') $executable = $this->getMockBuilder('Drupal\views\ViewExecutable')
->disableOriginalConstructor() ->disableOriginalConstructor()

View File

@ -77,11 +77,11 @@ class UserAccessControlHandlerTest extends UnitTestCase {
$this->viewer $this->viewer
->expects($this->any()) ->expects($this->any())
->method('hasPermission') ->method('hasPermission')
->will($this->returnValue(FALSE)); ->willReturn(FALSE);
$this->viewer $this->viewer
->expects($this->any()) ->expects($this->any())
->method('id') ->method('id')
->will($this->returnValue(1)); ->willReturn(1);
$this->owner = $this->createMock('\Drupal\Core\Session\AccountInterface'); $this->owner = $this->createMock('\Drupal\Core\Session\AccountInterface');
$this->owner $this->owner
@ -95,13 +95,13 @@ class UserAccessControlHandlerTest extends UnitTestCase {
$this->owner $this->owner
->expects($this->any()) ->expects($this->any())
->method('id') ->method('id')
->will($this->returnValue(2)); ->willReturn(2);
$this->admin = $this->createMock('\Drupal\Core\Session\AccountInterface'); $this->admin = $this->createMock('\Drupal\Core\Session\AccountInterface');
$this->admin $this->admin
->expects($this->any()) ->expects($this->any())
->method('hasPermission') ->method('hasPermission')
->will($this->returnValue(TRUE)); ->willReturn(TRUE);
$this->emailViewer = $this->createMock('\Drupal\Core\Session\AccountInterface'); $this->emailViewer = $this->createMock('\Drupal\Core\Session\AccountInterface');
$this->emailViewer $this->emailViewer
@ -113,7 +113,7 @@ class UserAccessControlHandlerTest extends UnitTestCase {
$this->emailViewer $this->emailViewer
->expects($this->any()) ->expects($this->any())
->method('id') ->method('id')
->will($this->returnValue(3)); ->willReturn(3);
$entity_type = $this->createMock('Drupal\Core\Entity\EntityTypeInterface'); $entity_type = $this->createMock('Drupal\Core\Entity\EntityTypeInterface');
@ -127,7 +127,7 @@ class UserAccessControlHandlerTest extends UnitTestCase {
$this->items $this->items
->expects($this->any()) ->expects($this->any())
->method('defaultAccess') ->method('defaultAccess')
->will($this->returnValue(AccessResult::allowed())); ->willReturn(AccessResult::allowed());
} }
/** /**
@ -139,12 +139,12 @@ class UserAccessControlHandlerTest extends UnitTestCase {
$field_definition = $this->createMock('Drupal\Core\Field\FieldDefinitionInterface'); $field_definition = $this->createMock('Drupal\Core\Field\FieldDefinitionInterface');
$field_definition->expects($this->any()) $field_definition->expects($this->any())
->method('getName') ->method('getName')
->will($this->returnValue($field)); ->willReturn($field);
$this->items $this->items
->expects($this->any()) ->expects($this->any())
->method('getEntity') ->method('getEntity')
->will($this->returnValue($this->{$target})); ->willReturn($this->{$target});
foreach (['view' => $view, 'edit' => $edit] as $operation => $result) { foreach (['view' => $view, 'edit' => $edit] as $operation => $result) {
$result_text = !isset($result) ? 'null' : ($result ? 'true' : 'false'); $result_text = !isset($result) ? 'null' : ($result ? 'true' : 'false');

View File

@ -72,7 +72,7 @@ class UserAuthTest extends UnitTestCase {
$entity_type_manager->expects($this->any()) $entity_type_manager->expects($this->any())
->method('getStorage') ->method('getStorage')
->with('user') ->with('user')
->will($this->returnValue($this->userStorage)); ->willReturn($this->userStorage);
$this->passwordService = $this->createMock('Drupal\Core\Password\PasswordInterface'); $this->passwordService = $this->createMock('Drupal\Core\Password\PasswordInterface');
@ -121,7 +121,7 @@ class UserAuthTest extends UnitTestCase {
$this->userStorage->expects($this->once()) $this->userStorage->expects($this->once())
->method('loadByProperties') ->method('loadByProperties')
->with(['name' => $this->username]) ->with(['name' => $this->username])
->will($this->returnValue([])); ->willReturn([]);
$this->assertFalse($this->userAuth->authenticate($this->username, $this->password)); $this->assertFalse($this->userAuth->authenticate($this->username, $this->password));
} }
@ -135,12 +135,12 @@ class UserAuthTest extends UnitTestCase {
$this->userStorage->expects($this->once()) $this->userStorage->expects($this->once())
->method('loadByProperties') ->method('loadByProperties')
->with(['name' => $this->username]) ->with(['name' => $this->username])
->will($this->returnValue([$this->testUser])); ->willReturn([$this->testUser]);
$this->passwordService->expects($this->once()) $this->passwordService->expects($this->once())
->method('check') ->method('check')
->with($this->password, $this->testUser->getPassword()) ->with($this->password, $this->testUser->getPassword())
->will($this->returnValue(FALSE)); ->willReturn(FALSE);
$this->assertFalse($this->userAuth->authenticate($this->username, $this->password)); $this->assertFalse($this->userAuth->authenticate($this->username, $this->password));
} }
@ -153,17 +153,17 @@ class UserAuthTest extends UnitTestCase {
public function testAuthenticateWithCorrectPassword() { public function testAuthenticateWithCorrectPassword() {
$this->testUser->expects($this->once()) $this->testUser->expects($this->once())
->method('id') ->method('id')
->will($this->returnValue(1)); ->willReturn(1);
$this->userStorage->expects($this->once()) $this->userStorage->expects($this->once())
->method('loadByProperties') ->method('loadByProperties')
->with(['name' => $this->username]) ->with(['name' => $this->username])
->will($this->returnValue([$this->testUser])); ->willReturn([$this->testUser]);
$this->passwordService->expects($this->once()) $this->passwordService->expects($this->once())
->method('check') ->method('check')
->with($this->password, $this->testUser->getPassword()) ->with($this->password, $this->testUser->getPassword())
->will($this->returnValue(TRUE)); ->willReturn(TRUE);
$this->assertSame(1, $this->userAuth->authenticate($this->username, $this->password)); $this->assertSame(1, $this->userAuth->authenticate($this->username, $this->password));
} }
@ -180,17 +180,17 @@ class UserAuthTest extends UnitTestCase {
public function testAuthenticateWithZeroPassword() { public function testAuthenticateWithZeroPassword() {
$this->testUser->expects($this->once()) $this->testUser->expects($this->once())
->method('id') ->method('id')
->will($this->returnValue(2)); ->willReturn(2);
$this->userStorage->expects($this->once()) $this->userStorage->expects($this->once())
->method('loadByProperties') ->method('loadByProperties')
->with(['name' => $this->username]) ->with(['name' => $this->username])
->will($this->returnValue([$this->testUser])); ->willReturn([$this->testUser]);
$this->passwordService->expects($this->once()) $this->passwordService->expects($this->once())
->method('check') ->method('check')
->with(0, 0) ->with(0, 0)
->will($this->returnValue(TRUE)); ->willReturn(TRUE);
$this->assertSame(2, $this->userAuth->authenticate($this->username, 0)); $this->assertSame(2, $this->userAuth->authenticate($this->username, 0));
} }
@ -203,7 +203,7 @@ class UserAuthTest extends UnitTestCase {
public function testAuthenticateWithCorrectPasswordAndNewPasswordHash() { public function testAuthenticateWithCorrectPasswordAndNewPasswordHash() {
$this->testUser->expects($this->once()) $this->testUser->expects($this->once())
->method('id') ->method('id')
->will($this->returnValue(1)); ->willReturn(1);
$this->testUser->expects($this->once()) $this->testUser->expects($this->once())
->method('setPassword') ->method('setPassword')
->with($this->password); ->with($this->password);
@ -213,16 +213,16 @@ class UserAuthTest extends UnitTestCase {
$this->userStorage->expects($this->once()) $this->userStorage->expects($this->once())
->method('loadByProperties') ->method('loadByProperties')
->with(['name' => $this->username]) ->with(['name' => $this->username])
->will($this->returnValue([$this->testUser])); ->willReturn([$this->testUser]);
$this->passwordService->expects($this->once()) $this->passwordService->expects($this->once())
->method('check') ->method('check')
->with($this->password, $this->testUser->getPassword()) ->with($this->password, $this->testUser->getPassword())
->will($this->returnValue(TRUE)); ->willReturn(TRUE);
$this->passwordService->expects($this->once()) $this->passwordService->expects($this->once())
->method('needsRehash') ->method('needsRehash')
->with($this->testUser->getPassword()) ->with($this->testUser->getPassword())
->will($this->returnValue(TRUE)); ->willReturn(TRUE);
$this->assertSame(1, $this->userAuth->authenticate($this->username, $this->password)); $this->assertSame(1, $this->userAuth->authenticate($this->username, $this->password));
} }

View File

@ -46,19 +46,19 @@ class RolesRidTest extends UnitTestCase {
$entity_type->expects($this->any()) $entity_type->expects($this->any())
->method('getKey') ->method('getKey')
->with('label') ->with('label')
->will($this->returnValue('label')); ->willReturn('label');
$entity_type_manager = $this->createMock(EntityTypeManagerInterface::class); $entity_type_manager = $this->createMock(EntityTypeManagerInterface::class);
$entity_type_manager->expects($this->any()) $entity_type_manager->expects($this->any())
->method('getDefinition') ->method('getDefinition')
->with($this->equalTo('user_role')) ->with($this->equalTo('user_role'))
->will($this->returnValue($entity_type)); ->willReturn($entity_type);
$entity_type_manager $entity_type_manager
->expects($this->once()) ->expects($this->once())
->method('getStorage') ->method('getStorage')
->with($this->equalTo('user_role')) ->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 // Set up a minimal container to satisfy Drupal\Core\Entity\EntityBase's
// dependency on it. // dependency on it.

View File

@ -134,7 +134,7 @@ class ViewAjaxControllerTest extends UnitTestCase {
$this->viewStorage->expects($this->once()) $this->viewStorage->expects($this->once())
->method('load') ->method('load')
->with('test_view') ->with('test_view')
->will($this->returnValue(FALSE)); ->willReturn(FALSE);
$this->expectException(NotFoundHttpException::class); $this->expectException(NotFoundHttpException::class);
$this->viewAjaxController->ajaxView($request); $this->viewAjaxController->ajaxView($request);
@ -155,19 +155,19 @@ class ViewAjaxControllerTest extends UnitTestCase {
$this->viewStorage->expects($this->once()) $this->viewStorage->expects($this->once())
->method('load') ->method('load')
->with('test_view') ->with('test_view')
->will($this->returnValue($view)); ->willReturn($view);
$executable = $this->getMockBuilder('Drupal\views\ViewExecutable') $executable = $this->getMockBuilder('Drupal\views\ViewExecutable')
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
$executable->expects($this->once()) $executable->expects($this->once())
->method('access') ->method('access')
->will($this->returnValue(FALSE)); ->willReturn(FALSE);
$this->executableFactory->expects($this->once()) $this->executableFactory->expects($this->once())
->method('get') ->method('get')
->with($view) ->with($view)
->will($this->returnValue($executable)); ->willReturn($executable);
$this->expectException(AccessDeniedHttpException::class); $this->expectException(AccessDeniedHttpException::class);
$this->viewAjaxController->ajaxView($request); $this->viewAjaxController->ajaxView($request);
@ -336,7 +336,7 @@ class ViewAjaxControllerTest extends UnitTestCase {
$display_collection->expects($this->any()) $display_collection->expects($this->any())
->method('get') ->method('get')
->with('page_1') ->with('page_1')
->will($this->returnValue($display_handler)); ->willReturn($display_handler);
$executable->displayHandlers = $display_collection; $executable->displayHandlers = $display_collection;
$response = $this->viewAjaxController->ajaxView($request); $response = $this->viewAjaxController->ajaxView($request);
@ -367,25 +367,25 @@ class ViewAjaxControllerTest extends UnitTestCase {
$this->viewStorage->expects($this->once()) $this->viewStorage->expects($this->once())
->method('load') ->method('load')
->with('test_view') ->with('test_view')
->will($this->returnValue($view)); ->willReturn($view);
$executable = $this->getMockBuilder('Drupal\views\ViewExecutable') $executable = $this->getMockBuilder('Drupal\views\ViewExecutable')
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
$executable->expects($this->once()) $executable->expects($this->once())
->method('access') ->method('access')
->will($this->returnValue(TRUE)); ->willReturn(TRUE);
$executable->expects($this->any()) $executable->expects($this->any())
->method('setDisplay') ->method('setDisplay')
->willReturn(TRUE); ->willReturn(TRUE);
$executable->expects($this->atMost(1)) $executable->expects($this->atMost(1))
->method('preview') ->method('preview')
->will($this->returnValue(['#markup' => 'View result'])); ->willReturn(['#markup' => 'View result']);
$this->executableFactory->expects($this->once()) $this->executableFactory->expects($this->once())
->method('get') ->method('get')
->with($view) ->with($view)
->will($this->returnValue($executable)); ->willReturn($executable);
$display_handler = $this->getMockBuilder('Drupal\views\Plugin\views\display\DisplayPluginBase') $display_handler = $this->getMockBuilder('Drupal\views\Plugin\views\display\DisplayPluginBase')
->disableOriginalConstructor() ->disableOriginalConstructor()
@ -403,7 +403,7 @@ class ViewAjaxControllerTest extends UnitTestCase {
$display_collection->expects($this->any()) $display_collection->expects($this->any())
->method('get') ->method('get')
->with('page_1') ->with('page_1')
->will($this->returnValue($display_handler)); ->willReturn($display_handler);
$executable->display_handler = $display_handler; $executable->display_handler = $display_handler;
$executable->displayHandlers = $display_collection; $executable->displayHandlers = $display_collection;

View File

@ -59,7 +59,7 @@ class RouteSubscriberTest extends UnitTestCase {
$this->entityTypeManager->expects($this->any()) $this->entityTypeManager->expects($this->any())
->method('getStorage') ->method('getStorage')
->with('view') ->with('view')
->will($this->returnValue($this->viewStorage)); ->willReturn($this->viewStorage);
$this->state = $this->createMock('\Drupal\Core\State\StateInterface'); $this->state = $this->createMock('\Drupal\Core\State\StateInterface');
$this->routeSubscriber = new TestRouteSubscriber($this->entityTypeManager, $this->state); $this->routeSubscriber = new TestRouteSubscriber($this->entityTypeManager, $this->state);
} }
@ -72,10 +72,10 @@ class RouteSubscriberTest extends UnitTestCase {
$display_1->expects($this->once()) $display_1->expects($this->once())
->method('collectRoutes') ->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()) $display_2->expects($this->once())
->method('collectRoutes') ->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(); $this->routeSubscriber->routes();
@ -155,14 +155,14 @@ class RouteSubscriberTest extends UnitTestCase {
->getMock(); ->getMock();
$this->viewStorage->expects($this->any()) $this->viewStorage->expects($this->any())
->method('load') ->method('load')
->will($this->returnValue($view)); ->willReturn($view);
$view->expects($this->any()) $view->expects($this->any())
->method('getExecutable') ->method('getExecutable')
->will($this->returnValue($executable)); ->willReturn($executable);
$view->expects($this->any()) $view->expects($this->any())
->method('id') ->method('id')
->will($this->returnValue('test_id')); ->willReturn('test_id');
$executable->storage = $view; $executable->storage = $view;
$executable->expects($this->any()) $executable->expects($this->any())

View File

@ -63,7 +63,7 @@ class ViewsBlockTest extends UnitTestCase {
$condition_plugin_manager = $this->createMock('Drupal\Core\Executable\ExecutableManagerInterface'); $condition_plugin_manager = $this->createMock('Drupal\Core\Executable\ExecutableManagerInterface');
$condition_plugin_manager->expects($this->any()) $condition_plugin_manager->expects($this->any())
->method('getDefinitions') ->method('getDefinitions')
->will($this->returnValue([])); ->willReturn([]);
$container = new ContainerBuilder(); $container = new ContainerBuilder();
$container->set('plugin.manager.condition', $condition_plugin_manager); $container->set('plugin.manager.condition', $condition_plugin_manager);
\Drupal::setContainer($container); \Drupal::setContainer($container);
@ -75,7 +75,7 @@ class ViewsBlockTest extends UnitTestCase {
$this->executable->expects($this->any()) $this->executable->expects($this->any())
->method('setDisplay') ->method('setDisplay')
->with('block_1') ->with('block_1')
->will($this->returnValue(TRUE)); ->willReturn(TRUE);
$this->executable->expects($this->any()) $this->executable->expects($this->any())
->method('getShowAdminLinks') ->method('getShowAdminLinks')
->willReturn(FALSE); ->willReturn(FALSE);
@ -99,7 +99,7 @@ class ViewsBlockTest extends UnitTestCase {
$this->executableFactory->expects($this->any()) $this->executableFactory->expects($this->any())
->method('get') ->method('get')
->with($this->view) ->with($this->view)
->will($this->returnValue($this->executable)); ->willReturn($this->executable);
$this->displayHandler = $this->getMockBuilder('Drupal\views\Plugin\views\display\Block') $this->displayHandler = $this->getMockBuilder('Drupal\views\Plugin\views\display\Block')
->disableOriginalConstructor() ->disableOriginalConstructor()
@ -126,7 +126,7 @@ class ViewsBlockTest extends UnitTestCase {
$this->storage->expects($this->any()) $this->storage->expects($this->any())
->method('load') ->method('load')
->with('test_view') ->with('test_view')
->will($this->returnValue($this->view)); ->willReturn($this->view);
$this->account = $this->createMock('Drupal\Core\Session\AccountInterface'); $this->account = $this->createMock('Drupal\Core\Session\AccountInterface');
} }

View File

@ -87,7 +87,7 @@ class ViewsLocalTaskTest extends UnitTestCase {
$display_plugin->expects($this->once()) $display_plugin->expects($this->once())
->method('getOption') ->method('getOption')
->with('menu') ->with('menu')
->will($this->returnValue(['type' => 'normal'])); ->willReturn(['type' => 'normal']);
$executable->display_handler = $display_plugin; $executable->display_handler = $display_plugin;
$storage = $this->getMockBuilder('Drupal\views\Entity\View') $storage = $this->getMockBuilder('Drupal\views\Entity\View')
@ -95,7 +95,7 @@ class ViewsLocalTaskTest extends UnitTestCase {
->getMock(); ->getMock();
$storage->expects($this->any()) $storage->expects($this->any())
->method('id') ->method('id')
->will($this->returnValue('example_view')); ->willReturn('example_view');
$storage->expects($this->any()) $storage->expects($this->any())
->method('getExecutable') ->method('getExecutable')
->willReturn($executable); ->willReturn($executable);
@ -124,7 +124,7 @@ class ViewsLocalTaskTest extends UnitTestCase {
->getMock(); ->getMock();
$storage->expects($this->any()) $storage->expects($this->any())
->method('id') ->method('id')
->will($this->returnValue('example_view')); ->willReturn('example_view');
$storage->expects($this->any()) $storage->expects($this->any())
->method('getExecutable') ->method('getExecutable')
->willReturn($executable); ->willReturn($executable);
@ -142,7 +142,11 @@ class ViewsLocalTaskTest extends UnitTestCase {
$display_plugin->expects($this->once()) $display_plugin->expects($this->once())
->method('getOption') ->method('getOption')
->with('menu') ->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; $executable->display_handler = $display_plugin;
$result = [['example_view', 'page_1']]; $result = [['example_view', 'page_1']];
@ -154,7 +158,7 @@ class ViewsLocalTaskTest extends UnitTestCase {
$this->state->expects($this->once()) $this->state->expects($this->once())
->method('get') ->method('get')
->with('views.view_route_names') ->with('views.view_route_names')
->will($this->returnValue($view_route_names)); ->willReturn($view_route_names);
$definitions = $this->localTaskDerivative->getDerivativeDefinitions($this->baseDefinition); $definitions = $this->localTaskDerivative->getDerivativeDefinitions($this->baseDefinition);
$this->assertCount(1, $definitions); $this->assertCount(1, $definitions);
@ -177,7 +181,7 @@ class ViewsLocalTaskTest extends UnitTestCase {
->getMock(); ->getMock();
$storage->expects($this->any()) $storage->expects($this->any())
->method('id') ->method('id')
->will($this->returnValue('example_view')); ->willReturn('example_view');
$storage->expects($this->any()) $storage->expects($this->any())
->method('getExecutable') ->method('getExecutable')
->willReturn($executable); ->willReturn($executable);
@ -195,7 +199,7 @@ class ViewsLocalTaskTest extends UnitTestCase {
$display_plugin->expects($this->once()) $display_plugin->expects($this->once())
->method('getOption') ->method('getOption')
->with('menu') ->with('menu')
->will($this->returnValue(['type' => 'tab', 'weight' => 12])); ->willReturn(['type' => 'tab', 'weight' => 12]);
$executable->display_handler = $display_plugin; $executable->display_handler = $display_plugin;
$result = [['example_view', 'page_1']]; $result = [['example_view', 'page_1']];
@ -208,7 +212,7 @@ class ViewsLocalTaskTest extends UnitTestCase {
$this->state->expects($this->once()) $this->state->expects($this->once())
->method('get') ->method('get')
->with('views.view_route_names') ->with('views.view_route_names')
->will($this->returnValue($view_route_names)); ->willReturn($view_route_names);
$definitions = $this->localTaskDerivative->getDerivativeDefinitions($this->baseDefinition); $definitions = $this->localTaskDerivative->getDerivativeDefinitions($this->baseDefinition);
$this->assertCount(0, $definitions); $this->assertCount(0, $definitions);
@ -226,7 +230,7 @@ class ViewsLocalTaskTest extends UnitTestCase {
->getMock(); ->getMock();
$storage->expects($this->any()) $storage->expects($this->any())
->method('id') ->method('id')
->will($this->returnValue('example_view')); ->willReturn('example_view');
$storage->expects($this->any()) $storage->expects($this->any())
->method('getExecutable') ->method('getExecutable')
->willReturn($executable); ->willReturn($executable);
@ -244,7 +248,11 @@ class ViewsLocalTaskTest extends UnitTestCase {
$display_plugin->expects($this->exactly(2)) $display_plugin->expects($this->exactly(2))
->method('getOption') ->method('getOption')
->with('menu') ->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; $executable->display_handler = $display_plugin;
$result = [['example_view', 'page_1']]; $result = [['example_view', 'page_1']];
@ -256,7 +264,7 @@ class ViewsLocalTaskTest extends UnitTestCase {
$this->state->expects($this->exactly(2)) $this->state->expects($this->exactly(2))
->method('get') ->method('get')
->with('views.view_route_names') ->with('views.view_route_names')
->will($this->returnValue($view_route_names)); ->willReturn($view_route_names);
$definitions = $this->localTaskDerivative->getDerivativeDefinitions($this->baseDefinition); $definitions = $this->localTaskDerivative->getDerivativeDefinitions($this->baseDefinition);
$this->assertCount(1, $definitions); $this->assertCount(1, $definitions);
@ -295,7 +303,7 @@ class ViewsLocalTaskTest extends UnitTestCase {
->getMock(); ->getMock();
$storage->expects($this->any()) $storage->expects($this->any())
->method('id') ->method('id')
->will($this->returnValue('example_view')); ->willReturn('example_view');
$storage->expects($this->any()) $storage->expects($this->any())
->method('getExecutable') ->method('getExecutable')
->willReturn($executable); ->willReturn($executable);
@ -313,10 +321,14 @@ class ViewsLocalTaskTest extends UnitTestCase {
$display_plugin->expects($this->exactly(2)) $display_plugin->expects($this->exactly(2))
->method('getOption') ->method('getOption')
->with('menu') ->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()) $display_plugin->expects($this->once())
->method('getPath') ->method('getPath')
->will($this->returnValue('path/example')); ->willReturn('path/example');
$executable->display_handler = $display_plugin; $executable->display_handler = $display_plugin;
$result = [['example_view', 'page_1']]; $result = [['example_view', 'page_1']];
@ -328,7 +340,7 @@ class ViewsLocalTaskTest extends UnitTestCase {
$this->state->expects($this->exactly(2)) $this->state->expects($this->exactly(2))
->method('get') ->method('get')
->with('views.view_route_names') ->with('views.view_route_names')
->will($this->returnValue($view_route_names)); ->willReturn($view_route_names);
// Mock the route provider. // Mock the route provider.
$route_collection = new RouteCollection(); $route_collection = new RouteCollection();
@ -336,7 +348,7 @@ class ViewsLocalTaskTest extends UnitTestCase {
$this->routeProvider->expects($this->any()) $this->routeProvider->expects($this->any())
->method('getRoutesByPattern') ->method('getRoutesByPattern')
->with('/path') ->with('/path')
->will($this->returnValue($route_collection)); ->willReturn($route_collection);
// Setup the existing local task of the test_route. // Setup the existing local task of the test_route.
$definitions['test_route_tab'] = $other_tab = [ $definitions['test_route_tab'] = $other_tab = [

View File

@ -33,7 +33,7 @@ class RawTest extends UnitTestCase {
$current_path->setPath('/test/example', $request); $current_path->setPath('/test/example', $request);
$view->expects($this->any()) $view->expects($this->any())
->method('getRequest') ->method('getRequest')
->will($this->returnValue($request)); ->willReturn($request);
$alias_manager = $this->createMock(AliasManagerInterface::class); $alias_manager = $this->createMock(AliasManagerInterface::class);
$alias_manager->expects($this->never()) $alias_manager->expects($this->never())
->method('getAliasByPath'); ->method('getAliasByPath');
@ -76,7 +76,7 @@ class RawTest extends UnitTestCase {
$alias_manager->expects($this->any()) $alias_manager->expects($this->any())
->method('getAliasByPath') ->method('getAliasByPath')
->with($this->equalTo('/test/example')) ->with($this->equalTo('/test/example'))
->will($this->returnValue('/other/example')); ->willReturn('/other/example');
$raw = new Raw([], 'raw', [], $alias_manager, $current_path); $raw = new Raw([], 'raw', [], $alias_manager, $current_path);
$options = [ $options = [

View File

@ -60,7 +60,7 @@ class EntityTest extends UnitTestCase {
$mock_entity = $this->getMockForAbstractClass('Drupal\Core\Entity\EntityBase', [], '', FALSE, TRUE, TRUE, ['bundle', 'access']); $mock_entity = $this->getMockForAbstractClass('Drupal\Core\Entity\EntityBase', [], '', FALSE, TRUE, TRUE, ['bundle', 'access']);
$mock_entity->expects($this->any()) $mock_entity->expects($this->any())
->method('bundle') ->method('bundle')
->will($this->returnValue('test_bundle')); ->willReturn('test_bundle');
$mock_entity->expects($this->any()) $mock_entity->expects($this->any())
->method('access') ->method('access')
->willReturnMap([ ->willReturnMap([
@ -72,7 +72,7 @@ class EntityTest extends UnitTestCase {
$mock_entity_bundle_2 = $this->getMockForAbstractClass('Drupal\Core\Entity\EntityBase', [], '', FALSE, TRUE, TRUE, ['bundle', 'access']); $mock_entity_bundle_2 = $this->getMockForAbstractClass('Drupal\Core\Entity\EntityBase', [], '', FALSE, TRUE, TRUE, ['bundle', 'access']);
$mock_entity_bundle_2->expects($this->any()) $mock_entity_bundle_2->expects($this->any())
->method('bundle') ->method('bundle')
->will($this->returnValue('test_bundle_2')); ->willReturn('test_bundle_2');
$mock_entity_bundle_2->expects($this->any()) $mock_entity_bundle_2->expects($this->any())
->method('access') ->method('access')
->willReturnMap([ ->willReturnMap([
@ -100,7 +100,7 @@ class EntityTest extends UnitTestCase {
$this->entityTypeManager->expects($this->any()) $this->entityTypeManager->expects($this->any())
->method('getStorage') ->method('getStorage')
->with('entity_test') ->with('entity_test')
->will($this->returnValue($storage)); ->willReturn($storage);
$this->executable = $this->getMockBuilder('Drupal\views\ViewExecutable') $this->executable = $this->getMockBuilder('Drupal\views\ViewExecutable')
->disableOriginalConstructor() ->disableOriginalConstructor()

View File

@ -546,7 +546,7 @@ class PathPluginBaseTest extends UnitTestCase {
->getMock(); ->getMock();
$view_entity->expects($this->any()) $view_entity->expects($this->any())
->method('id') ->method('id')
->will($this->returnValue('test_id')); ->willReturn('test_id');
$view = $this->getMockBuilder('Drupal\views\ViewExecutable') $view = $this->getMockBuilder('Drupal\views\ViewExecutable')
->disableOriginalConstructor() ->disableOriginalConstructor()
@ -559,7 +559,7 @@ class PathPluginBaseTest extends UnitTestCase {
->getMockForAbstractClass(); ->getMockForAbstractClass();
$this->accessPluginManager->expects($this->any()) $this->accessPluginManager->expects($this->any())
->method('createInstance') ->method('createInstance')
->will($this->returnValue($access_plugin)); ->willReturn($access_plugin);
return [$view, $view_entity, $access_plugin]; return [$view, $view_entity, $access_plugin];
} }

View File

@ -213,7 +213,7 @@ class PagerPluginBaseTest extends UnitTestCase {
$statement->expects($this->once()) $statement->expects($this->once())
->method('fetchField') ->method('fetchField')
->will($this->returnValue(3)); ->willReturn(3);
$query = $this->getMockBuilder('\Drupal\Core\Database\Query\Select') $query = $this->getMockBuilder('\Drupal\Core\Database\Query\Select')
->disableOriginalConstructor() ->disableOriginalConstructor()
@ -221,7 +221,7 @@ class PagerPluginBaseTest extends UnitTestCase {
$query->expects($this->once()) $query->expects($this->once())
->method('execute') ->method('execute')
->will($this->returnValue($statement)); ->willReturn($statement);
$this->pager->setOffset(0); $this->pager->setOffset(0);
$this->assertEquals(3, $this->pager->executeCountQuery($query)); $this->assertEquals(3, $this->pager->executeCountQuery($query));
@ -237,7 +237,7 @@ class PagerPluginBaseTest extends UnitTestCase {
$statement->expects($this->once()) $statement->expects($this->once())
->method('fetchField') ->method('fetchField')
->will($this->returnValue(3)); ->willReturn(3);
$query = $this->getMockBuilder('\Drupal\Core\Database\Query\Select') $query = $this->getMockBuilder('\Drupal\Core\Database\Query\Select')
->disableOriginalConstructor() ->disableOriginalConstructor()
@ -245,7 +245,7 @@ class PagerPluginBaseTest extends UnitTestCase {
$query->expects($this->once()) $query->expects($this->once())
->method('execute') ->method('execute')
->will($this->returnValue($statement)); ->willReturn($statement);
$this->pager->setOffset(2); $this->pager->setOffset(2);
$this->assertEquals(1, $this->pager->executeCountQuery($query)); $this->assertEquals(1, $this->pager->executeCountQuery($query));
@ -261,7 +261,7 @@ class PagerPluginBaseTest extends UnitTestCase {
$statement->expects($this->once()) $statement->expects($this->once())
->method('fetchField') ->method('fetchField')
->will($this->returnValue(2)); ->willReturn(2);
$query = $this->getMockBuilder(Select::class) $query = $this->getMockBuilder(Select::class)
->disableOriginalConstructor() ->disableOriginalConstructor()
@ -269,7 +269,7 @@ class PagerPluginBaseTest extends UnitTestCase {
$query->expects($this->once()) $query->expects($this->once())
->method('execute') ->method('execute')
->will($this->returnValue($statement)); ->willReturn($statement);
$this->pager->setOffset(3); $this->pager->setOffset(3);
$this->assertEquals(0, $this->pager->executeCountQuery($query)); $this->assertEquals(0, $this->pager->executeCountQuery($query));

View File

@ -44,7 +44,7 @@ class BlockTest extends UnitTestCase {
$this->executable->expects($this->any()) $this->executable->expects($this->any())
->method('setDisplay') ->method('setDisplay')
->with('block_1') ->with('block_1')
->will($this->returnValue(TRUE)); ->willReturn(TRUE);
$this->blockDisplay = $this->executable->display_handler = $this->getMockBuilder('Drupal\views\Plugin\views\display\Block') $this->blockDisplay = $this->executable->display_handler = $this->getMockBuilder('Drupal\views\Plugin\views\display\Block')
->disableOriginalConstructor() ->disableOriginalConstructor()
@ -67,7 +67,7 @@ class BlockTest extends UnitTestCase {
$this->blockPlugin->expects($this->once()) $this->blockPlugin->expects($this->once())
->method('getConfiguration') ->method('getConfiguration')
->will($this->returnValue(['items_per_page' => 'none'])); ->willReturn(['items_per_page' => 'none']);
$this->blockDisplay->preBlockBuild($this->blockPlugin); $this->blockDisplay->preBlockBuild($this->blockPlugin);
} }
@ -82,7 +82,7 @@ class BlockTest extends UnitTestCase {
$this->blockPlugin->expects($this->once()) $this->blockPlugin->expects($this->once())
->method('getConfiguration') ->method('getConfiguration')
->will($this->returnValue(['items_per_page' => 5])); ->willReturn(['items_per_page' => 5]);
$this->blockDisplay->preBlockBuild($this->blockPlugin); $this->blockDisplay->preBlockBuild($this->blockPlugin);
} }

View File

@ -101,7 +101,7 @@ class EntityOperationsUnitTest extends UnitTestCase {
->getMock(); ->getMock();
$entity->expects($this->any()) $entity->expects($this->any())
->method('getEntityTypeId') ->method('getEntityTypeId')
->will($this->returnValue($entity_type_id)); ->willReturn($entity_type_id);
$operations = [ $operations = [
'foo' => [ 'foo' => [
@ -112,12 +112,12 @@ class EntityOperationsUnitTest extends UnitTestCase {
$list_builder->expects($this->once()) $list_builder->expects($this->once())
->method('getOperations') ->method('getOperations')
->with($entity) ->with($entity)
->will($this->returnValue($operations)); ->willReturn($operations);
$this->entityTypeManager->expects($this->once()) $this->entityTypeManager->expects($this->once())
->method('getListBuilder') ->method('getListBuilder')
->with($entity_type_id) ->with($entity_type_id)
->will($this->returnValue($list_builder)); ->willReturn($list_builder);
$this->plugin->options['destination'] = TRUE; $this->plugin->options['destination'] = TRUE;
@ -143,7 +143,7 @@ class EntityOperationsUnitTest extends UnitTestCase {
->getMock(); ->getMock();
$entity->expects($this->any()) $entity->expects($this->any())
->method('getEntityTypeId') ->method('getEntityTypeId')
->will($this->returnValue($entity_type_id)); ->willReturn($entity_type_id);
$operations = [ $operations = [
'foo' => [ 'foo' => [
@ -154,12 +154,12 @@ class EntityOperationsUnitTest extends UnitTestCase {
$list_builder->expects($this->once()) $list_builder->expects($this->once())
->method('getOperations') ->method('getOperations')
->with($entity) ->with($entity)
->will($this->returnValue($operations)); ->willReturn($operations);
$this->entityTypeManager->expects($this->once()) $this->entityTypeManager->expects($this->once())
->method('getListBuilder') ->method('getListBuilder')
->with($entity_type_id) ->with($entity_type_id)
->will($this->returnValue($list_builder)); ->willReturn($list_builder);
$this->plugin->options['destination'] = FALSE; $this->plugin->options['destination'] = FALSE;

View File

@ -44,7 +44,7 @@ class ViewsDataHelperTest extends UnitTestCase {
->getMock(); ->getMock();
$views_data->expects($this->once()) $views_data->expects($this->once())
->method('getAll') ->method('getAll')
->will($this->returnValue($this->viewsData())); ->willReturn($this->viewsData());
$data_helper = new ViewsDataHelper($views_data); $data_helper = new ViewsDataHelper($views_data);

View File

@ -70,7 +70,7 @@ class ViewsDataTest extends UnitTestCase {
$this->languageManager = $this->createMock('Drupal\Core\Language\LanguageManagerInterface'); $this->languageManager = $this->createMock('Drupal\Core\Language\LanguageManagerInterface');
$this->languageManager->expects($this->any()) $this->languageManager->expects($this->any())
->method('getCurrentLanguage') ->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); $this->viewsData = new ViewsData($this->cacheBackend, $this->configFactory, $this->moduleHandler, $this->languageManager);
} }
@ -192,7 +192,7 @@ class ViewsDataTest extends UnitTestCase {
$this->cacheBackend->expects($this->once()) $this->cacheBackend->expects($this->once())
->method('get') ->method('get')
->with("views_data:en") ->with("views_data:en")
->will($this->returnValue(FALSE)); ->willReturn(FALSE);
$expected_views_data = $this->viewsDataWithProvider(); $expected_views_data = $this->viewsDataWithProvider();
$views_data = $this->viewsData->getAll(); $views_data = $this->viewsData->getAll();
@ -281,7 +281,7 @@ class ViewsDataTest extends UnitTestCase {
$this->cacheBackend->expects($this->once()) $this->cacheBackend->expects($this->once())
->method('get') ->method('get')
->with("views_data:en") ->with("views_data:en")
->will($this->returnValue(FALSE)); ->willReturn(FALSE);
$views_data = $this->viewsData->getAll(); $views_data = $this->viewsData->getAll();
$this->assertSame($expected_views_data, $views_data); $this->assertSame($expected_views_data, $views_data);
@ -404,7 +404,7 @@ class ViewsDataTest extends UnitTestCase {
$this->cacheBackend->expects($this->once()) $this->cacheBackend->expects($this->once())
->method('get') ->method('get')
->with('views_data:views_test_data:en') ->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()) $this->cacheBackend->expects($this->never())
->method('set'); ->method('set');
@ -512,7 +512,7 @@ class ViewsDataTest extends UnitTestCase {
$this->cacheBackend->expects($this->once()) $this->cacheBackend->expects($this->once())
->method('get') ->method('get')
->with("views_data:$non_existing_table:en") ->with("views_data:$non_existing_table:en")
->will($this->returnValue((object) ['data' => []])); ->willReturn((object) ['data' => []]);
$this->cacheBackend->expects($this->never()) $this->cacheBackend->expects($this->never())
->method('set'); ->method('set');
@ -565,7 +565,7 @@ class ViewsDataTest extends UnitTestCase {
$this->cacheBackend->expects($this->once()) $this->cacheBackend->expects($this->once())
->method('get') ->method('get')
->with("views_data:en") ->with("views_data:en")
->will($this->returnValue((object) ['data' => $expected_views_data])); ->willReturn((object) ['data' => $expected_views_data]);
$this->cacheBackend->expects($this->never()) $this->cacheBackend->expects($this->never())
->method('set'); ->method('set');

View File

@ -58,13 +58,13 @@ class ViewsTest extends UnitTestCase {
$view_storage->expects($this->once()) $view_storage->expects($this->once())
->method('load') ->method('load')
->with('test_view') ->with('test_view')
->will($this->returnValue($view)); ->willReturn($view);
$entity_type_manager = $this->createMock('Drupal\Core\Entity\EntityTypeManagerInterface'); $entity_type_manager = $this->createMock('Drupal\Core\Entity\EntityTypeManagerInterface');
$entity_type_manager->expects($this->once()) $entity_type_manager->expects($this->once())
->method('getStorage') ->method('getStorage')
->with('view') ->with('view')
->will($this->returnValue($view_storage)); ->willReturn($view_storage);
$this->container->set('entity_type.manager', $entity_type_manager); $this->container->set('entity_type.manager', $entity_type_manager);
$executable = Views::getView('test_view'); $executable = Views::getView('test_view');
@ -168,13 +168,17 @@ class ViewsTest extends UnitTestCase {
$view_storage->expects($this->once()) $view_storage->expects($this->once())
->method('loadMultiple') ->method('loadMultiple')
->with(['test_view_1', 'test_view_2', 'test_view_3']) ->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 = $this->createMock(EntityTypeManagerInterface::class);
$entity_type_manager->expects($this->exactly(2)) $entity_type_manager->expects($this->exactly(2))
->method('getStorage') ->method('getStorage')
->with('view') ->with('view')
->will($this->returnValue($view_storage)); ->willReturn($view_storage);
$this->container->set('entity_type.manager', $entity_type_manager); $this->container->set('entity_type.manager', $entity_type_manager);
$definitions = [ $definitions = [

View File

@ -90,10 +90,11 @@ class ViewListBuilderTest extends UnitTestCase {
->getMock(); ->getMock();
$page_display->expects($this->any()) $page_display->expects($this->any())
->method('getPath') ->method('getPath')
->will($this->onConsecutiveCalls( ->willReturnOnConsecutiveCalls(
$this->returnValue('test_page'), 'test_page',
$this->returnValue('<object>malformed_path</object>'), '<object>malformed_path</object>',
$this->returnValue('<script>alert("placeholder_page/%")</script>'))); '<script>alert("placeholder_page/%")</script>',
);
$embed_display = $this->getMockBuilder('Drupal\views\Plugin\views\display\Embed') $embed_display = $this->getMockBuilder('Drupal\views\Plugin\views\display\Embed')
->onlyMethods(['initDisplay']) ->onlyMethods(['initDisplay'])

View File

@ -85,7 +85,7 @@ class ViewUIObjectTest extends UnitTestCase {
$account = $this->createMock('Drupal\Core\Session\AccountInterface'); $account = $this->createMock('Drupal\Core\Session\AccountInterface');
$account->expects($this->exactly(2)) $account->expects($this->exactly(2))
->method('id') ->method('id')
->will($this->returnValue(1)); ->willReturn(1);
$container = new ContainerBuilder(); $container = new ContainerBuilder();
$container->set('current_user', $account); $container->set('current_user', $account);

View File

@ -82,7 +82,7 @@ class ExportStorageManagerTest extends KernelTestBase {
$lock->expects($this->exactly(2)) $lock->expects($this->exactly(2))
->method('acquire') ->method('acquire')
->with(ExportStorageManager::LOCK_NAME) ->with(ExportStorageManager::LOCK_NAME)
->will($this->returnValue(FALSE)); ->willReturn(FALSE);
$lock->expects($this->once()) $lock->expects($this->once())
->method('wait') ->method('wait')
->with(ExportStorageManager::LOCK_NAME); ->with(ExportStorageManager::LOCK_NAME);

View File

@ -69,7 +69,7 @@ class ImportStorageTransformerTest extends KernelTestBase {
$lock->expects($this->exactly(2)) $lock->expects($this->exactly(2))
->method('acquire') ->method('acquire')
->with(ImportStorageTransformer::LOCK_NAME) ->with(ImportStorageTransformer::LOCK_NAME)
->will($this->returnValue(FALSE)); ->willReturn(FALSE);
$lock->expects($this->once()) $lock->expects($this->once())
->method('wait') ->method('wait')
->with(ImportStorageTransformer::LOCK_NAME); ->with(ImportStorageTransformer::LOCK_NAME);
@ -100,7 +100,7 @@ class ImportStorageTransformerTest extends KernelTestBase {
$lock->expects($this->once()) $lock->expects($this->once())
->method('lockMayBeAvailable') ->method('lockMayBeAvailable')
->with(ConfigImporter::LOCK_NAME) ->with(ConfigImporter::LOCK_NAME)
->will($this->returnValue(FALSE)); ->willReturn(FALSE);
// The import transformer under test. // The import transformer under test.
$transformer = new ImportStorageTransformer( $transformer = new ImportStorageTransformer(

View File

@ -163,7 +163,7 @@ class LoggingTest extends DatabaseTestBase {
->getMock(); ->getMock();
$log->expects($this->once()) $log->expects($this->once())
->method('getDebugBacktrace') ->method('getDebugBacktrace')
->will($this->returnValue($stack)); ->willReturn($stack);
Database::addConnectionInfo('test', 'default', ['driver' => 'mysql', 'namespace' => $driver_namespace]); Database::addConnectionInfo('test', 'default', ['driver' => 'mysql', 'namespace' => $driver_namespace]);
$result = $log->findCaller($stack); $result = $log->findCaller($stack);

View File

@ -363,7 +363,7 @@ class AccessManagerTest extends UnitTestCase {
$this->routeProvider->expects($this->any()) $this->routeProvider->expects($this->any())
->method('getRouteByName') ->method('getRouteByName')
->with('test_route_1') ->with('test_route_1')
->will($this->returnValue($route)); ->willReturn($route);
$map[] = ['test_route_1', ['value' => 'example'], '/test-route-1/example']; $map[] = ['test_route_1', ['value' => 'example'], '/test-route-1/example'];
@ -371,7 +371,7 @@ class AccessManagerTest extends UnitTestCase {
$this->paramConverter->expects($this->atLeastOnce()) $this->paramConverter->expects($this->atLeastOnce())
->method('convert') ->method('convert')
->with(['value' => 'example', RouteObjectInterface::ROUTE_NAME => 'test_route_1', RouteObjectInterface::ROUTE_OBJECT => $route]) ->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)) $this->setupAccessArgumentsResolverFactory($this->exactly(2))
->with($this->callback(function ($route_match) { ->with($this->callback(function ($route_match) {
@ -383,10 +383,10 @@ class AccessManagerTest extends UnitTestCase {
$access_check = $this->createMock('Drupal\Tests\Core\Access\TestAccessCheckInterface'); $access_check = $this->createMock('Drupal\Tests\Core\Access\TestAccessCheckInterface');
$access_check->expects($this->atLeastOnce()) $access_check->expects($this->atLeastOnce())
->method('applies') ->method('applies')
->will($this->returnValue(TRUE)); ->willReturn(TRUE);
$access_check->expects($this->atLeastOnce()) $access_check->expects($this->atLeastOnce())
->method('access') ->method('access')
->will($this->returnValue(AccessResult::forbidden())); ->willReturn(AccessResult::forbidden());
$this->container->set('test_access', $access_check); $this->container->set('test_access', $access_check);
$this->container->setParameter('dynamic_access_check_services', ['test_access']); $this->container->setParameter('dynamic_access_check_services', ['test_access']);
@ -412,7 +412,7 @@ class AccessManagerTest extends UnitTestCase {
$this->routeProvider->expects($this->any()) $this->routeProvider->expects($this->any())
->method('getRouteByName') ->method('getRouteByName')
->with('test_route_1') ->with('test_route_1')
->will($this->returnValue($route)); ->willReturn($route);
$map[] = ['test_route_1', ['value' => 'example'], '/test-route-1/example']; $map[] = ['test_route_1', ['value' => 'example'], '/test-route-1/example'];
@ -420,7 +420,7 @@ class AccessManagerTest extends UnitTestCase {
$this->paramConverter->expects($this->atLeastOnce()) $this->paramConverter->expects($this->atLeastOnce())
->method('convert') ->method('convert')
->with(['value' => 'example', RouteObjectInterface::ROUTE_NAME => 'test_route_1', RouteObjectInterface::ROUTE_OBJECT => $route]) ->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)) $this->setupAccessArgumentsResolverFactory($this->exactly(2))
->with($this->callback(function ($route_match) { ->with($this->callback(function ($route_match) {
@ -432,10 +432,10 @@ class AccessManagerTest extends UnitTestCase {
$access_check = $this->createMock('Drupal\Tests\Core\Access\TestAccessCheckInterface'); $access_check = $this->createMock('Drupal\Tests\Core\Access\TestAccessCheckInterface');
$access_check->expects($this->atLeastOnce()) $access_check->expects($this->atLeastOnce())
->method('applies') ->method('applies')
->will($this->returnValue(TRUE)); ->willReturn(TRUE);
$access_check->expects($this->atLeastOnce()) $access_check->expects($this->atLeastOnce())
->method('access') ->method('access')
->will($this->returnValue(AccessResult::forbidden())); ->willReturn(AccessResult::forbidden());
$this->container->set('test_access', $access_check); $this->container->set('test_access', $access_check);
$this->container->setParameter('dynamic_access_check_services', ['test_access']); $this->container->setParameter('dynamic_access_check_services', ['test_access']);
@ -482,12 +482,12 @@ class AccessManagerTest extends UnitTestCase {
$route_provider->expects($this->any()) $route_provider->expects($this->any())
->method('getRouteByName') ->method('getRouteByName')
->will($this->returnValue($route)); ->willReturn($route);
$this->paramConverter = $this->createMock('Drupal\Core\ParamConverter\ParamConverterManagerInterface'); $this->paramConverter = $this->createMock('Drupal\Core\ParamConverter\ParamConverterManagerInterface');
$this->paramConverter->expects($this->any()) $this->paramConverter->expects($this->any())
->method('convert') ->method('convert')
->will($this->returnValue([])); ->willReturn([]);
$this->setupAccessArgumentsResolverFactory(); $this->setupAccessArgumentsResolverFactory();
@ -497,7 +497,7 @@ class AccessManagerTest extends UnitTestCase {
$access_check = $this->createMock('Drupal\Tests\Core\Access\TestAccessCheckInterface'); $access_check = $this->createMock('Drupal\Tests\Core\Access\TestAccessCheckInterface');
$access_check->expects($this->any()) $access_check->expects($this->any())
->method('access') ->method('access')
->will($this->returnValue($return_value)); ->willReturn($return_value);
$container->set('test_incorrect_value', $access_check); $container->set('test_incorrect_value', $access_check);
$access_manager = new AccessManager($route_provider, $this->paramConverter, $this->argumentsResolverFactory, $this->currentUser, $this->checkProvider); $access_manager = new AccessManager($route_provider, $this->paramConverter, $this->argumentsResolverFactory, $this->currentUser, $this->checkProvider);

View File

@ -462,7 +462,7 @@ class AccessResultTest extends UnitTestCase {
$account->expects($this->any()) $account->expects($this->any())
->method('hasPermission') ->method('hasPermission')
->with('may herd llamas') ->with('may herd llamas')
->will($this->returnValue(FALSE)); ->willReturn(FALSE);
$contexts = ['user.permissions']; $contexts = ['user.permissions'];
// Verify the object when using the ::allowedIfHasPermission() convenience // Verify the object when using the ::allowedIfHasPermission() convenience
@ -514,7 +514,7 @@ class AccessResultTest extends UnitTestCase {
$node = $this->createMock('\Drupal\node\NodeInterface'); $node = $this->createMock('\Drupal\node\NodeInterface');
$node->expects($this->any()) $node->expects($this->any())
->method('getCacheTags') ->method('getCacheTags')
->will($this->returnValue(['node:20011988'])); ->willReturn(['node:20011988']);
$node->expects($this->any()) $node->expects($this->any())
->method('getCacheMaxAge') ->method('getCacheMaxAge')
->willReturn(600); ->willReturn(600);

View File

@ -55,11 +55,11 @@ class CsrfAccessCheckTest extends UnitTestCase {
$this->csrfToken->expects($this->once()) $this->csrfToken->expects($this->once())
->method('validate') ->method('validate')
->with('test_query', 'test-path/42') ->with('test_query', 'test-path/42')
->will($this->returnValue(TRUE)); ->willReturn(TRUE);
$this->routeMatch->expects($this->once()) $this->routeMatch->expects($this->once())
->method('getRawParameters') ->method('getRawParameters')
->will($this->returnValue(['node' => 42])); ->willReturn(['node' => 42]);
$route = new Route('/test-path/{node}', [], ['_csrf_token' => 'TRUE']); $route = new Route('/test-path/{node}', [], ['_csrf_token' => 'TRUE']);
$request = Request::create('/test-path/42?token=test_query'); $request = Request::create('/test-path/42?token=test_query');
@ -74,11 +74,11 @@ class CsrfAccessCheckTest extends UnitTestCase {
$this->csrfToken->expects($this->once()) $this->csrfToken->expects($this->once())
->method('validate') ->method('validate')
->with('test_query', 'test-path') ->with('test_query', 'test-path')
->will($this->returnValue(FALSE)); ->willReturn(FALSE);
$this->routeMatch->expects($this->once()) $this->routeMatch->expects($this->once())
->method('getRawParameters') ->method('getRawParameters')
->will($this->returnValue([])); ->willReturn([]);
$route = new Route('/test-path', [], ['_csrf_token' => 'TRUE']); $route = new Route('/test-path', [], ['_csrf_token' => 'TRUE']);
$request = Request::create('/test-path?token=test_query'); $request = Request::create('/test-path?token=test_query');
@ -93,11 +93,11 @@ class CsrfAccessCheckTest extends UnitTestCase {
$this->csrfToken->expects($this->once()) $this->csrfToken->expects($this->once())
->method('validate') ->method('validate')
->with('', 'test-path') ->with('', 'test-path')
->will($this->returnValue(FALSE)); ->willReturn(FALSE);
$this->routeMatch->expects($this->once()) $this->routeMatch->expects($this->once())
->method('getRawParameters') ->method('getRawParameters')
->will($this->returnValue([])); ->willReturn([]);
$route = new Route('/test-path', [], ['_csrf_token' => 'TRUE']); $route = new Route('/test-path', [], ['_csrf_token' => 'TRUE']);
$request = Request::create('/test-path'); $request = Request::create('/test-path');

View File

@ -67,12 +67,12 @@ class CsrfTokenGeneratorTest extends UnitTestCase {
$key = Crypt::randomBytesBase64(); $key = Crypt::randomBytesBase64();
$this->privateKey->expects($this->any()) $this->privateKey->expects($this->any())
->method('get') ->method('get')
->will($this->returnValue($key)); ->willReturn($key);
$seed = Crypt::randomBytesBase64(); $seed = Crypt::randomBytesBase64();
$this->sessionMetadata->expects($this->any()) $this->sessionMetadata->expects($this->any())
->method('getCsrfTokenSeed') ->method('getCsrfTokenSeed')
->will($this->returnValue($seed)); ->willReturn($seed);
} }
/** /**
@ -97,11 +97,11 @@ class CsrfTokenGeneratorTest extends UnitTestCase {
$key = Crypt::randomBytesBase64(); $key = Crypt::randomBytesBase64();
$this->privateKey->expects($this->any()) $this->privateKey->expects($this->any())
->method('get') ->method('get')
->will($this->returnValue($key)); ->willReturn($key);
$this->sessionMetadata->expects($this->once()) $this->sessionMetadata->expects($this->once())
->method('getCsrfTokenSeed') ->method('getCsrfTokenSeed')
->will($this->returnValue(NULL)); ->willReturn(NULL);
$this->sessionMetadata->expects($this->once()) $this->sessionMetadata->expects($this->once())
->method('setCsrfTokenSeed') ->method('setCsrfTokenSeed')

View File

@ -72,15 +72,15 @@ class CustomAccessCheckTest extends UnitTestCase {
$resolver0 = $this->createMock('Drupal\Component\Utility\ArgumentsResolverInterface'); $resolver0 = $this->createMock('Drupal\Component\Utility\ArgumentsResolverInterface');
$resolver0->expects($this->once()) $resolver0->expects($this->once())
->method('getArguments') ->method('getArguments')
->will($this->returnValue([])); ->willReturn([]);
$resolver1 = $this->createMock('Drupal\Component\Utility\ArgumentsResolverInterface'); $resolver1 = $this->createMock('Drupal\Component\Utility\ArgumentsResolverInterface');
$resolver1->expects($this->once()) $resolver1->expects($this->once())
->method('getArguments') ->method('getArguments')
->will($this->returnValue([])); ->willReturn([]);
$resolver2 = $this->createMock('Drupal\Component\Utility\ArgumentsResolverInterface'); $resolver2 = $this->createMock('Drupal\Component\Utility\ArgumentsResolverInterface');
$resolver2->expects($this->once()) $resolver2->expects($this->once())
->method('getArguments') ->method('getArguments')
->will($this->returnValue(['parameter' => 'TRUE'])); ->willReturn(['parameter' => 'TRUE']);
$this->argumentsResolverFactory->expects($this->exactly(3)) $this->argumentsResolverFactory->expects($this->exactly(3))
->method('getArgumentsResolver') ->method('getArgumentsResolver')

View File

@ -39,15 +39,15 @@ class AjaxResponseTest extends UnitTestCase {
$command_one = $this->createMock('Drupal\Core\Ajax\CommandInterface'); $command_one = $this->createMock('Drupal\Core\Ajax\CommandInterface');
$command_one->expects($this->once()) $command_one->expects($this->once())
->method('render') ->method('render')
->will($this->returnValue(['command' => 'one'])); ->willReturn(['command' => 'one']);
$command_two = $this->createMock('Drupal\Core\Ajax\CommandInterface'); $command_two = $this->createMock('Drupal\Core\Ajax\CommandInterface');
$command_two->expects($this->once()) $command_two->expects($this->once())
->method('render') ->method('render')
->will($this->returnValue(['command' => 'two'])); ->willReturn(['command' => 'two']);
$command_three = $this->createMock('Drupal\Core\Ajax\CommandInterface'); $command_three = $this->createMock('Drupal\Core\Ajax\CommandInterface');
$command_three->expects($this->once()) $command_three->expects($this->once())
->method('render') ->method('render')
->will($this->returnValue(['command' => 'three'])); ->willReturn(['command' => 'three']);
$this->ajaxResponse->addCommand($command_one); $this->ajaxResponse->addCommand($command_one);
$this->ajaxResponse->addCommand($command_two); $this->ajaxResponse->addCommand($command_two);

View File

@ -60,7 +60,7 @@ class LibraryDependencyResolverTest extends UnitTestCase {
$this->libraryDiscovery->expects($this->any()) $this->libraryDiscovery->expects($this->any())
->method('getLibrariesByExtension') ->method('getLibrariesByExtension')
->with('test') ->with('test')
->will($this->returnValue($this->libraryData)); ->willReturn($this->libraryData);
$this->libraryDependencyResolver = new LibraryDependencyResolver($this->libraryDiscovery); $this->libraryDependencyResolver = new LibraryDependencyResolver($this->libraryDiscovery);
} }

View File

@ -150,7 +150,7 @@ class LibraryDiscoveryCollectorTest extends UnitTestCase {
$this->lock->expects($this->once()) $this->lock->expects($this->once())
->method('acquire') ->method('acquire')
->with($lock_key) ->with($lock_key)
->will($this->returnValue(TRUE)); ->willReturn(TRUE);
$this->cache->expects($this->exactly(2)) $this->cache->expects($this->exactly(2))
->method('get') ->method('get')
->with('library_info:kitten_theme') ->with('library_info:kitten_theme')

View File

@ -119,7 +119,7 @@ class LibraryDiscoveryParserTest extends UnitTestCase {
$this->moduleHandler->expects($this->atLeastOnce()) $this->moduleHandler->expects($this->atLeastOnce())
->method('moduleExists') ->method('moduleExists')
->with('example_module') ->with('example_module')
->will($this->returnValue(TRUE)); ->willReturn(TRUE);
$path = __DIR__ . '/library_test_files'; $path = __DIR__ . '/library_test_files';
$path = substr($path, strlen($this->root) + 1); $path = substr($path, strlen($this->root) + 1);
@ -149,7 +149,7 @@ class LibraryDiscoveryParserTest extends UnitTestCase {
$this->moduleHandler->expects($this->atLeastOnce()) $this->moduleHandler->expects($this->atLeastOnce())
->method('moduleExists') ->method('moduleExists')
->with('example_theme') ->with('example_theme')
->will($this->returnValue(FALSE)); ->willReturn(FALSE);
$path = __DIR__ . '/library_test_files'; $path = __DIR__ . '/library_test_files';
$path = substr($path, strlen($this->root) + 1); $path = substr($path, strlen($this->root) + 1);
@ -176,7 +176,7 @@ class LibraryDiscoveryParserTest extends UnitTestCase {
$this->moduleHandler->expects($this->atLeastOnce()) $this->moduleHandler->expects($this->atLeastOnce())
->method('moduleExists') ->method('moduleExists')
->with('example_module') ->with('example_module')
->will($this->returnValue(TRUE)); ->willReturn(TRUE);
$path = __DIR__ . '/library_test_files_not_existing'; $path = __DIR__ . '/library_test_files_not_existing';
$path = substr($path, strlen($this->root) + 1); $path = substr($path, strlen($this->root) + 1);
@ -197,7 +197,7 @@ class LibraryDiscoveryParserTest extends UnitTestCase {
$this->moduleHandler->expects($this->atLeastOnce()) $this->moduleHandler->expects($this->atLeastOnce())
->method('moduleExists') ->method('moduleExists')
->with('invalid_file') ->with('invalid_file')
->will($this->returnValue(TRUE)); ->willReturn(TRUE);
$path = __DIR__ . '/library_test_files'; $path = __DIR__ . '/library_test_files';
$path = substr($path, strlen($this->root) + 1); $path = substr($path, strlen($this->root) + 1);
@ -219,7 +219,7 @@ class LibraryDiscoveryParserTest extends UnitTestCase {
$this->moduleHandler->expects($this->atLeastOnce()) $this->moduleHandler->expects($this->atLeastOnce())
->method('moduleExists') ->method('moduleExists')
->with('example_module_only_dependencies') ->with('example_module_only_dependencies')
->will($this->returnValue(TRUE)); ->willReturn(TRUE);
$path = __DIR__ . '/library_test_files'; $path = __DIR__ . '/library_test_files';
$path = substr($path, strlen($this->root) + 1); $path = substr($path, strlen($this->root) + 1);
@ -241,7 +241,7 @@ class LibraryDiscoveryParserTest extends UnitTestCase {
$this->moduleHandler->expects($this->atLeastOnce()) $this->moduleHandler->expects($this->atLeastOnce())
->method('moduleExists') ->method('moduleExists')
->with('example_module_missing_information') ->with('example_module_missing_information')
->will($this->returnValue(TRUE)); ->willReturn(TRUE);
$path = __DIR__ . '/library_test_files'; $path = __DIR__ . '/library_test_files';
$path = substr($path, strlen($this->root) + 1); $path = substr($path, strlen($this->root) + 1);
@ -264,7 +264,7 @@ class LibraryDiscoveryParserTest extends UnitTestCase {
$this->moduleHandler->expects($this->atLeastOnce()) $this->moduleHandler->expects($this->atLeastOnce())
->method('moduleExists') ->method('moduleExists')
->with('versions') ->with('versions')
->will($this->returnValue(TRUE)); ->willReturn(TRUE);
$path = __DIR__ . '/library_test_files'; $path = __DIR__ . '/library_test_files';
$path = substr($path, strlen($this->root) + 1); $path = substr($path, strlen($this->root) + 1);
@ -297,7 +297,7 @@ class LibraryDiscoveryParserTest extends UnitTestCase {
$this->moduleHandler->expects($this->atLeastOnce()) $this->moduleHandler->expects($this->atLeastOnce())
->method('moduleExists') ->method('moduleExists')
->with('external') ->with('external')
->will($this->returnValue(TRUE)); ->willReturn(TRUE);
$path = __DIR__ . '/library_test_files'; $path = __DIR__ . '/library_test_files';
$path = substr($path, strlen($this->root) + 1); $path = substr($path, strlen($this->root) + 1);
@ -323,7 +323,7 @@ class LibraryDiscoveryParserTest extends UnitTestCase {
$this->moduleHandler->expects($this->atLeastOnce()) $this->moduleHandler->expects($this->atLeastOnce())
->method('moduleExists') ->method('moduleExists')
->with('css_weights') ->with('css_weights')
->will($this->returnValue(TRUE)); ->willReturn(TRUE);
$path = __DIR__ . '/library_test_files'; $path = __DIR__ . '/library_test_files';
$path = substr($path, strlen($this->root) + 1); $path = substr($path, strlen($this->root) + 1);
@ -364,7 +364,7 @@ class LibraryDiscoveryParserTest extends UnitTestCase {
$this->moduleHandler->expects($this->atLeastOnce()) $this->moduleHandler->expects($this->atLeastOnce())
->method('moduleExists') ->method('moduleExists')
->with('js_positive_weight') ->with('js_positive_weight')
->will($this->returnValue(TRUE)); ->willReturn(TRUE);
$path = __DIR__ . '/library_test_files'; $path = __DIR__ . '/library_test_files';
$path = substr($path, strlen($this->root) + 1); $path = substr($path, strlen($this->root) + 1);
@ -386,7 +386,7 @@ class LibraryDiscoveryParserTest extends UnitTestCase {
$this->moduleHandler->expects($this->atLeastOnce()) $this->moduleHandler->expects($this->atLeastOnce())
->method('moduleExists') ->method('moduleExists')
->with('css_js_settings') ->with('css_js_settings')
->will($this->returnValue(TRUE)); ->willReturn(TRUE);
$path = __DIR__ . '/library_test_files'; $path = __DIR__ . '/library_test_files';
$path = substr($path, strlen($this->root) + 1); $path = substr($path, strlen($this->root) + 1);
@ -419,7 +419,7 @@ class LibraryDiscoveryParserTest extends UnitTestCase {
$this->moduleHandler->expects($this->atLeastOnce()) $this->moduleHandler->expects($this->atLeastOnce())
->method('moduleExists') ->method('moduleExists')
->with('dependencies') ->with('dependencies')
->will($this->returnValue(TRUE)); ->willReturn(TRUE);
$path = __DIR__ . '/library_test_files'; $path = __DIR__ . '/library_test_files';
$path = substr($path, strlen($this->root) + 1); $path = substr($path, strlen($this->root) + 1);
@ -445,10 +445,10 @@ class LibraryDiscoveryParserTest extends UnitTestCase {
$this->moduleHandler->expects($this->atLeastOnce()) $this->moduleHandler->expects($this->atLeastOnce())
->method('moduleExists') ->method('moduleExists')
->with('data_types') ->with('data_types')
->will($this->returnValue(TRUE)); ->willReturn(TRUE);
$this->streamWrapperManager->expects($this->atLeastOnce()) $this->streamWrapperManager->expects($this->atLeastOnce())
->method('isValidUri') ->method('isValidUri')
->will($this->returnValue(TRUE)); ->willReturn(TRUE);
$path = __DIR__ . '/library_test_files'; $path = __DIR__ . '/library_test_files';
$path = substr($path, strlen($this->root) + 1); $path = substr($path, strlen($this->root) + 1);
@ -483,7 +483,7 @@ class LibraryDiscoveryParserTest extends UnitTestCase {
$this->moduleHandler->expects($this->atLeastOnce()) $this->moduleHandler->expects($this->atLeastOnce())
->method('moduleExists') ->method('moduleExists')
->with('js') ->with('js')
->will($this->returnValue(TRUE)); ->willReturn(TRUE);
$path = __DIR__ . '/library_test_files'; $path = __DIR__ . '/library_test_files';
$path = substr($path, strlen($this->root) + 1); $path = substr($path, strlen($this->root) + 1);
@ -509,7 +509,7 @@ class LibraryDiscoveryParserTest extends UnitTestCase {
$this->moduleHandler->expects($this->atLeastOnce()) $this->moduleHandler->expects($this->atLeastOnce())
->method('moduleExists') ->method('moduleExists')
->with('licenses_missing_information') ->with('licenses_missing_information')
->will($this->returnValue(TRUE)); ->willReturn(TRUE);
$path = __DIR__ . '/library_test_files'; $path = __DIR__ . '/library_test_files';
$path = substr($path, strlen($this->root) + 1); $path = substr($path, strlen($this->root) + 1);
@ -532,7 +532,7 @@ class LibraryDiscoveryParserTest extends UnitTestCase {
$this->moduleHandler->expects($this->atLeastOnce()) $this->moduleHandler->expects($this->atLeastOnce())
->method('moduleExists') ->method('moduleExists')
->with('licenses') ->with('licenses')
->will($this->returnValue(TRUE)); ->willReturn(TRUE);
$path = __DIR__ . '/library_test_files'; $path = __DIR__ . '/library_test_files';
$path = substr($path, strlen($this->root) + 1); $path = substr($path, strlen($this->root) + 1);
@ -651,7 +651,7 @@ class LibraryDiscoveryParserTest extends UnitTestCase {
$this->moduleHandler->expects($this->atLeastOnce()) $this->moduleHandler->expects($this->atLeastOnce())
->method('moduleExists') ->method('moduleExists')
->with('example_module') ->with('example_module')
->will($this->returnValue(TRUE)); ->willReturn(TRUE);
$libraries = $this->libraryDiscoveryParser->buildByExtension('example_module'); $libraries = $this->libraryDiscoveryParser->buildByExtension('example_module');
$library = $libraries['example']; $library = $libraries['example'];
@ -704,7 +704,7 @@ class LibraryDiscoveryParserTest extends UnitTestCase {
$this->moduleHandler->expects($this->atLeastOnce()) $this->moduleHandler->expects($this->atLeastOnce())
->method('moduleExists') ->method('moduleExists')
->with('deprecated') ->with('deprecated')
->will($this->returnValue(TRUE)); ->willReturn(TRUE);
$this->libraryDiscoveryParser->buildByExtension('deprecated'); $this->libraryDiscoveryParser->buildByExtension('deprecated');
} }
@ -729,7 +729,7 @@ class LibraryDiscoveryParserTest extends UnitTestCase {
$this->moduleHandler->expects($this->atLeastOnce()) $this->moduleHandler->expects($this->atLeastOnce())
->method('moduleExists') ->method('moduleExists')
->with($extension) ->with($extension)
->will($this->returnValue(TRUE)); ->willReturn(TRUE);
$path = __DIR__ . '/library_test_files'; $path = __DIR__ . '/library_test_files';
$path = substr($path, strlen($this->root) + 1); $path = substr($path, strlen($this->root) + 1);
@ -761,7 +761,7 @@ class LibraryDiscoveryParserTest extends UnitTestCase {
$this->moduleHandler->expects($this->atLeastOnce()) $this->moduleHandler->expects($this->atLeastOnce())
->method('moduleExists') ->method('moduleExists')
->with('example_contrib_module') ->with('example_contrib_module')
->will($this->returnValue(TRUE)); ->willReturn(TRUE);
$path = __DIR__ . '/library_test_files'; $path = __DIR__ . '/library_test_files';
$path = substr($path, strlen($this->root) + 1); $path = substr($path, strlen($this->root) + 1);
@ -773,7 +773,7 @@ class LibraryDiscoveryParserTest extends UnitTestCase {
$this->librariesDirectoryFileFinder->expects($this->once()) $this->librariesDirectoryFileFinder->expects($this->once())
->method('find') ->method('find')
->with('third_party_library/css/example.css') ->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'); $libraries = $this->libraryDiscoveryParser->buildByExtension('example_contrib_module');
$library = $libraries['third_party_library']; $library = $libraries['third_party_library'];
@ -792,7 +792,7 @@ class LibraryDiscoveryParserTest extends UnitTestCase {
$this->moduleHandler->expects($this->atLeastOnce()) $this->moduleHandler->expects($this->atLeastOnce())
->method('moduleExists') ->method('moduleExists')
->with('example_contrib_module') ->with('example_contrib_module')
->will($this->returnValue(TRUE)); ->willReturn(TRUE);
$path = __DIR__ . '/library_test_files'; $path = __DIR__ . '/library_test_files';
$path = substr($path, strlen($this->root) + 1); $path = substr($path, strlen($this->root) + 1);
@ -807,7 +807,7 @@ class LibraryDiscoveryParserTest extends UnitTestCase {
$this->librariesDirectoryFileFinder->expects($this->once()) $this->librariesDirectoryFileFinder->expects($this->once())
->method('find') ->method('find')
->with('third_party_library/css/example.css') ->with('third_party_library/css/example.css')
->will($this->returnValue(FALSE)); ->willReturn(FALSE);
$libraries = $this->libraryDiscoveryParser->buildByExtension('example_contrib_module'); $libraries = $this->libraryDiscoveryParser->buildByExtension('example_contrib_module');
$library = $libraries['third_party_library']; $library = $libraries['third_party_library'];
@ -827,7 +827,7 @@ class LibraryDiscoveryParserTest extends UnitTestCase {
$this->moduleHandler->expects($this->atLeastOnce()) $this->moduleHandler->expects($this->atLeastOnce())
->method('moduleExists') ->method('moduleExists')
->with('empty') ->with('empty')
->will($this->returnValue(TRUE)); ->willReturn(TRUE);
$path = __DIR__ . '/library_test_files'; $path = __DIR__ . '/library_test_files';
$path = substr($path, strlen($this->root) + 1); $path = substr($path, strlen($this->root) + 1);

Some files were not shown because too many files have changed in this diff Show More