Issue #3295880 by Spokje, longwave: ->willReturn(...) would make more sense here
parent
06d6ed5381
commit
cdcba2c1b0
|
@ -54,7 +54,12 @@ class AggregatorPluginSettingsBaseTest extends UnitTestCase {
|
|||
->getMock();
|
||||
$this->managers[$type]->expects($this->once())
|
||||
->method('getDefinitions')
|
||||
->will($this->returnValue(['aggregator_test' => ['title' => '', 'description' => '']]));
|
||||
->willReturn([
|
||||
'aggregator_test' => [
|
||||
'title' => '',
|
||||
'description' => '',
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
/** @var \Drupal\Core\Messenger\MessengerInterface|\PHPUnit\Framework\MockObject\MockBuilder $messenger */
|
||||
|
@ -102,7 +107,7 @@ class AggregatorPluginSettingsBaseTest extends UnitTestCase {
|
|||
$this->managers['processor']->expects($this->once())
|
||||
->method('createInstance')
|
||||
->with($this->equalTo('aggregator_test'))
|
||||
->will($this->returnValue($test_processor));
|
||||
->willReturn($test_processor);
|
||||
|
||||
$form = $this->settingsForm->buildForm([], $form_state);
|
||||
$this->settingsForm->validateForm($form, $form_state);
|
||||
|
|
|
@ -66,13 +66,13 @@ class BlockConfigEntityUnitTest extends UnitTestCase {
|
|||
$this->entityType = $this->createMock('\Drupal\Core\Entity\EntityTypeInterface');
|
||||
$this->entityType->expects($this->any())
|
||||
->method('getProvider')
|
||||
->will($this->returnValue('block'));
|
||||
->willReturn('block');
|
||||
|
||||
$this->entityTypeManager = $this->createMock(EntityTypeManagerInterface::class);
|
||||
$this->entityTypeManager->expects($this->any())
|
||||
->method('getDefinition')
|
||||
->with($this->entityTypeId)
|
||||
->will($this->returnValue($this->entityType));
|
||||
->willReturn($this->entityType);
|
||||
|
||||
$this->uuid = $this->createMock('\Drupal\Component\Uuid\UuidInterface');
|
||||
|
||||
|
@ -111,13 +111,13 @@ class BlockConfigEntityUnitTest extends UnitTestCase {
|
|||
$plugin_collection->expects($this->atLeastOnce())
|
||||
->method('get')
|
||||
->with($instance_id)
|
||||
->will($this->returnValue($instance));
|
||||
->willReturn($instance);
|
||||
$plugin_collection->addInstanceId($instance_id);
|
||||
|
||||
// Return the mocked plugin collection.
|
||||
$entity->expects($this->once())
|
||||
->method('getPluginCollections')
|
||||
->will($this->returnValue([$plugin_collection]));
|
||||
->willReturn([$plugin_collection]);
|
||||
|
||||
$dependencies = $entity->calculateDependencies()->getDependencies();
|
||||
$this->assertContains('test', $dependencies['module']);
|
||||
|
|
|
@ -79,7 +79,7 @@ class BlockFormTest extends UnitTestCase {
|
|||
$this->themeHandler = $this->createMock('Drupal\Core\Extension\ThemeHandlerInterface');
|
||||
$this->entityTypeManager->expects($this->any())
|
||||
->method('getStorage')
|
||||
->will($this->returnValue($this->storage));
|
||||
->willReturn($this->storage);
|
||||
|
||||
$this->pluginFormFactory = $this->prophesize(PluginFormFactoryInterface::class);
|
||||
}
|
||||
|
@ -99,14 +99,14 @@ class BlockFormTest extends UnitTestCase {
|
|||
->getMock();
|
||||
$plugin->expects($this->any())
|
||||
->method('getMachineNameSuggestion')
|
||||
->will($this->returnValue($machine_name));
|
||||
->willReturn($machine_name);
|
||||
|
||||
$block = $this->getMockBuilder(Block::class)
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$block->expects($this->any())
|
||||
->method('getPlugin')
|
||||
->will($this->returnValue($plugin));
|
||||
->willReturn($plugin);
|
||||
return $block;
|
||||
}
|
||||
|
||||
|
@ -126,15 +126,15 @@ class BlockFormTest extends UnitTestCase {
|
|||
$query = $this->createMock('Drupal\Core\Entity\Query\QueryInterface');
|
||||
$query->expects($this->exactly(5))
|
||||
->method('condition')
|
||||
->will($this->returnValue($query));
|
||||
->willReturn($query);
|
||||
|
||||
$query->expects($this->exactly(5))
|
||||
->method('execute')
|
||||
->will($this->returnValue(['test', 'other_test', 'other_test_1', 'other_test_2']));
|
||||
->willReturn(['test', 'other_test', 'other_test_1', 'other_test_2']);
|
||||
|
||||
$this->storage->expects($this->exactly(5))
|
||||
->method('getQuery')
|
||||
->will($this->returnValue($query));
|
||||
->willReturn($query);
|
||||
|
||||
$block_form_controller = new BlockForm($this->entityTypeManager, $this->conditionManager, $this->contextRepository, $this->language, $this->themeHandler, $this->pluginFormFactory->reveal());
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ class BlockRepositoryTest extends UnitTestCase {
|
|||
$theme_manager = $this->createMock('Drupal\Core\Theme\ThemeManagerInterface');
|
||||
$theme_manager->expects($this->atLeastOnce())
|
||||
->method('getActiveTheme')
|
||||
->will($this->returnValue($active_theme));
|
||||
->willReturn($active_theme);
|
||||
|
||||
$this->contextHandler = $this->createMock('Drupal\Core\Plugin\Context\ContextHandlerInterface');
|
||||
$this->blockStorage = $this->createMock('Drupal\Core\Entity\EntityStorageInterface');
|
||||
|
@ -82,7 +82,7 @@ class BlockRepositoryTest extends UnitTestCase {
|
|||
$block = $this->createMock('Drupal\block\BlockInterface');
|
||||
$block->expects($this->once())
|
||||
->method('access')
|
||||
->will($this->returnValue($block_config[0]));
|
||||
->willReturn($block_config[0]);
|
||||
$block->expects($block_config[0] ? $this->atLeastOnce() : $this->never())
|
||||
->method('getRegion')
|
||||
->willReturn($block_config[1]);
|
||||
|
|
|
@ -27,7 +27,7 @@ class CategoryAutocompleteTest extends UnitTestCase {
|
|||
$block_manager = $this->createMock('Drupal\Core\Block\BlockManagerInterface');
|
||||
$block_manager->expects($this->any())
|
||||
->method('getCategories')
|
||||
->will($this->returnValue(['Comment', 'Node', 'None & Such', 'User']));
|
||||
->willReturn(['Comment', 'Node', 'None & Such', 'User']);
|
||||
|
||||
$this->autocompleteController = new CategoryAutocompleteController($block_manager);
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ class BlockLocalTasksTest extends LocalTaskIntegrationTestBase {
|
|||
$theme_handler = $this->createMock('Drupal\Core\Extension\ThemeHandlerInterface');
|
||||
$theme_handler->expects($this->any())
|
||||
->method('listInfo')
|
||||
->will($this->returnValue($themes));
|
||||
->willReturn($themes);
|
||||
$theme_handler->expects($this->any())
|
||||
->method('hasUi')
|
||||
->willReturnMap([
|
||||
|
|
|
@ -219,7 +219,7 @@ class BlockPageVariantTest extends UnitTestCase {
|
|||
}
|
||||
$this->blockViewBuilder->expects($this->exactly($visible_block_count))
|
||||
->method('view')
|
||||
->will($this->returnValue([]));
|
||||
->willReturn([]);
|
||||
$this->blockRepository->expects($this->once())
|
||||
->method('getVisibleBlocksPerRegion')
|
||||
->willReturnCallback(function (&$cacheable_metadata) use ($blocks) {
|
||||
|
|
|
@ -45,7 +45,7 @@ class BlockContentLocalTasksTest extends LocalTaskIntegrationTestBase {
|
|||
$theme_handler = $this->createMock('Drupal\Core\Extension\ThemeHandlerInterface');
|
||||
$theme_handler->expects($this->any())
|
||||
->method('listInfo')
|
||||
->will($this->returnValue($themes));
|
||||
->willReturn($themes);
|
||||
|
||||
$container = new ContainerBuilder();
|
||||
$container->set('config.factory', $config_factory);
|
||||
|
|
|
@ -26,28 +26,28 @@ class CommentManagerTest extends UnitTestCase {
|
|||
$entity_type = $this->createMock('Drupal\Core\Entity\ContentEntityTypeInterface');
|
||||
$entity_type->expects($this->any())
|
||||
->method('getClass')
|
||||
->will($this->returnValue('Node'));
|
||||
->willReturn('Node');
|
||||
$entity_type->expects($this->any())
|
||||
->method('entityClassImplements')
|
||||
->with(FieldableEntityInterface::class)
|
||||
->will($this->returnValue(TRUE));
|
||||
->willReturn(TRUE);
|
||||
|
||||
$entity_field_manager = $this->createMock(EntityFieldManagerInterface::class);
|
||||
$entity_type_manager = $this->createMock(EntityTypeManagerInterface::class);
|
||||
|
||||
$entity_field_manager->expects($this->once())
|
||||
->method('getFieldMapByFieldType')
|
||||
->will($this->returnValue([
|
||||
->willReturn([
|
||||
'node' => [
|
||||
'field_foobar' => [
|
||||
'type' => 'comment',
|
||||
],
|
||||
],
|
||||
]));
|
||||
]);
|
||||
|
||||
$entity_type_manager->expects($this->any())
|
||||
->method('getDefinition')
|
||||
->will($this->returnValue($entity_type));
|
||||
->willReturn($entity_type);
|
||||
|
||||
$comment_manager = new CommentManager(
|
||||
$entity_type_manager,
|
||||
|
|
|
@ -73,7 +73,7 @@ class CommentStatisticsUnitTest extends UnitTestCase {
|
|||
|
||||
$this->select->expects($this->any())
|
||||
->method('execute')
|
||||
->will($this->returnValue($this->statement));
|
||||
->willReturn($this->statement);
|
||||
|
||||
$this->database = $this->getMockBuilder('Drupal\Core\Database\Connection')
|
||||
->disableOriginalConstructor()
|
||||
|
@ -81,7 +81,7 @@ class CommentStatisticsUnitTest extends UnitTestCase {
|
|||
|
||||
$this->database->expects($this->once())
|
||||
->method('select')
|
||||
->will($this->returnValue($this->select));
|
||||
->willReturn($this->select);
|
||||
|
||||
$this->commentStatistics = new CommentStatistics($this->database, $this->createMock('Drupal\Core\Session\AccountInterface'), $this->createMock(EntityTypeManagerInterface::class), $this->createMock('Drupal\Core\State\StateInterface'), $this->database);
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ class CommentLockTest extends UnitTestCase {
|
|||
$lock->expects($this->once())
|
||||
->method('acquire')
|
||||
->with($lock_name, 30)
|
||||
->will($this->returnValue(TRUE));
|
||||
->willReturn(TRUE);
|
||||
$lock->expects($this->once())
|
||||
->method('release')
|
||||
->with($lock_name);
|
||||
|
@ -55,27 +55,27 @@ class CommentLockTest extends UnitTestCase {
|
|||
->getMock();
|
||||
$comment->expects($this->once())
|
||||
->method('isNew')
|
||||
->will($this->returnValue(TRUE));
|
||||
->willReturn(TRUE);
|
||||
$comment->expects($this->once())
|
||||
->method('hasParentComment')
|
||||
->will($this->returnValue(TRUE));
|
||||
->willReturn(TRUE);
|
||||
$comment->expects($this->once())
|
||||
->method('getParentComment')
|
||||
->will($this->returnValue($comment));
|
||||
->willReturn($comment);
|
||||
$comment->expects($this->once())
|
||||
->method('getCommentedEntityId')
|
||||
->will($this->returnValue($cid));
|
||||
->willReturn($cid);
|
||||
$comment->expects($this->any())
|
||||
->method('getThread')
|
||||
->will($this->returnValue(''));
|
||||
->willReturn('');
|
||||
|
||||
$anon_user = $this->createMock('Drupal\Core\Session\AccountInterface');
|
||||
$anon_user->expects($this->any())
|
||||
->method('isAnonymous')
|
||||
->will($this->returnValue(TRUE));
|
||||
->willReturn(TRUE);
|
||||
$comment->expects($this->any())
|
||||
->method('getOwner')
|
||||
->will($this->returnValue($anon_user));
|
||||
->willReturn($anon_user);
|
||||
|
||||
$parent_entity = $this->createMock('\Drupal\Core\Entity\ContentEntityInterface');
|
||||
$parent_entity->expects($this->atLeastOnce())
|
||||
|
@ -88,7 +88,7 @@ class CommentLockTest extends UnitTestCase {
|
|||
$entity_type = $this->createMock('\Drupal\Core\Entity\EntityTypeInterface');
|
||||
$comment->expects($this->any())
|
||||
->method('getEntityType')
|
||||
->will($this->returnValue($entity_type));
|
||||
->willReturn($entity_type);
|
||||
$storage = $this->createMock('Drupal\comment\CommentStorageInterface');
|
||||
|
||||
// preSave() should acquire the lock. (This is what's really being tested.)
|
||||
|
|
|
@ -33,26 +33,26 @@ class CommentBulkFormTest extends UnitTestCase {
|
|||
$action = $this->createMock('\Drupal\system\ActionConfigEntityInterface');
|
||||
$action->expects($this->any())
|
||||
->method('getType')
|
||||
->will($this->returnValue('comment'));
|
||||
->willReturn('comment');
|
||||
$actions[$i] = $action;
|
||||
}
|
||||
|
||||
$action = $this->createMock('\Drupal\system\ActionConfigEntityInterface');
|
||||
$action->expects($this->any())
|
||||
->method('getType')
|
||||
->will($this->returnValue('user'));
|
||||
->willReturn('user');
|
||||
$actions[] = $action;
|
||||
|
||||
$entity_storage = $this->createMock('Drupal\Core\Entity\EntityStorageInterface');
|
||||
$entity_storage->expects($this->any())
|
||||
->method('loadMultiple')
|
||||
->will($this->returnValue($actions));
|
||||
->willReturn($actions);
|
||||
|
||||
$entity_type_manager = $this->createMock(EntityTypeManagerInterface::class);
|
||||
$entity_type_manager->expects($this->once())
|
||||
->method('getStorage')
|
||||
->with('action')
|
||||
->will($this->returnValue($entity_storage));
|
||||
->willReturn($entity_storage);
|
||||
|
||||
$entity_repository = $this->createMock(EntityRepositoryInterface::class);
|
||||
|
||||
|
@ -66,7 +66,7 @@ class CommentBulkFormTest extends UnitTestCase {
|
|||
$views_data->expects($this->any())
|
||||
->method('get')
|
||||
->with('comment')
|
||||
->will($this->returnValue(['table' => ['entity type' => 'comment']]));
|
||||
->willReturn(['table' => ['entity type' => 'comment']]);
|
||||
$container = new ContainerBuilder();
|
||||
$container->set('views.views_data', $views_data);
|
||||
$container->set('string_translation', $this->getStringTranslationStub());
|
||||
|
@ -76,7 +76,7 @@ class CommentBulkFormTest extends UnitTestCase {
|
|||
$storage->expects($this->any())
|
||||
->method('get')
|
||||
->with('base_table')
|
||||
->will($this->returnValue('comment'));
|
||||
->willReturn('comment');
|
||||
|
||||
$executable = $this->getMockBuilder('Drupal\views\ViewExecutable')
|
||||
->disableOriginalConstructor()
|
||||
|
|
|
@ -70,7 +70,7 @@ class ConfigEntityMapperTest extends UnitTestCase {
|
|||
->expects($this->any())
|
||||
->method('getRouteByName')
|
||||
->with('entity.configurable_language.edit_form')
|
||||
->will($this->returnValue(new Route('/admin/config/regional/language/edit/{configurable_language}')));
|
||||
->willReturn(new Route('/admin/config/regional/language/edit/{configurable_language}'));
|
||||
|
||||
$definition = [
|
||||
'class' => '\Drupal\config_translation\ConfigEntityMapper',
|
||||
|
@ -114,18 +114,18 @@ class ConfigEntityMapperTest extends UnitTestCase {
|
|||
->expects($this->once())
|
||||
->method('id')
|
||||
->with()
|
||||
->will($this->returnValue('entity_id'));
|
||||
->willReturn('entity_id');
|
||||
|
||||
$entity_type = $this->createMock('Drupal\Core\Config\Entity\ConfigEntityTypeInterface');
|
||||
$entity_type
|
||||
->expects($this->any())
|
||||
->method('getConfigPrefix')
|
||||
->will($this->returnValue('config_prefix'));
|
||||
->willReturn('config_prefix');
|
||||
$this->entityTypeManager
|
||||
->expects($this->once())
|
||||
->method('getDefinition')
|
||||
->with('configurable_language')
|
||||
->will($this->returnValue($entity_type));
|
||||
->willReturn($entity_type);
|
||||
|
||||
// No entity is set.
|
||||
$this->assertNull($this->configEntityMapper->getEntity());
|
||||
|
@ -154,14 +154,14 @@ class ConfigEntityMapperTest extends UnitTestCase {
|
|||
->expects($this->once())
|
||||
->method('getDefinition')
|
||||
->with('configurable_language')
|
||||
->will($this->returnValue($entity_type));
|
||||
->willReturn($entity_type);
|
||||
$this->configEntityMapper->setEntity($this->entity);
|
||||
|
||||
$this->entity
|
||||
->expects($this->once())
|
||||
->method('id')
|
||||
->with()
|
||||
->will($this->returnValue('entity_id'));
|
||||
->willReturn('entity_id');
|
||||
|
||||
$result = $this->configEntityMapper->getOverviewRouteParameters();
|
||||
|
||||
|
@ -183,12 +183,12 @@ class ConfigEntityMapperTest extends UnitTestCase {
|
|||
$entity_type = $this->createMock('Drupal\Core\Config\Entity\ConfigEntityTypeInterface');
|
||||
$entity_type->expects($this->once())
|
||||
->method('getLabel')
|
||||
->will($this->returnValue('test'));
|
||||
->willReturn('test');
|
||||
$this->entityTypeManager
|
||||
->expects($this->once())
|
||||
->method('getDefinition')
|
||||
->with('configurable_language')
|
||||
->will($this->returnValue($entity_type));
|
||||
->willReturn($entity_type);
|
||||
|
||||
$result = $this->configEntityMapper->getTypeName();
|
||||
$this->assertSame('test', $result);
|
||||
|
@ -201,12 +201,12 @@ class ConfigEntityMapperTest extends UnitTestCase {
|
|||
$entity_type = $this->createMock('Drupal\Core\Config\Entity\ConfigEntityTypeInterface');
|
||||
$entity_type->expects($this->once())
|
||||
->method('getLabel')
|
||||
->will($this->returnValue('test'));
|
||||
->willReturn('test');
|
||||
$this->entityTypeManager
|
||||
->expects($this->once())
|
||||
->method('getDefinition')
|
||||
->with('configurable_language')
|
||||
->will($this->returnValue($entity_type));
|
||||
->willReturn($entity_type);
|
||||
|
||||
$result = $this->configEntityMapper->getTypeLabel();
|
||||
$this->assertSame('test', $result);
|
||||
|
|
|
@ -88,23 +88,23 @@ class ConfigFieldMapperTest extends UnitTestCase {
|
|||
$entity_type
|
||||
->expects($this->any())
|
||||
->method('getConfigPrefix')
|
||||
->will($this->returnValue('config_prefix'));
|
||||
->willReturn('config_prefix');
|
||||
|
||||
$this->entityTypeManager
|
||||
->expects($this->any())
|
||||
->method('getDefinition')
|
||||
->will($this->returnValue($entity_type));
|
||||
->willReturn($entity_type);
|
||||
|
||||
$field_storage = $this->createMock('Drupal\field\FieldStorageConfigInterface');
|
||||
$field_storage
|
||||
->expects($this->any())
|
||||
->method('id')
|
||||
->will($this->returnValue('field_storage_id'));
|
||||
->willReturn('field_storage_id');
|
||||
|
||||
$this->entity
|
||||
->expects($this->any())
|
||||
->method('getFieldStorageDefinition')
|
||||
->will($this->returnValue($field_storage));
|
||||
->willReturn($field_storage);
|
||||
|
||||
$result = $this->configFieldMapper->setEntity($this->entity);
|
||||
$this->assertTrue($result);
|
||||
|
|
|
@ -39,7 +39,7 @@ class ConfigMapperManagerTest extends UnitTestCase {
|
|||
$language_manager->expects($this->once())
|
||||
->method('getCurrentLanguage')
|
||||
->with(LanguageInterface::TYPE_INTERFACE)
|
||||
->will($this->returnValue($language));
|
||||
->willReturn($language);
|
||||
|
||||
$this->typedConfigManager = $this->getMockBuilder('Drupal\Core\Config\TypedConfigManagerInterface')
|
||||
->getMock();
|
||||
|
@ -71,7 +71,7 @@ class ConfigMapperManagerTest extends UnitTestCase {
|
|||
->expects($this->once())
|
||||
->method('get')
|
||||
->with('test')
|
||||
->will($this->returnValue($element));
|
||||
->willReturn($element);
|
||||
|
||||
$result = $this->configMapperManager->hasTranslatable('test');
|
||||
$this->assertSame($expected, $result);
|
||||
|
@ -154,7 +154,7 @@ class ConfigMapperManagerTest extends UnitTestCase {
|
|||
$element = $this->createMock('Drupal\Core\TypedData\TypedDataInterface');
|
||||
$element->expects($this->any())
|
||||
->method('getDataDefinition')
|
||||
->will($this->returnValue($data_definition));
|
||||
->willReturn($data_definition);
|
||||
return $element;
|
||||
}
|
||||
|
||||
|
@ -179,7 +179,7 @@ class ConfigMapperManagerTest extends UnitTestCase {
|
|||
->getMock();
|
||||
$nested_element->expects($this->once())
|
||||
->method('getIterator')
|
||||
->will($this->returnValue(new \ArrayIterator($elements)));
|
||||
->willReturn(new \ArrayIterator($elements));
|
||||
return $nested_element;
|
||||
}
|
||||
|
||||
|
|
|
@ -128,7 +128,7 @@ class ConfigNamesMapperTest extends UnitTestCase {
|
|||
->expects($this->any())
|
||||
->method('getRouteByName')
|
||||
->with('system.site_information_settings')
|
||||
->will($this->returnValue($this->baseRoute));
|
||||
->willReturn($this->baseRoute);
|
||||
|
||||
$this->languageManager = $this->createMock('Drupal\Core\Language\LanguageManagerInterface');
|
||||
|
||||
|
|
|
@ -86,11 +86,11 @@ class MailHandlerTest extends UnitTestCase {
|
|||
|
||||
$this->languageManager->expects($this->any())
|
||||
->method('getDefaultLanguage')
|
||||
->will($this->returnValue($language));
|
||||
->willReturn($language);
|
||||
|
||||
$this->languageManager->expects($this->any())
|
||||
->method('getCurrentLanguage')
|
||||
->will($this->returnValue($language));
|
||||
->willReturn($language);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -42,14 +42,14 @@ class ContentModerationRouteSubscriberTest extends UnitTestCase {
|
|||
$definition = $this->createMock(EntityTypeInterface::class);
|
||||
$definition->expects($this->any())
|
||||
->method('getClass')
|
||||
->will($this->returnValue(SimpleTestEntity::class));
|
||||
->willReturn(SimpleTestEntity::class);
|
||||
$definition->expects($this->any())
|
||||
->method('isRevisionable')
|
||||
->willReturn(FALSE);
|
||||
$revisionable_definition = $this->createMock(EntityTypeInterface::class);
|
||||
$revisionable_definition->expects($this->any())
|
||||
->method('getClass')
|
||||
->will($this->returnValue(SimpleTestEntity::class));
|
||||
->willReturn(SimpleTestEntity::class);
|
||||
$revisionable_definition->expects($this->any())
|
||||
->method('isRevisionable')
|
||||
->willReturn(TRUE);
|
||||
|
|
|
@ -53,13 +53,13 @@ class ContentTranslationManageAccessCheckTest extends UnitTestCase {
|
|||
$translation_handler = $this->createMock('\Drupal\content_translation\ContentTranslationHandlerInterface');
|
||||
$translation_handler->expects($this->once())
|
||||
->method('getTranslationAccess')
|
||||
->will($this->returnValue(AccessResult::allowed()));
|
||||
->willReturn(AccessResult::allowed());
|
||||
|
||||
$entity_type_manager = $this->createMock(EntityTypeManagerInterface::class);
|
||||
$entity_type_manager->expects($this->once())
|
||||
->method('getHandler')
|
||||
->withAnyParameters()
|
||||
->will($this->returnValue($translation_handler));
|
||||
->willReturn($translation_handler);
|
||||
|
||||
// Set our source and target languages.
|
||||
$source = 'en';
|
||||
|
@ -87,7 +87,7 @@ class ContentTranslationManageAccessCheckTest extends UnitTestCase {
|
|||
$entity->expects($this->once())
|
||||
->method('getTranslationLanguages')
|
||||
->with()
|
||||
->will($this->returnValue([]));
|
||||
->willReturn([]);
|
||||
$entity->expects($this->once())
|
||||
->method('getCacheContexts')
|
||||
->willReturn([]);
|
||||
|
@ -96,7 +96,7 @@ class ContentTranslationManageAccessCheckTest extends UnitTestCase {
|
|||
->willReturn(Cache::PERMANENT);
|
||||
$entity->expects($this->once())
|
||||
->method('getCacheTags')
|
||||
->will($this->returnValue(['node:1337']));
|
||||
->willReturn(['node:1337']);
|
||||
$entity->expects($this->once())
|
||||
->method('getCacheContexts')
|
||||
->willReturn([]);
|
||||
|
@ -110,7 +110,7 @@ class ContentTranslationManageAccessCheckTest extends UnitTestCase {
|
|||
$route_match->expects($this->once())
|
||||
->method('getParameter')
|
||||
->with('node')
|
||||
->will($this->returnValue($entity));
|
||||
->willReturn($entity);
|
||||
|
||||
// Set the mock account.
|
||||
$account = $this->createMock('Drupal\Core\Session\AccountInterface');
|
||||
|
|
|
@ -34,9 +34,9 @@ class ContentTranslationLocalTasksTest extends LocalTaskIntegrationTestBase {
|
|||
$content_translation_manager = $this->createMock('Drupal\content_translation\ContentTranslationManagerInterface');
|
||||
$content_translation_manager->expects($this->any())
|
||||
->method('getSupportedEntityTypes')
|
||||
->will($this->returnValue([
|
||||
->willReturn([
|
||||
'node' => $entity_type,
|
||||
]));
|
||||
]);
|
||||
\Drupal::getContainer()->set('content_translation.manager', $content_translation_manager);
|
||||
\Drupal::getContainer()->set('string_translation', $this->getStringTranslationStub());
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ class DateFieldTest extends UnitTestCase {
|
|||
$migration->expects($this->once())
|
||||
->method('mergeProcessOfProperty')
|
||||
->with('field_date', $pipeline)
|
||||
->will($this->returnValue($migration));
|
||||
->willReturn($migration);
|
||||
|
||||
$plugin = new DateField([], '', []);
|
||||
$plugin->defineValueProcessPipeline($migration, 'field_date', $data);
|
||||
|
|
|
@ -65,13 +65,13 @@ class EditorConfigEntityUnitTest extends UnitTestCase {
|
|||
$this->entityType = $this->createMock('\Drupal\Core\Entity\EntityTypeInterface');
|
||||
$this->entityType->expects($this->any())
|
||||
->method('getProvider')
|
||||
->will($this->returnValue('editor'));
|
||||
->willReturn('editor');
|
||||
|
||||
$this->entityTypeManager = $this->createMock(EntityTypeManagerInterface::class);
|
||||
$this->entityTypeManager->expects($this->any())
|
||||
->method('getDefinition')
|
||||
->with($this->entityTypeId)
|
||||
->will($this->returnValue($this->entityType));
|
||||
->willReturn($this->entityType);
|
||||
|
||||
$this->uuid = $this->createMock('\Drupal\Component\Uuid\UuidInterface');
|
||||
|
||||
|
@ -98,33 +98,33 @@ class EditorConfigEntityUnitTest extends UnitTestCase {
|
|||
->getMock();
|
||||
$plugin->expects($this->once())
|
||||
->method('getPluginDefinition')
|
||||
->will($this->returnValue(['provider' => 'test_module']));
|
||||
->willReturn(['provider' => 'test_module']);
|
||||
$plugin->expects($this->once())
|
||||
->method('getDefaultSettings')
|
||||
->will($this->returnValue([]));
|
||||
->willReturn([]);
|
||||
|
||||
$this->editorPluginManager->expects($this->any())
|
||||
->method('createInstance')
|
||||
->with($this->editorId)
|
||||
->will($this->returnValue($plugin));
|
||||
->willReturn($plugin);
|
||||
|
||||
$entity = new Editor($values, $this->entityTypeId);
|
||||
|
||||
$filter_format = $this->createMock('Drupal\Core\Config\Entity\ConfigEntityInterface');
|
||||
$filter_format->expects($this->once())
|
||||
->method('getConfigDependencyName')
|
||||
->will($this->returnValue('filter.format.test'));
|
||||
->willReturn('filter.format.test');
|
||||
|
||||
$storage = $this->createMock('Drupal\Core\Entity\EntityStorageInterface');
|
||||
$storage->expects($this->once())
|
||||
->method('load')
|
||||
->with($format_id)
|
||||
->will($this->returnValue($filter_format));
|
||||
->willReturn($filter_format);
|
||||
|
||||
$this->entityTypeManager->expects($this->once())
|
||||
->method('getStorage')
|
||||
->with('filter_format')
|
||||
->will($this->returnValue($storage));
|
||||
->willReturn($storage);
|
||||
|
||||
$dependencies = $entity->calculateDependencies()->getDependencies();
|
||||
$this->assertContains('test_module', $dependencies['module']);
|
||||
|
|
|
@ -34,7 +34,7 @@ class StandardTest extends UnitTestCase {
|
|||
->getMock();
|
||||
$this->format->expects($this->any())
|
||||
->method('getFilterTypes')
|
||||
->will($this->returnValue([FilterInterface::TYPE_HTML_RESTRICTOR]));
|
||||
->willReturn([FilterInterface::TYPE_HTML_RESTRICTOR]);
|
||||
$restrictions = [
|
||||
'allowed' => [
|
||||
'p' => TRUE,
|
||||
|
@ -47,7 +47,7 @@ class StandardTest extends UnitTestCase {
|
|||
];
|
||||
$this->format->expects($this->any())
|
||||
->method('getHtmlRestrictions')
|
||||
->will($this->returnValue($restrictions));
|
||||
->willReturn($restrictions);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -95,10 +95,10 @@ class FieldConfigEntityUnitTest extends UnitTestCase {
|
|||
$this->fieldStorage = $this->createMock('\Drupal\field\FieldStorageConfigInterface');
|
||||
$this->fieldStorage->expects($this->any())
|
||||
->method('getType')
|
||||
->will($this->returnValue('test_field'));
|
||||
->willReturn('test_field');
|
||||
$this->fieldStorage->expects($this->any())
|
||||
->method('getName')
|
||||
->will($this->returnValue('field_test'));
|
||||
->willReturn('field_test');
|
||||
$this->fieldStorage->expects($this->any())
|
||||
->method('getSettings')
|
||||
->willReturn([]);
|
||||
|
@ -106,9 +106,9 @@ class FieldConfigEntityUnitTest extends UnitTestCase {
|
|||
$this->entityFieldManager->expects($this->any())
|
||||
->method('getFieldStorageDefinitions')
|
||||
->with('test_entity_type')
|
||||
->will($this->returnValue([
|
||||
->willReturn([
|
||||
$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->expects($this->any())
|
||||
->method('getBundleConfigDependency')
|
||||
->will($this->returnValue(['type' => 'config', 'name' => 'test.test_entity_type.id']));
|
||||
->willReturn(['type' => 'config', 'name' => 'test.test_entity_type.id']);
|
||||
|
||||
$this->entityTypeManager->expects($this->any())
|
||||
->method('getDefinition')
|
||||
|
@ -135,7 +135,7 @@ class FieldConfigEntityUnitTest extends UnitTestCase {
|
|||
|
||||
$this->fieldStorage->expects($this->once())
|
||||
->method('getConfigDependencyName')
|
||||
->will($this->returnValue('field.storage.test_entity_type.test_field'));
|
||||
->willReturn('field.storage.test_entity_type.test_field');
|
||||
|
||||
$field = new FieldConfig([
|
||||
'field_name' => $this->fieldStorage->getName(),
|
||||
|
@ -157,12 +157,12 @@ class FieldConfigEntityUnitTest extends UnitTestCase {
|
|||
$storage->expects($this->any())
|
||||
->method('load')
|
||||
->with('test_bundle_not_exists')
|
||||
->will($this->returnValue(NULL));
|
||||
->willReturn(NULL);
|
||||
|
||||
$this->entityTypeManager->expects($this->any())
|
||||
->method('getStorage')
|
||||
->with('bundle_entity_type')
|
||||
->will($this->returnValue($storage));
|
||||
->willReturn($storage);
|
||||
|
||||
$target_entity_type = new EntityType([
|
||||
'id' => 'test_entity_type',
|
||||
|
@ -252,15 +252,15 @@ class FieldConfigEntityUnitTest extends UnitTestCase {
|
|||
$this->entityTypeManager->expects($this->any())
|
||||
->method('getDefinition')
|
||||
->with($this->entityTypeId)
|
||||
->will($this->returnValue($this->entityType));
|
||||
->willReturn($this->entityType);
|
||||
$this->entityType->expects($this->once())
|
||||
->method('getKey')
|
||||
->with('id')
|
||||
->will($this->returnValue('id'));
|
||||
->willReturn('id');
|
||||
$this->entityType->expects($this->once())
|
||||
->method('getPropertiesToExport')
|
||||
->with('test_entity_type.test_bundle.field_test')
|
||||
->will($this->returnValue(array_combine(array_keys($expected), array_keys($expected))));
|
||||
->willReturn(array_combine(array_keys($expected), array_keys($expected)));
|
||||
|
||||
$export = $field->toArray();
|
||||
$this->assertEquals($expected, $export);
|
||||
|
|
|
@ -68,11 +68,11 @@ class FieldStorageConfigAccessControlHandlerTest extends UnitTestCase {
|
|||
$this->anon
|
||||
->expects($this->any())
|
||||
->method('hasPermission')
|
||||
->will($this->returnValue(FALSE));
|
||||
->willReturn(FALSE);
|
||||
$this->anon
|
||||
->expects($this->any())
|
||||
->method('id')
|
||||
->will($this->returnValue(0));
|
||||
->willReturn(0);
|
||||
|
||||
$this->member = $this->createMock(AccountInterface::class);
|
||||
$this->member
|
||||
|
@ -84,23 +84,23 @@ class FieldStorageConfigAccessControlHandlerTest extends UnitTestCase {
|
|||
$this->member
|
||||
->expects($this->any())
|
||||
->method('id')
|
||||
->will($this->returnValue(2));
|
||||
->willReturn(2);
|
||||
|
||||
$storageType = $this->createMock(ConfigEntityTypeInterface::class);
|
||||
$storageType
|
||||
->expects($this->any())
|
||||
->method('getProvider')
|
||||
->will($this->returnValue('field'));
|
||||
->willReturn('field');
|
||||
$storageType
|
||||
->expects($this->any())
|
||||
->method('getConfigPrefix')
|
||||
->will($this->returnValue('field.storage'));
|
||||
->willReturn('field.storage');
|
||||
|
||||
$entityType = $this->createMock(ConfigEntityTypeInterface::class);
|
||||
$entityType
|
||||
->expects($this->any())
|
||||
->method('getProvider')
|
||||
->will($this->returnValue('node'));
|
||||
->willReturn('node');
|
||||
$entityType
|
||||
->expects($this->any())
|
||||
->method('getConfigPrefix')
|
||||
|
@ -110,7 +110,7 @@ class FieldStorageConfigAccessControlHandlerTest extends UnitTestCase {
|
|||
$this->moduleHandler
|
||||
->expects($this->any())
|
||||
->method('invokeAll')
|
||||
->will($this->returnValue([]));
|
||||
->willReturn([]);
|
||||
|
||||
$storage_access_control_handler = new FieldStorageConfigAccessControlHandler($storageType);
|
||||
$storage_access_control_handler->setModuleHandler($this->moduleHandler);
|
||||
|
|
|
@ -73,14 +73,14 @@ class FieldStorageConfigEntityUnitTest extends UnitTestCase {
|
|||
$fieldStorageConfigentityType = $this->createMock('\Drupal\Core\Config\Entity\ConfigEntityTypeInterface');
|
||||
$fieldStorageConfigentityType->expects($this->any())
|
||||
->method('getProvider')
|
||||
->will($this->returnValue('field'));
|
||||
->willReturn('field');
|
||||
|
||||
// Create a mock entity type to attach the field to.
|
||||
$attached_entity_type_id = $this->randomMachineName();
|
||||
$attached_entity_type = $this->createMock('\Drupal\Core\Entity\EntityTypeInterface');
|
||||
$attached_entity_type->expects($this->any())
|
||||
->method('getProvider')
|
||||
->will($this->returnValue('entity_provider_module'));
|
||||
->willReturn('entity_provider_module');
|
||||
|
||||
// Get definition is called three times. Twice in
|
||||
// ConfigEntityBase::addDependency() to get the provider of the field config
|
||||
|
|
|
@ -57,7 +57,7 @@ class ForumListingBreadcrumbBuilderTest extends UnitTestCase {
|
|||
$route_match = $this->createMock('Drupal\Core\Routing\RouteMatchInterface');
|
||||
$route_match->expects($this->once())
|
||||
->method('getRouteName')
|
||||
->will($this->returnValue($route_name));
|
||||
->willReturn($route_name);
|
||||
$route_match->expects($this->any())
|
||||
->method('getParameter')
|
||||
->willReturnMap($parameter_map);
|
||||
|
@ -196,7 +196,7 @@ class ForumListingBreadcrumbBuilderTest extends UnitTestCase {
|
|||
$route_match->expects($this->exactly(2))
|
||||
->method('getParameter')
|
||||
->with('taxonomy_term')
|
||||
->will($this->returnValue($forum_listing));
|
||||
->willReturn($forum_listing);
|
||||
|
||||
// First test.
|
||||
$expected1 = [
|
||||
|
|
|
@ -52,7 +52,7 @@ class ForumNodeBreadcrumbBuilderTest extends UnitTestCase {
|
|||
$forum_manager = $this->createMock('Drupal\forum\ForumManagerInterface');
|
||||
$forum_manager->expects($this->any())
|
||||
->method('checkNodeType')
|
||||
->will($this->returnValue(TRUE));
|
||||
->willReturn(TRUE);
|
||||
|
||||
$translation_manager = $this->createMock('Drupal\Core\StringTranslation\TranslationInterface');
|
||||
|
||||
|
@ -62,7 +62,7 @@ class ForumNodeBreadcrumbBuilderTest extends UnitTestCase {
|
|||
$route_match = $this->createMock('Drupal\Core\Routing\RouteMatchInterface');
|
||||
$route_match->expects($this->once())
|
||||
->method('getRouteName')
|
||||
->will($this->returnValue($route_name));
|
||||
->willReturn($route_name);
|
||||
$route_match->expects($this->any())
|
||||
->method('getParameter')
|
||||
->willReturnMap($parameter_map);
|
||||
|
@ -201,7 +201,7 @@ class ForumNodeBreadcrumbBuilderTest extends UnitTestCase {
|
|||
$route_match->expects($this->exactly(2))
|
||||
->method('getParameter')
|
||||
->with('node')
|
||||
->will($this->returnValue($forum_node));
|
||||
->willReturn($forum_node);
|
||||
|
||||
// First test.
|
||||
$expected1 = [
|
||||
|
|
|
@ -31,22 +31,22 @@ class ForumManagerTest extends UnitTestCase {
|
|||
|
||||
$config_factory->expects($this->once())
|
||||
->method('get')
|
||||
->will($this->returnValue($config));
|
||||
->willReturn($config);
|
||||
|
||||
$config->expects($this->once())
|
||||
->method('get')
|
||||
->will($this->returnValue('forums'));
|
||||
->willReturn('forums');
|
||||
|
||||
$entity_type_manager->expects($this->once())
|
||||
->method('getStorage')
|
||||
->will($this->returnValue($storage));
|
||||
->willReturn($storage);
|
||||
|
||||
// This is sufficient for testing purposes.
|
||||
$term = new \stdClass();
|
||||
|
||||
$storage->expects($this->once())
|
||||
->method('create')
|
||||
->will($this->returnValue($term));
|
||||
->willReturn($term);
|
||||
|
||||
$connection = $this->getMockBuilder('\Drupal\Core\Database\Connection')
|
||||
->disableOriginalConstructor()
|
||||
|
@ -74,7 +74,7 @@ class ForumManagerTest extends UnitTestCase {
|
|||
|
||||
$manager->expects($this->once())
|
||||
->method('getChildren')
|
||||
->will($this->returnValue([]));
|
||||
->willReturn([]);
|
||||
|
||||
// Get the index once.
|
||||
$index1 = $manager->getIndex();
|
||||
|
|
|
@ -57,7 +57,7 @@ class FieldNormalizerDenormalizeExceptionsTest extends UnitTestCase {
|
|||
->getMock();
|
||||
$mock->expects($this->any())
|
||||
->method('getParent')
|
||||
->will($this->returnValue(NULL));
|
||||
->willReturn(NULL);
|
||||
return [
|
||||
[[]],
|
||||
[['target_instance' => $mock]],
|
||||
|
|
|
@ -53,7 +53,7 @@ class ImageStyleTest extends UnitTestCase {
|
|||
$effectManager->expects($this->any())
|
||||
->method('createInstance')
|
||||
->with($image_effect_id)
|
||||
->will($this->returnValue($image_effect));
|
||||
->willReturn($image_effect);
|
||||
$default_stubs = ['getImageEffectPluginManager', 'fileDefaultScheme'];
|
||||
$image_style = $this->getMockBuilder('\Drupal\image\Entity\ImageStyle')
|
||||
->setConstructorArgs([
|
||||
|
@ -65,7 +65,7 @@ class ImageStyleTest extends UnitTestCase {
|
|||
|
||||
$image_style->expects($this->any())
|
||||
->method('getImageEffectPluginManager')
|
||||
->will($this->returnValue($effectManager));
|
||||
->willReturn($effectManager);
|
||||
$image_style->expects($this->any())
|
||||
->method('fileDefaultScheme')
|
||||
->willReturnCallback([$this, 'fileDefaultScheme']);
|
||||
|
@ -82,12 +82,12 @@ class ImageStyleTest extends UnitTestCase {
|
|||
$this->entityType = $this->createMock('\Drupal\Core\Entity\EntityTypeInterface');
|
||||
$this->entityType->expects($this->any())
|
||||
->method('getProvider')
|
||||
->will($this->returnValue($provider));
|
||||
->willReturn($provider);
|
||||
$this->entityTypeManager = $this->createMock('\Drupal\Core\Entity\EntityTypeManagerInterface');
|
||||
$this->entityTypeManager->expects($this->any())
|
||||
->method('getDefinition')
|
||||
->with($this->entityTypeId)
|
||||
->will($this->returnValue($this->entityType));
|
||||
->willReturn($this->entityType);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -101,7 +101,7 @@ class ImageStyleTest extends UnitTestCase {
|
|||
->getMock();
|
||||
$image_effect->expects($this->any())
|
||||
->method('getDerivativeExtension')
|
||||
->will($this->returnValue('png'));
|
||||
->willReturn('png');
|
||||
|
||||
$image_style = $this->getImageStyleMock($image_effect_id, $image_effect);
|
||||
|
||||
|
@ -124,7 +124,7 @@ class ImageStyleTest extends UnitTestCase {
|
|||
->getMock();
|
||||
$image_effect->expects($this->any())
|
||||
->method('getDerivativeExtension')
|
||||
->will($this->returnValue('png'));
|
||||
->willReturn('png');
|
||||
|
||||
$image_style = $this->getImageStyleMock($image_effect_id, $image_effect);
|
||||
$this->assertEquals($image_style->buildUri('public://test.jpeg'), 'public://styles/' . $image_style->id() . '/public/test.jpeg.png');
|
||||
|
@ -157,15 +157,15 @@ class ImageStyleTest extends UnitTestCase {
|
|||
->getMock();
|
||||
$image_effect->expects($this->any())
|
||||
->method('getDerivativeExtension')
|
||||
->will($this->returnValue('png'));
|
||||
->willReturn('png');
|
||||
|
||||
$image_style = $this->getImageStyleMock($image_effect_id, $image_effect, ['getPrivateKey', 'getHashSalt']);
|
||||
$image_style->expects($this->any())
|
||||
->method('getPrivateKey')
|
||||
->will($this->returnValue($private_key));
|
||||
->willReturn($private_key);
|
||||
$image_style->expects($this->any())
|
||||
->method('getHashSalt')
|
||||
->will($this->returnValue($hash_salt));
|
||||
->willReturn($hash_salt);
|
||||
|
||||
// Assert the extension has been added to the URI before creating the token.
|
||||
$this->assertEquals($image_style->getPathToken('public://test.jpeg.png'), $image_style->getPathToken('public://test.jpeg'));
|
||||
|
@ -184,10 +184,10 @@ class ImageStyleTest extends UnitTestCase {
|
|||
$image_style = $this->getImageStyleMock($image_effect_id, $image_effect, ['getPrivateKey', 'getHashSalt']);
|
||||
$image_style->expects($this->any())
|
||||
->method('getPrivateKey')
|
||||
->will($this->returnValue($private_key));
|
||||
->willReturn($private_key);
|
||||
$image_style->expects($this->any())
|
||||
->method('getHashSalt')
|
||||
->will($this->returnValue($hash_salt));
|
||||
->willReturn($hash_salt);
|
||||
// Assert no extension has been added to the uri before creating the token.
|
||||
$this->assertNotEquals($image_style->getPathToken('public://test.jpeg.png'), $image_style->getPathToken('public://test.jpeg'));
|
||||
$this->assertNotEquals(substr(Crypt::hmacBase64($image_style->id() . ':' . 'public://test.jpeg.png', $private_key . $hash_salt), 0, 8), $image_style->getPathToken('public://test.jpeg'));
|
||||
|
|
|
@ -61,7 +61,7 @@ class DenyPrivateImageStyleDownloadTest extends UnitTestCase {
|
|||
public function testPrivateImageStyleDownloadPolicy($expected_result, $route_name) {
|
||||
$this->routeMatch->expects($this->once())
|
||||
->method('getRouteName')
|
||||
->will($this->returnValue($route_name));
|
||||
->willReturn($route_name);
|
||||
|
||||
$actual_result = $this->policy->check($this->response, $this->request);
|
||||
$this->assertSame($expected_result, $actual_result);
|
||||
|
|
|
@ -88,12 +88,12 @@ class ContentLanguageSettingsUnitTest extends UnitTestCase {
|
|||
$target_entity_type = $this->createMock('\Drupal\Core\Entity\EntityTypeInterface');
|
||||
$target_entity_type->expects($this->any())
|
||||
->method('getBundleConfigDependency')
|
||||
->will($this->returnValue(['type' => 'config', 'name' => 'test.test_entity_type.id']));
|
||||
->willReturn(['type' => 'config', 'name' => 'test.test_entity_type.id']);
|
||||
|
||||
$this->entityTypeManager->expects($this->any())
|
||||
->method('getDefinition')
|
||||
->with('test_entity_type')
|
||||
->will($this->returnValue($target_entity_type));
|
||||
->willReturn($target_entity_type);
|
||||
|
||||
$config = new ContentLanguageSettings([
|
||||
'target_entity_type_id' => 'test_entity_type',
|
||||
|
@ -250,17 +250,17 @@ class ContentLanguageSettingsUnitTest extends UnitTestCase {
|
|||
->expects($this->any())
|
||||
->method('load')
|
||||
->with($config_id)
|
||||
->will($this->returnValue($existing_config));
|
||||
->willReturn($existing_config);
|
||||
$this->configEntityStorageInterface
|
||||
->expects($this->any())
|
||||
->method('create')
|
||||
->will($this->returnValue($nullConfig));
|
||||
->willReturn($nullConfig);
|
||||
|
||||
$this->entityTypeManager
|
||||
->expects($this->any())
|
||||
->method('getStorage')
|
||||
->with('language_content_settings')
|
||||
->will($this->returnValue($this->configEntityStorageInterface));
|
||||
->willReturn($this->configEntityStorageInterface);
|
||||
|
||||
$entity_type_repository = $this->getMockForAbstractClass(EntityTypeRepositoryInterface::class);
|
||||
$entity_type_repository->expects($this->any())
|
||||
|
|
|
@ -29,11 +29,11 @@ class LanguageNegotiationUrlTest extends UnitTestCase {
|
|||
$language_de = $this->createMock('\Drupal\Core\Language\LanguageInterface');
|
||||
$language_de->expects($this->any())
|
||||
->method('getId')
|
||||
->will($this->returnValue('de'));
|
||||
->willReturn('de');
|
||||
$language_en = $this->createMock('\Drupal\Core\Language\LanguageInterface');
|
||||
$language_en->expects($this->any())
|
||||
->method('getId')
|
||||
->will($this->returnValue('en'));
|
||||
->willReturn('en');
|
||||
$languages = [
|
||||
'de' => $language_de,
|
||||
'en' => $language_en,
|
||||
|
@ -45,7 +45,7 @@ class LanguageNegotiationUrlTest extends UnitTestCase {
|
|||
->getMock();
|
||||
$language_manager->expects($this->any())
|
||||
->method('getLanguages')
|
||||
->will($this->returnValue($languages));
|
||||
->willReturn($languages);
|
||||
$this->languageManager = $language_manager;
|
||||
|
||||
// Create a user stub.
|
||||
|
@ -69,7 +69,10 @@ class LanguageNegotiationUrlTest extends UnitTestCase {
|
|||
public function testPathPrefix($prefix, $prefixes, $expected_langcode) {
|
||||
$this->languageManager->expects($this->any())
|
||||
->method('getCurrentLanguage')
|
||||
->will($this->returnValue($this->languages[(in_array($expected_langcode, ['en', 'de'])) ? $expected_langcode : 'en']));
|
||||
->willReturn($this->languages[(in_array($expected_langcode, [
|
||||
'en',
|
||||
'de',
|
||||
])) ? $expected_langcode : 'en']);
|
||||
|
||||
$config = $this->getConfigFactoryStub([
|
||||
'language.negotiation' => [
|
||||
|
@ -158,7 +161,7 @@ class LanguageNegotiationUrlTest extends UnitTestCase {
|
|||
public function testDomain($http_host, $domains, $expected_langcode) {
|
||||
$this->languageManager->expects($this->any())
|
||||
->method('getCurrentLanguage')
|
||||
->will($this->returnValue($this->languages['en']));
|
||||
->willReturn($this->languages['en']);
|
||||
|
||||
$config = $this->getConfigFactoryStub([
|
||||
'language.negotiation' => [
|
||||
|
|
|
@ -32,7 +32,7 @@ class LanguageDomainsTest extends MigrateProcessTestCase {
|
|||
// to return TRUE to be able to test the process.
|
||||
$this->row->expects($this->once())
|
||||
->method('getSourceProperty')
|
||||
->will($this->returnValue(TRUE));
|
||||
->willReturn(TRUE);
|
||||
|
||||
// The language_domains plugin use $base_url to fill empty domains.
|
||||
global $base_url;
|
||||
|
|
|
@ -77,7 +77,7 @@ class LocaleLookupTest extends UnitTestCase {
|
|||
$this->user = $this->createMock('Drupal\Core\Session\AccountInterface');
|
||||
$this->user->expects($this->any())
|
||||
->method('getRoles')
|
||||
->will($this->returnValue(['anonymous']));
|
||||
->willReturn(['anonymous']);
|
||||
|
||||
$this->configFactory = $this->getConfigFactoryStub(['locale.settings' => ['cache_strings' => FALSE]]);
|
||||
|
||||
|
@ -112,7 +112,7 @@ class LocaleLookupTest extends UnitTestCase {
|
|||
$this->storage->expects($this->once())
|
||||
->method('findTranslation')
|
||||
->with($this->equalTo($args))
|
||||
->will($this->returnValue($result));
|
||||
->willReturn($result);
|
||||
|
||||
$locale_lookup = $this->getMockBuilder('Drupal\locale\LocaleLookup')
|
||||
->setConstructorArgs(['en', 'irrelevant', $this->storage, $this->cache, $this->lock, $this->configFactory, $this->languageManager, $this->requestStack])
|
||||
|
@ -229,7 +229,7 @@ class LocaleLookupTest extends UnitTestCase {
|
|||
$this->storage->expects($this->once())
|
||||
->method('findTranslation')
|
||||
->with($this->equalTo($args))
|
||||
->will($this->returnValue($result));
|
||||
->willReturn($result);
|
||||
|
||||
$this->configFactory = $this->getConfigFactoryStub(['locale.settings' => ['cache_strings' => TRUE]]);
|
||||
$locale_lookup = $this->getMockBuilder('Drupal\locale\LocaleLookup')
|
||||
|
@ -254,10 +254,10 @@ class LocaleLookupTest extends UnitTestCase {
|
|||
->will($this->returnSelf());
|
||||
$this->storage->expects($this->once())
|
||||
->method('findTranslation')
|
||||
->will($this->returnValue(NULL));
|
||||
->willReturn(NULL);
|
||||
$this->storage->expects($this->once())
|
||||
->method('createString')
|
||||
->will($this->returnValue($string));
|
||||
->willReturn($string);
|
||||
|
||||
$request = Request::create('/test');
|
||||
$this->requestStack->push($request);
|
||||
|
@ -349,7 +349,7 @@ class LocaleLookupTest extends UnitTestCase {
|
|||
$this->user = $this->createMock('Drupal\Core\Session\AccountInterface');
|
||||
$this->user->expects($this->any())
|
||||
->method('getRoles')
|
||||
->will($this->returnValue($roles));
|
||||
->willReturn($roles);
|
||||
|
||||
$container = new ContainerBuilder();
|
||||
$container->set('current_user', $this->user);
|
||||
|
|
|
@ -36,7 +36,7 @@ class MenuLinkContentEntityAccessTest extends UnitTestCase {
|
|||
$language = $this->createMock(LanguageInterface::class);
|
||||
$language->expects($this->any())
|
||||
->method('getId')
|
||||
->will($this->returnValue('de'));
|
||||
->willReturn('de');
|
||||
|
||||
$entity = $this->createMock(ContentEntityInterface::class);
|
||||
$entity->expects($this->any())
|
||||
|
|
|
@ -89,7 +89,7 @@ class MigrateExecutableTest extends MigrateTestCase {
|
|||
|
||||
$this->migration->expects($this->any())
|
||||
->method('getSourcePlugin')
|
||||
->will($this->returnValue($source));
|
||||
->willReturn($source);
|
||||
|
||||
// Ensure that a message with the proper message was added.
|
||||
$exception_message .= " in " . __FILE__ . " line $line";
|
||||
|
@ -115,7 +115,7 @@ class MigrateExecutableTest extends MigrateTestCase {
|
|||
|
||||
$this->migration->expects($this->once())
|
||||
->method('getProcessPlugins')
|
||||
->will($this->returnValue([]));
|
||||
->willReturn([]);
|
||||
|
||||
$destination = $this->createMock('Drupal\migrate\Plugin\MigrateDestinationInterface');
|
||||
|
||||
|
@ -140,7 +140,7 @@ class MigrateExecutableTest extends MigrateTestCase {
|
|||
|
||||
$this->migration->expects($this->once())
|
||||
->method('getProcessPlugins')
|
||||
->will($this->returnValue([]));
|
||||
->willReturn([]);
|
||||
|
||||
$destination = $this->createMock('Drupal\migrate\Plugin\MigrateDestinationInterface');
|
||||
|
||||
|
@ -168,7 +168,7 @@ class MigrateExecutableTest extends MigrateTestCase {
|
|||
|
||||
$this->migration->expects($this->once())
|
||||
->method('getProcessPlugins')
|
||||
->will($this->returnValue([]));
|
||||
->willReturn([]);
|
||||
|
||||
$destination = $this->createMock('Drupal\migrate\Plugin\MigrateDestinationInterface');
|
||||
|
||||
|
@ -196,7 +196,7 @@ class MigrateExecutableTest extends MigrateTestCase {
|
|||
|
||||
$this->migration->expects($this->once())
|
||||
->method('getProcessPlugins')
|
||||
->will($this->returnValue([]));
|
||||
->willReturn([]);
|
||||
|
||||
$destination = $this->createMock('Drupal\migrate\Plugin\MigrateDestinationInterface');
|
||||
|
||||
|
@ -270,7 +270,7 @@ class MigrateExecutableTest extends MigrateTestCase {
|
|||
|
||||
$this->migration->expects($this->once())
|
||||
->method('getProcessPlugins')
|
||||
->will($this->returnValue([]));
|
||||
->willReturn([]);
|
||||
|
||||
$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]->expects($this->once())
|
||||
->method('getPluginDefinition')
|
||||
->will($this->returnValue([]));
|
||||
->willReturn([]);
|
||||
$plugins[$key][0]->expects($this->once())
|
||||
->method('transform')
|
||||
->will($this->returnValue($value));
|
||||
->willReturn($value);
|
||||
}
|
||||
$this->migration->expects($this->once())
|
||||
->method('getProcessPlugins')
|
||||
->with(NULL)
|
||||
->will($this->returnValue($plugins));
|
||||
->willReturn($plugins);
|
||||
$row = new Row();
|
||||
$this->executable->processRow($row);
|
||||
foreach ($expected as $key => $value) {
|
||||
|
@ -317,7 +317,7 @@ class MigrateExecutableTest extends MigrateTestCase {
|
|||
$this->migration->expects($this->once())
|
||||
->method('getProcessPlugins')
|
||||
->with(NULL)
|
||||
->will($this->returnValue(['test' => []]));
|
||||
->willReturn(['test' => []]);
|
||||
$row = new Row();
|
||||
$this->executable->processRow($row);
|
||||
$this->assertSame($row->getDestination(), []);
|
||||
|
@ -386,10 +386,10 @@ class MigrateExecutableTest extends MigrateTestCase {
|
|||
->getMockForAbstractClass();
|
||||
$source->expects($this->once())
|
||||
->method('rewind')
|
||||
->will($this->returnValue(TRUE));
|
||||
->willReturn(TRUE);
|
||||
$source->expects($this->any())
|
||||
->method('initializeIterator')
|
||||
->will($this->returnValue([]));
|
||||
->willReturn([]);
|
||||
$source->expects($this->any())
|
||||
->method('valid')
|
||||
->will($this->onConsecutiveCalls(TRUE, FALSE));
|
||||
|
|
|
@ -29,7 +29,7 @@ class ConfigTest extends UnitTestCase {
|
|||
$config->expects($this->once())
|
||||
->method('set')
|
||||
->with($this->equalTo($key), $this->equalTo($val))
|
||||
->will($this->returnValue($config));
|
||||
->willReturn($config);
|
||||
}
|
||||
$config->expects($this->once())
|
||||
->method('save');
|
||||
|
@ -40,20 +40,20 @@ class ConfigTest extends UnitTestCase {
|
|||
$config_factory->expects($this->once())
|
||||
->method('getEditable')
|
||||
->with('d8_config')
|
||||
->will($this->returnValue($config));
|
||||
->willReturn($config);
|
||||
$row = $this->getMockBuilder('Drupal\migrate\Row')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$row->expects($this->any())
|
||||
->method('getRawDestination')
|
||||
->will($this->returnValue($source));
|
||||
->willReturn($source);
|
||||
$language_manager = $this->getMockBuilder('Drupal\language\ConfigurableLanguageManagerInterface')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$language_manager->expects($this->never())
|
||||
->method('getLanguageConfigOverride')
|
||||
->with('fr', 'd8_config')
|
||||
->will($this->returnValue($config));
|
||||
->willReturn($config);
|
||||
$destination = new Config(['config_name' => 'd8_config'], 'd8_config', ['pluginId' => 'd8_config'], $migration, $config_factory, $language_manager);
|
||||
$destination_id = $destination->import($row);
|
||||
$this->assertEquals(['d8_config'], $destination_id);
|
||||
|
@ -76,7 +76,7 @@ class ConfigTest extends UnitTestCase {
|
|||
$config->expects($this->once())
|
||||
->method('set')
|
||||
->with($this->equalTo($key), $this->equalTo($val))
|
||||
->will($this->returnValue($config));
|
||||
->willReturn($config);
|
||||
}
|
||||
$config->expects($this->once())
|
||||
->method('save');
|
||||
|
@ -87,23 +87,23 @@ class ConfigTest extends UnitTestCase {
|
|||
$config_factory->expects($this->once())
|
||||
->method('getEditable')
|
||||
->with('d8_config')
|
||||
->will($this->returnValue($config));
|
||||
->willReturn($config);
|
||||
$row = $this->getMockBuilder('Drupal\migrate\Row')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$row->expects($this->any())
|
||||
->method('getRawDestination')
|
||||
->will($this->returnValue($source));
|
||||
->willReturn($source);
|
||||
$row->expects($this->any())
|
||||
->method('getDestinationProperty')
|
||||
->will($this->returnValue($source['langcode']));
|
||||
->willReturn($source['langcode']);
|
||||
$language_manager = $this->getMockBuilder('Drupal\language\ConfigurableLanguageManagerInterface')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$language_manager->expects($this->any())
|
||||
->method('getLanguageConfigOverride')
|
||||
->with('mi', 'd8_config')
|
||||
->will($this->returnValue($config));
|
||||
->willReturn($config);
|
||||
$destination = new Config(['config_name' => 'd8_config', 'translations' => 'true'], 'd8_config', ['pluginId' => 'd8_config'], $migration, $config_factory, $language_manager);
|
||||
$destination_id = $destination->import($row);
|
||||
$this->assertEquals(['d8_config', 'mi'], $destination_id);
|
||||
|
|
|
@ -18,7 +18,7 @@ class GetTest extends MigrateProcessTestCase {
|
|||
$this->row->expects($this->once())
|
||||
->method('get')
|
||||
->with('test')
|
||||
->will($this->returnValue('source_value'));
|
||||
->willReturn('source_value');
|
||||
$this->plugin = new Get(['source' => 'test'], '', []);
|
||||
$value = $this->plugin->transform(NULL, $this->migrateExecutable, $this->row, 'destination_property');
|
||||
$this->assertSame('source_value', $value);
|
||||
|
@ -49,7 +49,7 @@ class GetTest extends MigrateProcessTestCase {
|
|||
$this->row->expects($this->once())
|
||||
->method('get')
|
||||
->with('@@test')
|
||||
->will($this->returnValue('source_value'));
|
||||
->willReturn('source_value');
|
||||
$this->plugin = new Get(['source' => '@@test'], '', []);
|
||||
$value = $this->plugin->transform(NULL, $this->migrateExecutable, $this->row, 'destination_property');
|
||||
$this->assertSame('source_value', $value);
|
||||
|
|
|
@ -162,10 +162,10 @@ class MakeUniqueEntityFieldTest extends MigrateProcessTestCase {
|
|||
protected function entityQueryExpects($count) {
|
||||
$this->entityQuery->expects($this->exactly($count + 1))
|
||||
->method('condition')
|
||||
->will($this->returnValue($this->entityQuery));
|
||||
->willReturn($this->entityQuery);
|
||||
$this->entityQuery->expects($this->exactly($count + 1))
|
||||
->method('count')
|
||||
->will($this->returnValue($this->entityQuery));
|
||||
->willReturn($this->entityQuery);
|
||||
$this->entityQuery->expects($this->exactly($count + 1))
|
||||
->method('execute')
|
||||
->willReturnCallback(function () use (&$count) {
|
||||
|
|
|
@ -71,7 +71,7 @@ class NodeOperationAccessTest extends UnitTestCase {
|
|||
$language = $this->createMock(LanguageInterface::class);
|
||||
$language->expects($this->any())
|
||||
->method('getId')
|
||||
->will($this->returnValue('de'));
|
||||
->willReturn('de');
|
||||
|
||||
$nid = 333;
|
||||
/** @var \Drupal\node\NodeInterface|\PHPUnit\Framework\MockObject\MockObject $node */
|
||||
|
|
|
@ -61,7 +61,7 @@ class DenyNodePreviewTest extends UnitTestCase {
|
|||
public function testPrivateImageStyleDownloadPolicy($expected_result, $route_name) {
|
||||
$this->routeMatch->expects($this->once())
|
||||
->method('getRouteName')
|
||||
->will($this->returnValue($route_name));
|
||||
->willReturn($route_name);
|
||||
|
||||
$actual_result = $this->policy->check($this->response, $this->request);
|
||||
$this->assertSame($expected_result, $actual_result);
|
||||
|
|
|
@ -33,26 +33,26 @@ class NodeBulkFormTest extends UnitTestCase {
|
|||
$action = $this->createMock('\Drupal\system\ActionConfigEntityInterface');
|
||||
$action->expects($this->any())
|
||||
->method('getType')
|
||||
->will($this->returnValue('node'));
|
||||
->willReturn('node');
|
||||
$actions[$i] = $action;
|
||||
}
|
||||
|
||||
$action = $this->createMock('\Drupal\system\ActionConfigEntityInterface');
|
||||
$action->expects($this->any())
|
||||
->method('getType')
|
||||
->will($this->returnValue('user'));
|
||||
->willReturn('user');
|
||||
$actions[] = $action;
|
||||
|
||||
$entity_storage = $this->createMock('Drupal\Core\Entity\EntityStorageInterface');
|
||||
$entity_storage->expects($this->any())
|
||||
->method('loadMultiple')
|
||||
->will($this->returnValue($actions));
|
||||
->willReturn($actions);
|
||||
|
||||
$entity_type_manager = $this->createMock(EntityTypeManagerInterface::class);
|
||||
$entity_type_manager->expects($this->once())
|
||||
->method('getStorage')
|
||||
->with('action')
|
||||
->will($this->returnValue($entity_storage));
|
||||
->willReturn($entity_storage);
|
||||
|
||||
$entity_repository = $this->createMock(EntityRepositoryInterface::class);
|
||||
|
||||
|
@ -66,7 +66,7 @@ class NodeBulkFormTest extends UnitTestCase {
|
|||
$views_data->expects($this->any())
|
||||
->method('get')
|
||||
->with('node')
|
||||
->will($this->returnValue(['table' => ['entity type' => 'node']]));
|
||||
->willReturn(['table' => ['entity type' => 'node']]);
|
||||
$container = new ContainerBuilder();
|
||||
$container->set('views.views_data', $views_data);
|
||||
$container->set('string_translation', $this->getStringTranslationStub());
|
||||
|
@ -76,7 +76,7 @@ class NodeBulkFormTest extends UnitTestCase {
|
|||
$storage->expects($this->any())
|
||||
->method('get')
|
||||
->with('base_table')
|
||||
->will($this->returnValue('node'));
|
||||
->willReturn('node');
|
||||
|
||||
$executable = $this->getMockBuilder('Drupal\views\ViewExecutable')
|
||||
->disableOriginalConstructor()
|
||||
|
|
|
@ -91,12 +91,12 @@ class AliasManagerTest extends UnitTestCase {
|
|||
$this->languageManager->expects($this->any())
|
||||
->method('getCurrentLanguage')
|
||||
->with(LanguageInterface::TYPE_URL)
|
||||
->will($this->returnValue($language));
|
||||
->willReturn($language);
|
||||
|
||||
$this->aliasRepository->expects($this->once())
|
||||
->method('lookupByAlias')
|
||||
->with($alias, $language->getId())
|
||||
->will($this->returnValue(NULL));
|
||||
->willReturn(NULL);
|
||||
|
||||
$this->assertEquals($alias, $this->aliasManager->getPathByAlias($alias));
|
||||
// Call it twice to test the static cache.
|
||||
|
@ -117,7 +117,7 @@ class AliasManagerTest extends UnitTestCase {
|
|||
$this->aliasRepository->expects($this->once())
|
||||
->method('lookupByAlias')
|
||||
->with($alias, $language->getId())
|
||||
->will($this->returnValue(['path' => $path]));
|
||||
->willReturn(['path' => $path]);
|
||||
|
||||
$this->assertEquals($path, $this->aliasManager->getPathByAlias($alias));
|
||||
// Call it twice to test the static cache.
|
||||
|
@ -139,7 +139,7 @@ class AliasManagerTest extends UnitTestCase {
|
|||
$this->aliasRepository->expects($this->once())
|
||||
->method('lookupByAlias')
|
||||
->with($alias, 'de')
|
||||
->will($this->returnValue(['path' => $path]));
|
||||
->willReturn(['path' => $path]);
|
||||
|
||||
$this->assertEquals($path, $this->aliasManager->getPathByAlias($alias, 'de'));
|
||||
// Call it twice to test the static cache.
|
||||
|
@ -161,7 +161,7 @@ class AliasManagerTest extends UnitTestCase {
|
|||
$this->aliasWhitelist->expects($this->any())
|
||||
->method('get')
|
||||
->with($path_part1)
|
||||
->will($this->returnValue(FALSE));
|
||||
->willReturn(FALSE);
|
||||
|
||||
// The whitelist returns FALSE for that path part, so the storage should
|
||||
// never be called.
|
||||
|
@ -188,12 +188,12 @@ class AliasManagerTest extends UnitTestCase {
|
|||
$this->aliasWhitelist->expects($this->any())
|
||||
->method('get')
|
||||
->with($path_part1)
|
||||
->will($this->returnValue(TRUE));
|
||||
->willReturn(TRUE);
|
||||
|
||||
$this->aliasRepository->expects($this->once())
|
||||
->method('lookupBySystemPath')
|
||||
->with($path, $language->getId())
|
||||
->will($this->returnValue(NULL));
|
||||
->willReturn(NULL);
|
||||
|
||||
$this->assertEquals($path, $this->aliasManager->getAliasByPath($path));
|
||||
// Call it twice to test the static cache.
|
||||
|
@ -226,12 +226,12 @@ class AliasManagerTest extends UnitTestCase {
|
|||
$this->aliasWhitelist->expects($this->any())
|
||||
->method('get')
|
||||
->with($path_part1)
|
||||
->will($this->returnValue(TRUE));
|
||||
->willReturn(TRUE);
|
||||
|
||||
$this->aliasRepository->expects($this->once())
|
||||
->method('lookupBySystemPath')
|
||||
->with($path, $language->getId())
|
||||
->will($this->returnValue(['alias' => $alias]));
|
||||
->willReturn(['alias' => $alias]);
|
||||
|
||||
$this->assertEquals($alias, $this->aliasManager->getAliasByPath($path));
|
||||
// Call it twice to test the static cache.
|
||||
|
@ -263,7 +263,7 @@ class AliasManagerTest extends UnitTestCase {
|
|||
$this->cache->expects($this->once())
|
||||
->method('get')
|
||||
->with($this->cacheKey)
|
||||
->will($this->returnValue((object) ['data' => $cached_paths]));
|
||||
->willReturn((object) ['data' => $cached_paths]);
|
||||
|
||||
// Simulate a request so that the preloaded paths are fetched.
|
||||
$this->aliasManager->setCacheKey($this->path);
|
||||
|
@ -271,12 +271,12 @@ class AliasManagerTest extends UnitTestCase {
|
|||
$this->aliasWhitelist->expects($this->any())
|
||||
->method('get')
|
||||
->with($path_part1)
|
||||
->will($this->returnValue(TRUE));
|
||||
->willReturn(TRUE);
|
||||
|
||||
$this->aliasRepository->expects($this->once())
|
||||
->method('preloadPathAlias')
|
||||
->with($cached_paths[$language->getId()], $language->getId())
|
||||
->will($this->returnValue([$path => $alias]));
|
||||
->willReturn([$path => $alias]);
|
||||
|
||||
// LookupPathAlias should not be called.
|
||||
$this->aliasRepository->expects($this->never())
|
||||
|
@ -311,7 +311,7 @@ class AliasManagerTest extends UnitTestCase {
|
|||
$this->cache->expects($this->once())
|
||||
->method('get')
|
||||
->with($this->cacheKey)
|
||||
->will($this->returnValue((object) ['data' => $cached_paths]));
|
||||
->willReturn((object) ['data' => $cached_paths]);
|
||||
|
||||
// Simulate a request so that the preloaded paths are fetched.
|
||||
$this->aliasManager->setCacheKey($this->path);
|
||||
|
@ -319,7 +319,7 @@ class AliasManagerTest extends UnitTestCase {
|
|||
$this->aliasWhitelist->expects($this->any())
|
||||
->method('get')
|
||||
->with($path_part1)
|
||||
->will($this->returnValue(TRUE));
|
||||
->willReturn(TRUE);
|
||||
|
||||
// The requested language is different than the cached, so this will
|
||||
// need to load.
|
||||
|
@ -328,7 +328,7 @@ class AliasManagerTest extends UnitTestCase {
|
|||
$this->aliasRepository->expects($this->once())
|
||||
->method('lookupBySystemPath')
|
||||
->with($path, $language->getId())
|
||||
->will($this->returnValue(['alias' => $alias]));
|
||||
->willReturn(['alias' => $alias]);
|
||||
|
||||
$this->assertEquals($alias, $this->aliasManager->getAliasByPath($path));
|
||||
// Call it twice to test the static cache.
|
||||
|
@ -360,7 +360,7 @@ class AliasManagerTest extends UnitTestCase {
|
|||
$this->cache->expects($this->once())
|
||||
->method('get')
|
||||
->with($this->cacheKey)
|
||||
->will($this->returnValue((object) ['data' => $cached_paths]));
|
||||
->willReturn((object) ['data' => $cached_paths]);
|
||||
|
||||
// Simulate a request so that the preloaded paths are fetched.
|
||||
$this->aliasManager->setCacheKey($this->path);
|
||||
|
@ -368,12 +368,12 @@ class AliasManagerTest extends UnitTestCase {
|
|||
$this->aliasWhitelist->expects($this->any())
|
||||
->method('get')
|
||||
->with($path_part1)
|
||||
->will($this->returnValue(TRUE));
|
||||
->willReturn(TRUE);
|
||||
|
||||
$this->aliasRepository->expects($this->once())
|
||||
->method('preloadPathAlias')
|
||||
->with($cached_paths[$language->getId()], $language->getId())
|
||||
->will($this->returnValue([$cached_path => $cached_alias]));
|
||||
->willReturn([$cached_path => $cached_alias]);
|
||||
|
||||
// LookupPathAlias() should not be called.
|
||||
$this->aliasRepository->expects($this->never())
|
||||
|
@ -408,7 +408,7 @@ class AliasManagerTest extends UnitTestCase {
|
|||
$this->cache->expects($this->once())
|
||||
->method('get')
|
||||
->with($this->cacheKey)
|
||||
->will($this->returnValue((object) ['data' => $cached_paths]));
|
||||
->willReturn((object) ['data' => $cached_paths]);
|
||||
|
||||
// Simulate a request so that the preloaded paths are fetched.
|
||||
$this->aliasManager->setCacheKey($this->path);
|
||||
|
@ -416,17 +416,17 @@ class AliasManagerTest extends UnitTestCase {
|
|||
$this->aliasWhitelist->expects($this->any())
|
||||
->method('get')
|
||||
->with($path_part1)
|
||||
->will($this->returnValue(TRUE));
|
||||
->willReturn(TRUE);
|
||||
|
||||
$this->aliasRepository->expects($this->once())
|
||||
->method('preloadPathAlias')
|
||||
->with($cached_paths[$language->getId()], $language->getId())
|
||||
->will($this->returnValue([$cached_path => $cached_alias]));
|
||||
->willReturn([$cached_path => $cached_alias]);
|
||||
|
||||
$this->aliasRepository->expects($this->once())
|
||||
->method('lookupBySystemPath')
|
||||
->with($path, $language->getId())
|
||||
->will($this->returnValue(NULL));
|
||||
->willReturn(NULL);
|
||||
|
||||
$this->assertEquals($path, $this->aliasManager->getAliasByPath($path));
|
||||
// Call it twice to test the static cache.
|
||||
|
@ -494,7 +494,7 @@ class AliasManagerTest extends UnitTestCase {
|
|||
$this->cache->expects($this->once())
|
||||
->method('get')
|
||||
->with($this->cacheKey)
|
||||
->will($this->returnValue((object) ['data' => $cached_paths]));
|
||||
->willReturn((object) ['data' => $cached_paths]);
|
||||
|
||||
// Simulate a request so that the preloaded paths are fetched.
|
||||
$this->aliasManager->setCacheKey($this->path);
|
||||
|
@ -502,17 +502,17 @@ class AliasManagerTest extends UnitTestCase {
|
|||
$this->aliasWhitelist->expects($this->any())
|
||||
->method('get')
|
||||
->with($path_part1)
|
||||
->will($this->returnValue(TRUE));
|
||||
->willReturn(TRUE);
|
||||
|
||||
$this->aliasRepository->expects($this->once())
|
||||
->method('preloadPathAlias')
|
||||
->with($cached_paths[$language->getId()], $language->getId())
|
||||
->will($this->returnValue([$cached_path => $cached_alias]));
|
||||
->willReturn([$cached_path => $cached_alias]);
|
||||
|
||||
$this->aliasRepository->expects($this->once())
|
||||
->method('lookupBySystemPath')
|
||||
->with($path, $language->getId())
|
||||
->will($this->returnValue(['alias' => $new_alias]));
|
||||
->willReturn(['alias' => $new_alias]);
|
||||
|
||||
$this->assertEquals($new_alias, $this->aliasManager->getAliasByPath($path));
|
||||
// Call it twice to test the static cache.
|
||||
|
@ -537,7 +537,7 @@ class AliasManagerTest extends UnitTestCase {
|
|||
$this->languageManager->expects($this->any())
|
||||
->method('getCurrentLanguage')
|
||||
->with(LanguageInterface::TYPE_URL)
|
||||
->will($this->returnValue($language));
|
||||
->willReturn($language);
|
||||
|
||||
return $language;
|
||||
}
|
||||
|
|
|
@ -83,11 +83,11 @@ class QuickEditEntityFieldAccessCheckTest extends UnitTestCase {
|
|||
$entity_with_field->expects($this->any())
|
||||
->method('get')
|
||||
->with($field_name)
|
||||
->will($this->returnValue($field_storage));
|
||||
->willReturn($field_storage);
|
||||
$entity_with_field->expects($this->once())
|
||||
->method('hasTranslation')
|
||||
->with(LanguageInterface::LANGCODE_NOT_SPECIFIED)
|
||||
->will($this->returnValue(TRUE));
|
||||
->willReturn(TRUE);
|
||||
|
||||
$account = $this->createMock('Drupal\Core\Session\AccountInterface');
|
||||
$access = $this->editAccessCheck->access($entity_with_field, $field_name, LanguageInterface::LANGCODE_NOT_SPECIFIED, $account);
|
||||
|
|
|
@ -51,7 +51,7 @@ class RdfMappingConfigEntityUnitTest extends UnitTestCase {
|
|||
$this->entityType = $this->createMock('\Drupal\Core\Entity\EntityTypeInterface');
|
||||
$this->entityType->expects($this->any())
|
||||
->method('getProvider')
|
||||
->will($this->returnValue('entity'));
|
||||
->willReturn('entity');
|
||||
|
||||
$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->expects($this->any())
|
||||
->method('getProvider')
|
||||
->will($this->returnValue('test_module'));
|
||||
->willReturn('test_module');
|
||||
$values = ['targetEntityType' => $target_entity_type_id];
|
||||
$target_entity_type->expects($this->any())
|
||||
->method('getBundleEntityType')
|
||||
->will($this->returnValue(NULL));
|
||||
->willReturn(NULL);
|
||||
$target_entity_type->expects($this->any())
|
||||
->method('getBundleConfigDependency')
|
||||
->will($this->returnValue(['type' => 'module', 'name' => 'test_module']));
|
||||
->willReturn(['type' => 'module', 'name' => 'test_module']);
|
||||
|
||||
$this->entityTypeManager->expects($this->any())
|
||||
->method('getDefinition')
|
||||
|
@ -103,13 +103,16 @@ class RdfMappingConfigEntityUnitTest extends UnitTestCase {
|
|||
$target_entity_type = $this->createMock('\Drupal\Core\Entity\EntityTypeInterface');
|
||||
$target_entity_type->expects($this->any())
|
||||
->method('getProvider')
|
||||
->will($this->returnValue('test_module'));
|
||||
->willReturn('test_module');
|
||||
$bundle_id = $this->randomMachineName(10);
|
||||
$values = ['targetEntityType' => $target_entity_type_id , 'bundle' => $bundle_id];
|
||||
|
||||
$target_entity_type->expects($this->any())
|
||||
->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())
|
||||
->method('getDefinition')
|
||||
|
|
|
@ -42,13 +42,13 @@ class ResponsiveImageStyleConfigEntityUnitTest extends UnitTestCase {
|
|||
$this->entityType = $this->createMock('\Drupal\Core\Entity\EntityTypeInterface');
|
||||
$this->entityType->expects($this->any())
|
||||
->method('getProvider')
|
||||
->will($this->returnValue('responsive_image'));
|
||||
->willReturn('responsive_image');
|
||||
|
||||
$this->entityTypeManager = $this->createMock(EntityTypeManagerInterface::class);
|
||||
$this->entityTypeManager->expects($this->any())
|
||||
->method('getDefinition')
|
||||
->with('responsive_image_style')
|
||||
->will($this->returnValue($this->entityType));
|
||||
->willReturn($this->entityType);
|
||||
|
||||
$this->breakpointManager = $this->createMock('\Drupal\breakpoint\BreakpointManagerInterface');
|
||||
|
||||
|
|
|
@ -85,7 +85,7 @@ class CollectRoutesTest extends UnitTestCase {
|
|||
$container->set('authentication_collector', $authentication_collector);
|
||||
$authentication_collector->expects($this->any())
|
||||
->method('getSortedProviders')
|
||||
->will($this->returnValue(['basic_auth' => 'data', 'cookie' => 'data']));
|
||||
->willReturn(['basic_auth' => 'data', 'cookie' => 'data']);
|
||||
|
||||
$container->setParameter('serializer.format_providers', ['json']);
|
||||
|
||||
|
@ -105,7 +105,7 @@ class CollectRoutesTest extends UnitTestCase {
|
|||
|
||||
$display_manager->expects($this->once())
|
||||
->method('getDefinition')
|
||||
->will($this->returnValue(['id' => 'test', 'provider' => 'test']));
|
||||
->willReturn(['id' => 'test', 'provider' => 'test']);
|
||||
|
||||
$none = $this->getMockBuilder('\Drupal\views\Plugin\views\access\None')
|
||||
->disableOriginalConstructor()
|
||||
|
@ -113,7 +113,7 @@ class CollectRoutesTest extends UnitTestCase {
|
|||
|
||||
$access_manager->expects($this->once())
|
||||
->method('createInstance')
|
||||
->will($this->returnValue($none));
|
||||
->willReturn($none);
|
||||
|
||||
$style_plugin = $this->getMockBuilder('\Drupal\rest\Plugin\views\style\Serializer')
|
||||
->onlyMethods(['getFormats', 'init'])
|
||||
|
@ -122,16 +122,16 @@ class CollectRoutesTest extends UnitTestCase {
|
|||
|
||||
$style_plugin->expects($this->once())
|
||||
->method('getFormats')
|
||||
->will($this->returnValue(['json']));
|
||||
->willReturn(['json']);
|
||||
|
||||
$style_plugin->expects($this->once())
|
||||
->method('init')
|
||||
->with($view_executable)
|
||||
->will($this->returnValue(TRUE));
|
||||
->willReturn(TRUE);
|
||||
|
||||
$style_manager->expects($this->once())
|
||||
->method('createInstance')
|
||||
->will($this->returnValue($style_plugin));
|
||||
->willReturn($style_plugin);
|
||||
|
||||
$this->routes = new RouteCollection();
|
||||
$this->routes->add('test_1', new Route('/test/1'));
|
||||
|
|
|
@ -56,7 +56,7 @@ class EntityResourceValidationTraitTest extends UnitTestCase {
|
|||
|
||||
$violations->expects($this->once())
|
||||
->method('filterByFieldAccess')
|
||||
->will($this->returnValue([]));
|
||||
->willReturn([]);
|
||||
|
||||
$entity->validate()->willReturn($violations);
|
||||
|
||||
|
|
|
@ -55,13 +55,13 @@ class SearchPageRepositoryTest extends UnitTestCase {
|
|||
$this->storage = $this->createMock('Drupal\Core\Config\Entity\ConfigEntityStorageInterface');
|
||||
$this->storage->expects($this->any())
|
||||
->method('getQuery')
|
||||
->will($this->returnValue($this->query));
|
||||
->willReturn($this->query);
|
||||
|
||||
/** @var \Drupal\Core\Entity\EntityTypeManagerInterface|\PHPUnit\Framework\MockObject\MockObject $entity_type_manager */
|
||||
$entity_type_manager = $this->createMock(EntityTypeManagerInterface::class);
|
||||
$entity_type_manager->expects($this->any())
|
||||
->method('getStorage')
|
||||
->will($this->returnValue($this->storage));
|
||||
->willReturn($this->storage);
|
||||
|
||||
$this->configFactory = $this->createMock('Drupal\Core\Config\ConfigFactoryInterface');
|
||||
$this->searchPageRepository = new SearchPageRepository($this->configFactory, $entity_type_manager);
|
||||
|
@ -74,10 +74,10 @@ class SearchPageRepositoryTest extends UnitTestCase {
|
|||
$this->query->expects($this->once())
|
||||
->method('condition')
|
||||
->with('status', TRUE)
|
||||
->will($this->returnValue($this->query));
|
||||
->willReturn($this->query);
|
||||
$this->query->expects($this->once())
|
||||
->method('execute')
|
||||
->will($this->returnValue(['test' => 'test', 'other_test' => 'other_test']));
|
||||
->willReturn(['test' => 'test', 'other_test' => 'other_test']);
|
||||
|
||||
$entities = [];
|
||||
$entities['test'] = $this->createMock('Drupal\search\SearchPageInterface');
|
||||
|
@ -85,7 +85,7 @@ class SearchPageRepositoryTest extends UnitTestCase {
|
|||
$this->storage->expects($this->once())
|
||||
->method('loadMultiple')
|
||||
->with(['test' => 'test', 'other_test' => 'other_test'])
|
||||
->will($this->returnValue($entities));
|
||||
->willReturn($entities);
|
||||
|
||||
$result = $this->searchPageRepository->getActiveSearchPages();
|
||||
$this->assertSame($entities, $result);
|
||||
|
@ -98,14 +98,14 @@ class SearchPageRepositoryTest extends UnitTestCase {
|
|||
$this->query->expects($this->once())
|
||||
->method('condition')
|
||||
->with('status', TRUE)
|
||||
->will($this->returnValue($this->query));
|
||||
->willReturn($this->query);
|
||||
$this->query->expects($this->once())
|
||||
->method('range')
|
||||
->with(0, 1)
|
||||
->will($this->returnValue($this->query));
|
||||
->willReturn($this->query);
|
||||
$this->query->expects($this->once())
|
||||
->method('execute')
|
||||
->will($this->returnValue(['test' => 'test']));
|
||||
->willReturn(['test' => 'test']);
|
||||
|
||||
$this->assertTrue($this->searchPageRepository->isSearchActive());
|
||||
}
|
||||
|
@ -117,24 +117,24 @@ class SearchPageRepositoryTest extends UnitTestCase {
|
|||
$this->query->expects($this->once())
|
||||
->method('condition')
|
||||
->with('status', TRUE)
|
||||
->will($this->returnValue($this->query));
|
||||
->willReturn($this->query);
|
||||
$this->query->expects($this->once())
|
||||
->method('execute')
|
||||
->will($this->returnValue(['test' => 'test', 'other_test' => 'other_test']));
|
||||
->willReturn(['test' => 'test', 'other_test' => 'other_test']);
|
||||
|
||||
$entities = [];
|
||||
$entities['test'] = $this->createMock('Drupal\search\SearchPageInterface');
|
||||
$entities['test']->expects($this->once())
|
||||
->method('isIndexable')
|
||||
->will($this->returnValue(TRUE));
|
||||
->willReturn(TRUE);
|
||||
$entities['other_test'] = $this->createMock('Drupal\search\SearchPageInterface');
|
||||
$entities['other_test']->expects($this->once())
|
||||
->method('isIndexable')
|
||||
->will($this->returnValue(FALSE));
|
||||
->willReturn(FALSE);
|
||||
$this->storage->expects($this->once())
|
||||
->method('loadMultiple')
|
||||
->with(['test' => 'test', 'other_test' => 'other_test'])
|
||||
->will($this->returnValue($entities));
|
||||
->willReturn($entities);
|
||||
|
||||
$result = $this->searchPageRepository->getIndexableSearchPages();
|
||||
$this->assertCount(1, $result);
|
||||
|
@ -151,11 +151,11 @@ class SearchPageRepositoryTest extends UnitTestCase {
|
|||
$config->expects($this->once())
|
||||
->method('clear')
|
||||
->with('default_page')
|
||||
->will($this->returnValue($config));
|
||||
->willReturn($config);
|
||||
$this->configFactory->expects($this->once())
|
||||
->method('getEditable')
|
||||
->with('search.settings')
|
||||
->will($this->returnValue($config));
|
||||
->willReturn($config);
|
||||
$this->searchPageRepository->clearDefaultSearchPage();
|
||||
}
|
||||
|
||||
|
@ -166,10 +166,10 @@ class SearchPageRepositoryTest extends UnitTestCase {
|
|||
$this->query->expects($this->once())
|
||||
->method('condition')
|
||||
->with('status', TRUE)
|
||||
->will($this->returnValue($this->query));
|
||||
->willReturn($this->query);
|
||||
$this->query->expects($this->once())
|
||||
->method('execute')
|
||||
->will($this->returnValue(['test' => 'test', 'other_test' => 'other_test']));
|
||||
->willReturn(['test' => 'test', 'other_test' => 'other_test']);
|
||||
|
||||
$config = $this->getMockBuilder('Drupal\Core\Config\Config')
|
||||
->disableOriginalConstructor()
|
||||
|
@ -177,11 +177,11 @@ class SearchPageRepositoryTest extends UnitTestCase {
|
|||
$config->expects($this->once())
|
||||
->method('get')
|
||||
->with('default_page')
|
||||
->will($this->returnValue('test'));
|
||||
->willReturn('test');
|
||||
$this->configFactory->expects($this->once())
|
||||
->method('get')
|
||||
->with('search.settings')
|
||||
->will($this->returnValue($config));
|
||||
->willReturn($config);
|
||||
|
||||
$this->assertSame('test', $this->searchPageRepository->getDefaultSearchPage());
|
||||
}
|
||||
|
@ -193,10 +193,10 @@ class SearchPageRepositoryTest extends UnitTestCase {
|
|||
$this->query->expects($this->once())
|
||||
->method('condition')
|
||||
->with('status', TRUE)
|
||||
->will($this->returnValue($this->query));
|
||||
->willReturn($this->query);
|
||||
$this->query->expects($this->once())
|
||||
->method('execute')
|
||||
->will($this->returnValue(['test' => 'test']));
|
||||
->willReturn(['test' => 'test']);
|
||||
|
||||
$config = $this->getMockBuilder('Drupal\Core\Config\Config')
|
||||
->disableOriginalConstructor()
|
||||
|
@ -204,11 +204,11 @@ class SearchPageRepositoryTest extends UnitTestCase {
|
|||
$config->expects($this->once())
|
||||
->method('get')
|
||||
->with('default_page')
|
||||
->will($this->returnValue('other_test'));
|
||||
->willReturn('other_test');
|
||||
$this->configFactory->expects($this->once())
|
||||
->method('get')
|
||||
->with('search.settings')
|
||||
->will($this->returnValue($config));
|
||||
->willReturn($config);
|
||||
|
||||
$this->assertSame('test', $this->searchPageRepository->getDefaultSearchPage());
|
||||
}
|
||||
|
@ -224,25 +224,25 @@ class SearchPageRepositoryTest extends UnitTestCase {
|
|||
$config->expects($this->once())
|
||||
->method('set')
|
||||
->with('default_page', $id)
|
||||
->will($this->returnValue($config));
|
||||
->willReturn($config);
|
||||
$config->expects($this->once())
|
||||
->method('save')
|
||||
->will($this->returnValue($config));
|
||||
->willReturn($config);
|
||||
$this->configFactory->expects($this->once())
|
||||
->method('getEditable')
|
||||
->with('search.settings')
|
||||
->will($this->returnValue($config));
|
||||
->willReturn($config);
|
||||
|
||||
$search_page = $this->createMock('Drupal\search\SearchPageInterface');
|
||||
$search_page->expects($this->once())
|
||||
->method('id')
|
||||
->will($this->returnValue($id));
|
||||
->willReturn($id);
|
||||
$search_page->expects($this->once())
|
||||
->method('enable')
|
||||
->will($this->returnValue($search_page));
|
||||
->willReturn($search_page);
|
||||
$search_page->expects($this->once())
|
||||
->method('save')
|
||||
->will($this->returnValue($search_page));
|
||||
->willReturn($search_page);
|
||||
$this->searchPageRepository->setDefaultSearchPage($search_page);
|
||||
}
|
||||
|
||||
|
@ -253,10 +253,10 @@ class SearchPageRepositoryTest extends UnitTestCase {
|
|||
$entity_type = $this->createMock('Drupal\Core\Entity\EntityTypeInterface');
|
||||
$entity_type->expects($this->any())
|
||||
->method('getClass')
|
||||
->will($this->returnValue('Drupal\Tests\search\Unit\TestSearchPage'));
|
||||
->willReturn('Drupal\Tests\search\Unit\TestSearchPage');
|
||||
$this->storage->expects($this->once())
|
||||
->method('getEntityType')
|
||||
->will($this->returnValue($entity_type));
|
||||
->willReturn($entity_type);
|
||||
|
||||
// Declare entities out of their expected order so we can be sure they were
|
||||
// sorted. We cannot mock these because of uasort(), see
|
||||
|
|
|
@ -47,7 +47,7 @@ class SearchPluginCollectionTest extends UnitTestCase {
|
|||
$plugin = $this->createMock('Drupal\search\Plugin\SearchInterface');
|
||||
$this->pluginManager->expects($this->once())
|
||||
->method('createInstance')
|
||||
->will($this->returnValue($plugin));
|
||||
->willReturn($plugin);
|
||||
$this->assertSame($plugin, $this->searchPluginCollection->get('banana'));
|
||||
}
|
||||
|
||||
|
@ -59,11 +59,11 @@ class SearchPluginCollectionTest extends UnitTestCase {
|
|||
$plugin->expects($this->once())
|
||||
->method('setSearchPageId')
|
||||
->with('fruit_stand')
|
||||
->will($this->returnValue($plugin));
|
||||
->willReturn($plugin);
|
||||
|
||||
$this->pluginManager->expects($this->once())
|
||||
->method('createInstance')
|
||||
->will($this->returnValue($plugin));
|
||||
->willReturn($plugin);
|
||||
|
||||
$this->assertSame($plugin, $this->searchPluginCollection->get('banana'));
|
||||
}
|
||||
|
|
|
@ -65,7 +65,7 @@ class XmlEncoderTest extends UnitTestCase {
|
|||
$this->baseEncoder->expects($this->once())
|
||||
->method('encode')
|
||||
->with($this->testArray, 'test', [])
|
||||
->will($this->returnValue('test'));
|
||||
->willReturn('test');
|
||||
|
||||
$this->assertEquals('test', $this->encoder->encode($this->testArray, 'test'));
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ class XmlEncoderTest extends UnitTestCase {
|
|||
$this->baseEncoder->expects($this->once())
|
||||
->method('decode')
|
||||
->with('test', 'test', [])
|
||||
->will($this->returnValue($this->testArray));
|
||||
->willReturn($this->testArray);
|
||||
|
||||
$this->assertEquals($this->testArray, $this->encoder->decode('test', 'test'));
|
||||
}
|
||||
|
|
|
@ -140,7 +140,7 @@ class ChainEntityResolverTest extends UnitTestCase {
|
|||
$mock->expects($this->once())
|
||||
->method('resolve')
|
||||
->with($this->testNormalizer, $this->testData, $this->testEntityType)
|
||||
->will($this->returnValue($return));
|
||||
->willReturn($return);
|
||||
}
|
||||
else {
|
||||
$mock->expects($this->never())
|
||||
|
|
|
@ -57,7 +57,7 @@ class UuidResolverTest extends UnitTestCase {
|
|||
$normalizer->expects($this->once())
|
||||
->method('getUuid')
|
||||
->with([])
|
||||
->will($this->returnValue(NULL));
|
||||
->willReturn(NULL);
|
||||
$this->assertNull($this->resolver->resolve($normalizer, [], 'test_type'));
|
||||
}
|
||||
|
||||
|
@ -70,13 +70,13 @@ class UuidResolverTest extends UnitTestCase {
|
|||
$this->entityRepository->expects($this->once())
|
||||
->method('loadEntityByUuid')
|
||||
->with('test_type')
|
||||
->will($this->returnValue(NULL));
|
||||
->willReturn(NULL);
|
||||
|
||||
$normalizer = $this->createMock('Drupal\serialization\EntityResolver\UuidReferenceInterface');
|
||||
$normalizer->expects($this->once())
|
||||
->method('getUuid')
|
||||
->with([])
|
||||
->will($this->returnValue($uuid));
|
||||
->willReturn($uuid);
|
||||
|
||||
$this->assertNull($this->resolver->resolve($normalizer, [], 'test_type'));
|
||||
}
|
||||
|
@ -90,18 +90,18 @@ class UuidResolverTest extends UnitTestCase {
|
|||
$entity = $this->createMock('Drupal\Core\Entity\EntityInterface');
|
||||
$entity->expects($this->once())
|
||||
->method('id')
|
||||
->will($this->returnValue(1));
|
||||
->willReturn(1);
|
||||
|
||||
$this->entityRepository->expects($this->once())
|
||||
->method('loadEntityByUuid')
|
||||
->with('test_type', $uuid)
|
||||
->will($this->returnValue($entity));
|
||||
->willReturn($entity);
|
||||
|
||||
$normalizer = $this->createMock('Drupal\serialization\EntityResolver\UuidReferenceInterface');
|
||||
$normalizer->expects($this->once())
|
||||
->method('getUuid')
|
||||
->with([])
|
||||
->will($this->returnValue($uuid));
|
||||
->willReturn($uuid);
|
||||
$this->assertSame(1, $this->resolver->resolve($normalizer, [], 'test_type'));
|
||||
}
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ class ConfigEntityNormalizerTest extends UnitTestCase {
|
|||
$config_entity = $this->createMock('Drupal\Core\Config\Entity\ConfigEntityInterface');
|
||||
$config_entity->expects($this->once())
|
||||
->method('toArray')
|
||||
->will($this->returnValue($test_export_properties));
|
||||
->willReturn($test_export_properties);
|
||||
|
||||
$this->assertSame(['test' => 'test'], $normalizer->normalize($config_entity));
|
||||
}
|
||||
|
|
|
@ -67,7 +67,7 @@ class ContentEntityNormalizerTest extends UnitTestCase {
|
|||
$this->serializer->expects($this->any())
|
||||
->method('normalize')
|
||||
->with($this->containsOnlyInstancesOf('Drupal\Core\Field\FieldItemListInterface'), 'test_format', ['account' => NULL])
|
||||
->will($this->returnValue('test'));
|
||||
->willReturn('test');
|
||||
|
||||
$definitions = [
|
||||
'field_accessible_external' => $this->createMockFieldListItem(TRUE, FALSE),
|
||||
|
@ -101,7 +101,7 @@ class ContentEntityNormalizerTest extends UnitTestCase {
|
|||
$this->serializer->expects($this->any())
|
||||
->method('normalize')
|
||||
->with($this->containsOnlyInstancesOf('Drupal\Core\Field\FieldItemListInterface'), 'test_format', $context)
|
||||
->will($this->returnValue('test'));
|
||||
->willReturn('test');
|
||||
|
||||
// The mock account should get passed directly into the access() method on
|
||||
// field items from $context['account'].
|
||||
|
@ -137,7 +137,7 @@ class ContentEntityNormalizerTest extends UnitTestCase {
|
|||
->shouldBeCalled();
|
||||
$content_entity_mock->expects($this->any())
|
||||
->method('getTypedData')
|
||||
->will($this->returnValue($typed_data->reveal()));
|
||||
->willReturn($typed_data->reveal());
|
||||
|
||||
return $content_entity_mock;
|
||||
}
|
||||
|
@ -159,7 +159,7 @@ class ContentEntityNormalizerTest extends UnitTestCase {
|
|||
$mock = $this->createMock('Drupal\Core\Field\FieldItemListInterface');
|
||||
$mock->expects($this->once())
|
||||
->method('getDataDefinition')
|
||||
->will($this->returnValue($data_definition->reveal()));
|
||||
->willReturn($data_definition->reveal());
|
||||
$data_definition->isInternal()
|
||||
->willReturn($internal)
|
||||
->shouldBeCalled();
|
||||
|
@ -167,7 +167,7 @@ class ContentEntityNormalizerTest extends UnitTestCase {
|
|||
$mock->expects($this->once())
|
||||
->method('access')
|
||||
->with('view', $user_context)
|
||||
->will($this->returnValue($access));
|
||||
->willReturn($access);
|
||||
}
|
||||
return $mock;
|
||||
}
|
||||
|
|
|
@ -87,7 +87,7 @@ class EntityNormalizerTest extends UnitTestCase {
|
|||
->getMockForAbstractClass();
|
||||
$content_entity->expects($this->once())
|
||||
->method('getFields')
|
||||
->will($this->returnValue($definitions));
|
||||
->willReturn($definitions);
|
||||
|
||||
$serializer = $this->getMockBuilder('Symfony\Component\Serializer\Serializer')
|
||||
->disableOriginalConstructor()
|
||||
|
@ -137,11 +137,11 @@ class EntityNormalizerTest extends UnitTestCase {
|
|||
$entity_type->expects($this->once())
|
||||
->method('hasKey')
|
||||
->with('bundle')
|
||||
->will($this->returnValue(TRUE));
|
||||
->willReturn(TRUE);
|
||||
$entity_type->expects($this->once())
|
||||
->method('getKey')
|
||||
->with('bundle')
|
||||
->will($this->returnValue('test_type'));
|
||||
->willReturn('test_type');
|
||||
$entity_type->expects($this->once())
|
||||
->method('entityClassImplements')
|
||||
->with(FieldableEntityInterface::class)
|
||||
|
@ -149,17 +149,17 @@ class EntityNormalizerTest extends UnitTestCase {
|
|||
|
||||
$entity_type->expects($this->once())
|
||||
->method('getBundleEntityType')
|
||||
->will($this->returnValue('test_bundle'));
|
||||
->willReturn('test_bundle');
|
||||
|
||||
$entity_type_storage_definition = $this->createMock('Drupal\Core\Field\FieldStorageDefinitionInterface');
|
||||
$entity_type_storage_definition->expects($this->once())
|
||||
->method('getMainPropertyName')
|
||||
->will($this->returnValue('name'));
|
||||
->willReturn('name');
|
||||
|
||||
$entity_type_definition = $this->createMock('Drupal\Core\Field\FieldDefinitionInterface');
|
||||
$entity_type_definition->expects($this->once())
|
||||
->method('getFieldStorageDefinition')
|
||||
->will($this->returnValue($entity_type_storage_definition));
|
||||
->willReturn($entity_type_storage_definition);
|
||||
|
||||
$base_definitions = [
|
||||
'test_type' => $entity_type_definition,
|
||||
|
@ -168,21 +168,21 @@ class EntityNormalizerTest extends UnitTestCase {
|
|||
$this->entityTypeManager->expects($this->once())
|
||||
->method('getDefinition')
|
||||
->with('test')
|
||||
->will($this->returnValue($entity_type));
|
||||
->willReturn($entity_type);
|
||||
$this->entityFieldManager->expects($this->once())
|
||||
->method('getBaseFieldDefinitions')
|
||||
->with('test')
|
||||
->will($this->returnValue($base_definitions));
|
||||
->willReturn($base_definitions);
|
||||
|
||||
$entity_query_mock = $this->createMock('Drupal\Core\Entity\Query\QueryInterface');
|
||||
$entity_query_mock->expects($this->once())
|
||||
->method('execute')
|
||||
->will($this->returnValue(['test_bundle' => 'test_bundle']));
|
||||
->willReturn(['test_bundle' => 'test_bundle']);
|
||||
|
||||
$entity_type_storage = $this->createMock('Drupal\Core\Entity\EntityStorageInterface');
|
||||
$entity_type_storage->expects($this->once())
|
||||
->method('getQuery')
|
||||
->will($this->returnValue($entity_query_mock));
|
||||
->willReturn($entity_query_mock);
|
||||
|
||||
$key_1 = $this->createMock(FieldItemListInterface::class);
|
||||
$key_2 = $this->createMock(FieldItemListInterface::class);
|
||||
|
@ -204,7 +204,7 @@ class EntityNormalizerTest extends UnitTestCase {
|
|||
$storage->expects($this->once())
|
||||
->method('create')
|
||||
->with($expected_test_data)
|
||||
->will($this->returnValue($entity));
|
||||
->willReturn($entity);
|
||||
|
||||
$this->entityTypeManager->expects($this->exactly(2))
|
||||
->method('getStorage')
|
||||
|
@ -253,11 +253,11 @@ class EntityNormalizerTest extends UnitTestCase {
|
|||
$entity_type->expects($this->once())
|
||||
->method('hasKey')
|
||||
->with('bundle')
|
||||
->will($this->returnValue(TRUE));
|
||||
->willReturn(TRUE);
|
||||
$entity_type->expects($this->once())
|
||||
->method('getKey')
|
||||
->with('bundle')
|
||||
->will($this->returnValue('test_type'));
|
||||
->willReturn('test_type');
|
||||
$entity_type->expects($this->once())
|
||||
->method('entityClassImplements')
|
||||
->with(FieldableEntityInterface::class)
|
||||
|
@ -265,17 +265,17 @@ class EntityNormalizerTest extends UnitTestCase {
|
|||
|
||||
$entity_type->expects($this->once())
|
||||
->method('getBundleEntityType')
|
||||
->will($this->returnValue('test_bundle'));
|
||||
->willReturn('test_bundle');
|
||||
|
||||
$entity_type_storage_definition = $this->createMock('Drupal\Core\Field\FieldStorageDefinitionInterface');
|
||||
$entity_type_storage_definition->expects($this->once())
|
||||
->method('getMainPropertyName')
|
||||
->will($this->returnValue('name'));
|
||||
->willReturn('name');
|
||||
|
||||
$entity_type_definition = $this->createMock('Drupal\Core\Field\FieldDefinitionInterface');
|
||||
$entity_type_definition->expects($this->once())
|
||||
->method('getFieldStorageDefinition')
|
||||
->will($this->returnValue($entity_type_storage_definition));
|
||||
->willReturn($entity_type_storage_definition);
|
||||
|
||||
$base_definitions = [
|
||||
'test_type' => $entity_type_definition,
|
||||
|
@ -284,26 +284,26 @@ class EntityNormalizerTest extends UnitTestCase {
|
|||
$this->entityTypeManager->expects($this->once())
|
||||
->method('getDefinition')
|
||||
->with('test')
|
||||
->will($this->returnValue($entity_type));
|
||||
->willReturn($entity_type);
|
||||
$this->entityFieldManager->expects($this->once())
|
||||
->method('getBaseFieldDefinitions')
|
||||
->with('test')
|
||||
->will($this->returnValue($base_definitions));
|
||||
->willReturn($base_definitions);
|
||||
|
||||
$entity_query_mock = $this->createMock('Drupal\Core\Entity\Query\QueryInterface');
|
||||
$entity_query_mock->expects($this->once())
|
||||
->method('execute')
|
||||
->will($this->returnValue(['test_bundle_other' => 'test_bundle_other']));
|
||||
->willReturn(['test_bundle_other' => 'test_bundle_other']);
|
||||
|
||||
$entity_type_storage = $this->createMock('Drupal\Core\Entity\EntityStorageInterface');
|
||||
$entity_type_storage->expects($this->once())
|
||||
->method('getQuery')
|
||||
->will($this->returnValue($entity_query_mock));
|
||||
->willReturn($entity_query_mock);
|
||||
|
||||
$this->entityTypeManager->expects($this->once())
|
||||
->method('getStorage')
|
||||
->with('test_bundle')
|
||||
->will($this->returnValue($entity_type_storage));
|
||||
->willReturn($entity_type_storage);
|
||||
|
||||
$this->expectException(UnexpectedValueException::class);
|
||||
$this->entityNormalizer->denormalize($test_data, 'Drupal\Core\Entity\ContentEntityBase', NULL, ['entity_type' => 'test']);
|
||||
|
@ -328,14 +328,14 @@ class EntityNormalizerTest extends UnitTestCase {
|
|||
$entity_type->expects($this->once())
|
||||
->method('hasKey')
|
||||
->with('bundle')
|
||||
->will($this->returnValue(FALSE));
|
||||
->willReturn(FALSE);
|
||||
$entity_type->expects($this->never())
|
||||
->method('getKey');
|
||||
|
||||
$this->entityTypeManager->expects($this->once())
|
||||
->method('getDefinition')
|
||||
->with('test')
|
||||
->will($this->returnValue($entity_type));
|
||||
->willReturn($entity_type);
|
||||
|
||||
$key_1 = $this->createMock(FieldItemListInterface::class);
|
||||
$key_2 = $this->createMock(FieldItemListInterface::class);
|
||||
|
@ -352,12 +352,12 @@ class EntityNormalizerTest extends UnitTestCase {
|
|||
$storage->expects($this->once())
|
||||
->method('create')
|
||||
->with([])
|
||||
->will($this->returnValue($entity));
|
||||
->willReturn($entity);
|
||||
|
||||
$this->entityTypeManager->expects($this->once())
|
||||
->method('getStorage')
|
||||
->with('test')
|
||||
->will($this->returnValue($storage));
|
||||
->willReturn($storage);
|
||||
|
||||
$this->entityFieldManager->expects($this->never())
|
||||
->method('getBaseFieldDefinitions');
|
||||
|
@ -403,18 +403,18 @@ class EntityNormalizerTest extends UnitTestCase {
|
|||
$this->entityTypeManager->expects($this->once())
|
||||
->method('getDefinition')
|
||||
->with('test')
|
||||
->will($this->returnValue($entity_type));
|
||||
->willReturn($entity_type);
|
||||
|
||||
$storage = $this->createMock('Drupal\Core\Entity\EntityStorageInterface');
|
||||
$storage->expects($this->once())
|
||||
->method('create')
|
||||
->with($test_data)
|
||||
->will($this->returnValue($this->createMock('Drupal\Core\Entity\EntityInterface')));
|
||||
->willReturn($this->createMock('Drupal\Core\Entity\EntityInterface'));
|
||||
|
||||
$this->entityTypeManager->expects($this->once())
|
||||
->method('getStorage')
|
||||
->with('test')
|
||||
->will($this->returnValue($storage));
|
||||
->willReturn($storage);
|
||||
|
||||
$this->entityFieldManager->expects($this->never())
|
||||
->method('getBaseFieldDefinitions');
|
||||
|
|
|
@ -52,7 +52,7 @@ class ListNormalizerTest extends UnitTestCase {
|
|||
$typed_data_manager = $this->createMock(TypedDataManagerInterface::class);
|
||||
$typed_data_manager->expects($this->any())
|
||||
->method('getPropertyInstance')
|
||||
->will($this->returnValue($this->typedData));
|
||||
->willReturn($this->typedData);
|
||||
|
||||
// Set up a mock container as ItemList() will call for the 'typed_data_manager'
|
||||
// service.
|
||||
|
@ -62,7 +62,7 @@ class ListNormalizerTest extends UnitTestCase {
|
|||
$container->expects($this->any())
|
||||
->method('get')
|
||||
->with($this->equalTo('typed_data_manager'))
|
||||
->will($this->returnValue($typed_data_manager));
|
||||
->willReturn($typed_data_manager);
|
||||
|
||||
\Drupal::setContainer($container);
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ class TypedDataNormalizerTest extends UnitTestCase {
|
|||
public function testNormalize() {
|
||||
$this->typedData->expects($this->once())
|
||||
->method('getValue')
|
||||
->will($this->returnValue('test'));
|
||||
->willReturn('test');
|
||||
|
||||
$this->assertEquals('test', $this->normalizer->normalize($this->typedData));
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ class ShortcutLocalTasksTest extends LocalTaskIntegrationTestBase {
|
|||
$entity_type_manager = $this->createMock(EntityTypeManagerInterface::class);
|
||||
$entity_type_manager->expects($this->any())
|
||||
->method('getDefinitions')
|
||||
->will($this->returnValue([]));
|
||||
->willReturn([]);
|
||||
$this->container->set('entity_type.manager', $entity_type_manager);
|
||||
$this->container->set('string_translation', $this->getStringTranslationStub());
|
||||
}
|
||||
|
|
|
@ -164,7 +164,7 @@ class PathBasedBreadcrumbBuilderTest extends UnitTestCase {
|
|||
public function testBuildWithOnePathElement() {
|
||||
$this->context->expects($this->once())
|
||||
->method('getPathInfo')
|
||||
->will($this->returnValue('/example'));
|
||||
->willReturn('/example');
|
||||
|
||||
$breadcrumb = $this->builder->build($this->createMock('Drupal\Core\Routing\RouteMatchInterface'));
|
||||
$this->assertEquals([0 => new Link('Home', new Url('<front>'))], $breadcrumb->getLinks());
|
||||
|
@ -182,7 +182,7 @@ class PathBasedBreadcrumbBuilderTest extends UnitTestCase {
|
|||
public function testBuildWithTwoPathElements() {
|
||||
$this->context->expects($this->once())
|
||||
->method('getPathInfo')
|
||||
->will($this->returnValue('/example/baz'));
|
||||
->willReturn('/example/baz');
|
||||
$this->setupStubPathProcessor();
|
||||
|
||||
$route_1 = new Route('/example');
|
||||
|
@ -221,7 +221,7 @@ class PathBasedBreadcrumbBuilderTest extends UnitTestCase {
|
|||
public function testBuildWithThreePathElements() {
|
||||
$this->context->expects($this->once())
|
||||
->method('getPathInfo')
|
||||
->will($this->returnValue('/example/bar/baz'));
|
||||
->willReturn('/example/bar/baz');
|
||||
$this->setupStubPathProcessor();
|
||||
|
||||
$route_1 = new Route('/example/bar');
|
||||
|
@ -279,7 +279,7 @@ class PathBasedBreadcrumbBuilderTest extends UnitTestCase {
|
|||
public function testBuildWithException($exception_class, $exception_argument) {
|
||||
$this->context->expects($this->once())
|
||||
->method('getPathInfo')
|
||||
->will($this->returnValue('/example/bar'));
|
||||
->willReturn('/example/bar');
|
||||
$this->setupStubPathProcessor();
|
||||
|
||||
$this->requestMatcher->expects($this->any())
|
||||
|
@ -320,15 +320,15 @@ class PathBasedBreadcrumbBuilderTest extends UnitTestCase {
|
|||
public function testBuildWithNonProcessedPath() {
|
||||
$this->context->expects($this->once())
|
||||
->method('getPathInfo')
|
||||
->will($this->returnValue('/example/bar'));
|
||||
->willReturn('/example/bar');
|
||||
|
||||
$this->pathProcessor->expects($this->once())
|
||||
->method('processInbound')
|
||||
->will($this->returnValue(FALSE));
|
||||
->willReturn(FALSE);
|
||||
|
||||
$this->requestMatcher->expects($this->any())
|
||||
->method('matchRequest')
|
||||
->will($this->returnValue([]));
|
||||
->willReturn([]);
|
||||
|
||||
$breadcrumb = $this->builder->build($this->createMock('Drupal\Core\Routing\RouteMatchInterface'));
|
||||
|
||||
|
@ -357,7 +357,7 @@ class PathBasedBreadcrumbBuilderTest extends UnitTestCase {
|
|||
public function testBuildWithUserPath() {
|
||||
$this->context->expects($this->once())
|
||||
->method('getPathInfo')
|
||||
->will($this->returnValue('/user/1/edit'));
|
||||
->willReturn('/user/1/edit');
|
||||
$this->setupStubPathProcessor();
|
||||
|
||||
$route_1 = new Route('/user/1');
|
||||
|
@ -378,7 +378,7 @@ class PathBasedBreadcrumbBuilderTest extends UnitTestCase {
|
|||
$this->titleResolver->expects($this->once())
|
||||
->method('getTitle')
|
||||
->with($this->anything(), $route_1)
|
||||
->will($this->returnValue('Admin'));
|
||||
->willReturn('Admin');
|
||||
|
||||
$breadcrumb = $this->builder->build($this->createMock('Drupal\Core\Routing\RouteMatchInterface'));
|
||||
$this->assertEquals([0 => new Link('Home', new Url('<front>')), 1 => new Link('Admin', new Url('user_page'))], $breadcrumb->getLinks());
|
||||
|
|
|
@ -36,9 +36,9 @@ class SystemLocalTasksTest extends LocalTaskIntegrationTestBase {
|
|||
$theme->info = ['name' => 'olivero'];
|
||||
$this->themeHandler->expects($this->any())
|
||||
->method('listInfo')
|
||||
->will($this->returnValue([
|
||||
->willReturn([
|
||||
'olivero' => $theme,
|
||||
]));
|
||||
]);
|
||||
$this->themeHandler->expects($this->any())
|
||||
->method('hasUi')
|
||||
->with('olivero')
|
||||
|
|
|
@ -34,7 +34,7 @@ class TourTest extends UnitTestCase {
|
|||
|
||||
$tour->expects($this->any())
|
||||
->method('getRoutes')
|
||||
->will($this->returnValue($routes));
|
||||
->willReturn($routes);
|
||||
|
||||
$this->assertSame($result, $tour->hasMatchingRoute($route_name, $route_params));
|
||||
|
||||
|
|
|
@ -91,7 +91,7 @@ class UpdateFetcherTest extends UnitTestCase implements LoggerInterface {
|
|||
$container->expects($this->any())
|
||||
->method('get')
|
||||
->with('logger.factory')
|
||||
->will($this->returnValue($logger_factory));
|
||||
->willReturn($logger_factory);
|
||||
\Drupal::setContainer($container);
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ class UserLocalTasksTest extends LocalTaskIntegrationTestBase {
|
|||
$entity_type_manager = $this->createMock(EntityTypeManagerInterface::class);
|
||||
$entity_type_manager->expects($this->any())
|
||||
->method('getDefinitions')
|
||||
->will($this->returnValue([]));
|
||||
->willReturn([]);
|
||||
$this->container->set('entity_type.manager', $entity_type_manager);
|
||||
$this->container->set('string_translation', $this->getStringTranslationStub());
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ class AddRoleUserTest extends RoleUserTestBase {
|
|||
$this->account->expects($this->any())
|
||||
->method('hasRole')
|
||||
->with($this->equalTo('test_role_1'))
|
||||
->will($this->returnValue(TRUE));
|
||||
->willReturn(TRUE);
|
||||
|
||||
$config = ['rid' => 'test_role_1'];
|
||||
$add_role_plugin = new AddRoleUser($config, 'user_add_role_action', ['type' => 'user'], $this->userRoleEntityType);
|
||||
|
@ -38,7 +38,7 @@ class AddRoleUserTest extends RoleUserTestBase {
|
|||
$this->account->expects($this->any())
|
||||
->method('hasRole')
|
||||
->with($this->equalTo('test_role_1'))
|
||||
->will($this->returnValue(FALSE));
|
||||
->willReturn(FALSE);
|
||||
|
||||
$config = ['rid' => 'test_role_1'];
|
||||
$add_role_plugin = new AddRoleUser($config, 'user_add_role_action', ['type' => 'user'], $this->userRoleEntityType);
|
||||
|
|
|
@ -20,7 +20,7 @@ class RemoveRoleUserTest extends RoleUserTestBase {
|
|||
$this->account->expects($this->any())
|
||||
->method('hasRole')
|
||||
->with($this->equalTo('test_role_1'))
|
||||
->will($this->returnValue(TRUE));
|
||||
->willReturn(TRUE);
|
||||
|
||||
$config = ['rid' => 'test_role_1'];
|
||||
$remove_role_plugin = new RemoveRoleUser($config, 'user_remove_role_action', ['type' => 'user'], $this->userRoleEntityType);
|
||||
|
@ -38,7 +38,7 @@ class RemoveRoleUserTest extends RoleUserTestBase {
|
|||
$this->account->expects($this->any())
|
||||
->method('hasRole')
|
||||
->with($this->equalTo('test_role_1'))
|
||||
->will($this->returnValue(FALSE));
|
||||
->willReturn(FALSE);
|
||||
|
||||
$config = ['rid' => 'test_role_1'];
|
||||
$remove_role_plugin = new RemoveRoleUser($config, 'user_remove_role_action', ['type' => 'user'], $this->userRoleEntityType);
|
||||
|
|
|
@ -22,7 +22,7 @@ class UserTest extends UserSessionTest {
|
|||
$user->expects($this->any())
|
||||
->method('id')
|
||||
// @todo Also test the uid = 1 handling.
|
||||
->will($this->returnValue($authenticated ? 2 : 0));
|
||||
->willReturn($authenticated ? 2 : 0);
|
||||
$roles = [];
|
||||
foreach ($rids as $rid) {
|
||||
$roles[] = (object) [
|
||||
|
@ -32,7 +32,7 @@ class UserTest extends UserSessionTest {
|
|||
$user->expects($this->any())
|
||||
->method('get')
|
||||
->with('roles')
|
||||
->will($this->returnValue($roles));
|
||||
->willReturn($roles);
|
||||
return $user;
|
||||
}
|
||||
|
||||
|
|
|
@ -33,26 +33,26 @@ class UserBulkFormTest extends UnitTestCase {
|
|||
$action = $this->createMock('\Drupal\system\ActionConfigEntityInterface');
|
||||
$action->expects($this->any())
|
||||
->method('getType')
|
||||
->will($this->returnValue('user'));
|
||||
->willReturn('user');
|
||||
$actions[$i] = $action;
|
||||
}
|
||||
|
||||
$action = $this->createMock('\Drupal\system\ActionConfigEntityInterface');
|
||||
$action->expects($this->any())
|
||||
->method('getType')
|
||||
->will($this->returnValue('node'));
|
||||
->willReturn('node');
|
||||
$actions[] = $action;
|
||||
|
||||
$entity_storage = $this->createMock('Drupal\Core\Entity\EntityStorageInterface');
|
||||
$entity_storage->expects($this->any())
|
||||
->method('loadMultiple')
|
||||
->will($this->returnValue($actions));
|
||||
->willReturn($actions);
|
||||
|
||||
$entity_type_manager = $this->createMock(EntityTypeManagerInterface::class);
|
||||
$entity_type_manager->expects($this->once())
|
||||
->method('getStorage')
|
||||
->with('action')
|
||||
->will($this->returnValue($entity_storage));
|
||||
->willReturn($entity_storage);
|
||||
|
||||
$entity_repository = $this->createMock(EntityRepositoryInterface::class);
|
||||
|
||||
|
@ -66,7 +66,7 @@ class UserBulkFormTest extends UnitTestCase {
|
|||
$views_data->expects($this->any())
|
||||
->method('get')
|
||||
->with('users')
|
||||
->will($this->returnValue(['table' => ['entity type' => 'user']]));
|
||||
->willReturn(['table' => ['entity type' => 'user']]);
|
||||
$container = new ContainerBuilder();
|
||||
$container->set('views.views_data', $views_data);
|
||||
$container->set('string_translation', $this->getStringTranslationStub());
|
||||
|
@ -76,7 +76,7 @@ class UserBulkFormTest extends UnitTestCase {
|
|||
$storage->expects($this->any())
|
||||
->method('get')
|
||||
->with('base_table')
|
||||
->will($this->returnValue('users'));
|
||||
->willReturn('users');
|
||||
|
||||
$executable = $this->getMockBuilder('Drupal\views\ViewExecutable')
|
||||
->disableOriginalConstructor()
|
||||
|
|
|
@ -77,11 +77,11 @@ class UserAccessControlHandlerTest extends UnitTestCase {
|
|||
$this->viewer
|
||||
->expects($this->any())
|
||||
->method('hasPermission')
|
||||
->will($this->returnValue(FALSE));
|
||||
->willReturn(FALSE);
|
||||
$this->viewer
|
||||
->expects($this->any())
|
||||
->method('id')
|
||||
->will($this->returnValue(1));
|
||||
->willReturn(1);
|
||||
|
||||
$this->owner = $this->createMock('\Drupal\Core\Session\AccountInterface');
|
||||
$this->owner
|
||||
|
@ -95,13 +95,13 @@ class UserAccessControlHandlerTest extends UnitTestCase {
|
|||
$this->owner
|
||||
->expects($this->any())
|
||||
->method('id')
|
||||
->will($this->returnValue(2));
|
||||
->willReturn(2);
|
||||
|
||||
$this->admin = $this->createMock('\Drupal\Core\Session\AccountInterface');
|
||||
$this->admin
|
||||
->expects($this->any())
|
||||
->method('hasPermission')
|
||||
->will($this->returnValue(TRUE));
|
||||
->willReturn(TRUE);
|
||||
|
||||
$this->emailViewer = $this->createMock('\Drupal\Core\Session\AccountInterface');
|
||||
$this->emailViewer
|
||||
|
@ -113,7 +113,7 @@ class UserAccessControlHandlerTest extends UnitTestCase {
|
|||
$this->emailViewer
|
||||
->expects($this->any())
|
||||
->method('id')
|
||||
->will($this->returnValue(3));
|
||||
->willReturn(3);
|
||||
|
||||
$entity_type = $this->createMock('Drupal\Core\Entity\EntityTypeInterface');
|
||||
|
||||
|
@ -127,7 +127,7 @@ class UserAccessControlHandlerTest extends UnitTestCase {
|
|||
$this->items
|
||||
->expects($this->any())
|
||||
->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->expects($this->any())
|
||||
->method('getName')
|
||||
->will($this->returnValue($field));
|
||||
->willReturn($field);
|
||||
|
||||
$this->items
|
||||
->expects($this->any())
|
||||
->method('getEntity')
|
||||
->will($this->returnValue($this->{$target}));
|
||||
->willReturn($this->{$target});
|
||||
|
||||
foreach (['view' => $view, 'edit' => $edit] as $operation => $result) {
|
||||
$result_text = !isset($result) ? 'null' : ($result ? 'true' : 'false');
|
||||
|
|
|
@ -72,7 +72,7 @@ class UserAuthTest extends UnitTestCase {
|
|||
$entity_type_manager->expects($this->any())
|
||||
->method('getStorage')
|
||||
->with('user')
|
||||
->will($this->returnValue($this->userStorage));
|
||||
->willReturn($this->userStorage);
|
||||
|
||||
$this->passwordService = $this->createMock('Drupal\Core\Password\PasswordInterface');
|
||||
|
||||
|
@ -121,7 +121,7 @@ class UserAuthTest extends UnitTestCase {
|
|||
$this->userStorage->expects($this->once())
|
||||
->method('loadByProperties')
|
||||
->with(['name' => $this->username])
|
||||
->will($this->returnValue([]));
|
||||
->willReturn([]);
|
||||
|
||||
$this->assertFalse($this->userAuth->authenticate($this->username, $this->password));
|
||||
}
|
||||
|
@ -135,12 +135,12 @@ class UserAuthTest extends UnitTestCase {
|
|||
$this->userStorage->expects($this->once())
|
||||
->method('loadByProperties')
|
||||
->with(['name' => $this->username])
|
||||
->will($this->returnValue([$this->testUser]));
|
||||
->willReturn([$this->testUser]);
|
||||
|
||||
$this->passwordService->expects($this->once())
|
||||
->method('check')
|
||||
->with($this->password, $this->testUser->getPassword())
|
||||
->will($this->returnValue(FALSE));
|
||||
->willReturn(FALSE);
|
||||
|
||||
$this->assertFalse($this->userAuth->authenticate($this->username, $this->password));
|
||||
}
|
||||
|
@ -153,17 +153,17 @@ class UserAuthTest extends UnitTestCase {
|
|||
public function testAuthenticateWithCorrectPassword() {
|
||||
$this->testUser->expects($this->once())
|
||||
->method('id')
|
||||
->will($this->returnValue(1));
|
||||
->willReturn(1);
|
||||
|
||||
$this->userStorage->expects($this->once())
|
||||
->method('loadByProperties')
|
||||
->with(['name' => $this->username])
|
||||
->will($this->returnValue([$this->testUser]));
|
||||
->willReturn([$this->testUser]);
|
||||
|
||||
$this->passwordService->expects($this->once())
|
||||
->method('check')
|
||||
->with($this->password, $this->testUser->getPassword())
|
||||
->will($this->returnValue(TRUE));
|
||||
->willReturn(TRUE);
|
||||
|
||||
$this->assertSame(1, $this->userAuth->authenticate($this->username, $this->password));
|
||||
}
|
||||
|
@ -180,17 +180,17 @@ class UserAuthTest extends UnitTestCase {
|
|||
public function testAuthenticateWithZeroPassword() {
|
||||
$this->testUser->expects($this->once())
|
||||
->method('id')
|
||||
->will($this->returnValue(2));
|
||||
->willReturn(2);
|
||||
|
||||
$this->userStorage->expects($this->once())
|
||||
->method('loadByProperties')
|
||||
->with(['name' => $this->username])
|
||||
->will($this->returnValue([$this->testUser]));
|
||||
->willReturn([$this->testUser]);
|
||||
|
||||
$this->passwordService->expects($this->once())
|
||||
->method('check')
|
||||
->with(0, 0)
|
||||
->will($this->returnValue(TRUE));
|
||||
->willReturn(TRUE);
|
||||
|
||||
$this->assertSame(2, $this->userAuth->authenticate($this->username, 0));
|
||||
}
|
||||
|
@ -203,7 +203,7 @@ class UserAuthTest extends UnitTestCase {
|
|||
public function testAuthenticateWithCorrectPasswordAndNewPasswordHash() {
|
||||
$this->testUser->expects($this->once())
|
||||
->method('id')
|
||||
->will($this->returnValue(1));
|
||||
->willReturn(1);
|
||||
$this->testUser->expects($this->once())
|
||||
->method('setPassword')
|
||||
->with($this->password);
|
||||
|
@ -213,16 +213,16 @@ class UserAuthTest extends UnitTestCase {
|
|||
$this->userStorage->expects($this->once())
|
||||
->method('loadByProperties')
|
||||
->with(['name' => $this->username])
|
||||
->will($this->returnValue([$this->testUser]));
|
||||
->willReturn([$this->testUser]);
|
||||
|
||||
$this->passwordService->expects($this->once())
|
||||
->method('check')
|
||||
->with($this->password, $this->testUser->getPassword())
|
||||
->will($this->returnValue(TRUE));
|
||||
->willReturn(TRUE);
|
||||
$this->passwordService->expects($this->once())
|
||||
->method('needsRehash')
|
||||
->with($this->testUser->getPassword())
|
||||
->will($this->returnValue(TRUE));
|
||||
->willReturn(TRUE);
|
||||
|
||||
$this->assertSame(1, $this->userAuth->authenticate($this->username, $this->password));
|
||||
}
|
||||
|
|
|
@ -46,19 +46,19 @@ class RolesRidTest extends UnitTestCase {
|
|||
$entity_type->expects($this->any())
|
||||
->method('getKey')
|
||||
->with('label')
|
||||
->will($this->returnValue('label'));
|
||||
->willReturn('label');
|
||||
|
||||
$entity_type_manager = $this->createMock(EntityTypeManagerInterface::class);
|
||||
$entity_type_manager->expects($this->any())
|
||||
->method('getDefinition')
|
||||
->with($this->equalTo('user_role'))
|
||||
->will($this->returnValue($entity_type));
|
||||
->willReturn($entity_type);
|
||||
|
||||
$entity_type_manager
|
||||
->expects($this->once())
|
||||
->method('getStorage')
|
||||
->with($this->equalTo('user_role'))
|
||||
->will($this->returnValue($role_storage));
|
||||
->willReturn($role_storage);
|
||||
|
||||
// Set up a minimal container to satisfy Drupal\Core\Entity\EntityBase's
|
||||
// dependency on it.
|
||||
|
|
|
@ -134,7 +134,7 @@ class ViewAjaxControllerTest extends UnitTestCase {
|
|||
$this->viewStorage->expects($this->once())
|
||||
->method('load')
|
||||
->with('test_view')
|
||||
->will($this->returnValue(FALSE));
|
||||
->willReturn(FALSE);
|
||||
|
||||
$this->expectException(NotFoundHttpException::class);
|
||||
$this->viewAjaxController->ajaxView($request);
|
||||
|
@ -155,19 +155,19 @@ class ViewAjaxControllerTest extends UnitTestCase {
|
|||
$this->viewStorage->expects($this->once())
|
||||
->method('load')
|
||||
->with('test_view')
|
||||
->will($this->returnValue($view));
|
||||
->willReturn($view);
|
||||
|
||||
$executable = $this->getMockBuilder('Drupal\views\ViewExecutable')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$executable->expects($this->once())
|
||||
->method('access')
|
||||
->will($this->returnValue(FALSE));
|
||||
->willReturn(FALSE);
|
||||
|
||||
$this->executableFactory->expects($this->once())
|
||||
->method('get')
|
||||
->with($view)
|
||||
->will($this->returnValue($executable));
|
||||
->willReturn($executable);
|
||||
|
||||
$this->expectException(AccessDeniedHttpException::class);
|
||||
$this->viewAjaxController->ajaxView($request);
|
||||
|
@ -336,7 +336,7 @@ class ViewAjaxControllerTest extends UnitTestCase {
|
|||
$display_collection->expects($this->any())
|
||||
->method('get')
|
||||
->with('page_1')
|
||||
->will($this->returnValue($display_handler));
|
||||
->willReturn($display_handler);
|
||||
$executable->displayHandlers = $display_collection;
|
||||
|
||||
$response = $this->viewAjaxController->ajaxView($request);
|
||||
|
@ -367,25 +367,25 @@ class ViewAjaxControllerTest extends UnitTestCase {
|
|||
$this->viewStorage->expects($this->once())
|
||||
->method('load')
|
||||
->with('test_view')
|
||||
->will($this->returnValue($view));
|
||||
->willReturn($view);
|
||||
|
||||
$executable = $this->getMockBuilder('Drupal\views\ViewExecutable')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$executable->expects($this->once())
|
||||
->method('access')
|
||||
->will($this->returnValue(TRUE));
|
||||
->willReturn(TRUE);
|
||||
$executable->expects($this->any())
|
||||
->method('setDisplay')
|
||||
->willReturn(TRUE);
|
||||
$executable->expects($this->atMost(1))
|
||||
->method('preview')
|
||||
->will($this->returnValue(['#markup' => 'View result']));
|
||||
->willReturn(['#markup' => 'View result']);
|
||||
|
||||
$this->executableFactory->expects($this->once())
|
||||
->method('get')
|
||||
->with($view)
|
||||
->will($this->returnValue($executable));
|
||||
->willReturn($executable);
|
||||
|
||||
$display_handler = $this->getMockBuilder('Drupal\views\Plugin\views\display\DisplayPluginBase')
|
||||
->disableOriginalConstructor()
|
||||
|
@ -403,7 +403,7 @@ class ViewAjaxControllerTest extends UnitTestCase {
|
|||
$display_collection->expects($this->any())
|
||||
->method('get')
|
||||
->with('page_1')
|
||||
->will($this->returnValue($display_handler));
|
||||
->willReturn($display_handler);
|
||||
|
||||
$executable->display_handler = $display_handler;
|
||||
$executable->displayHandlers = $display_collection;
|
||||
|
|
|
@ -59,7 +59,7 @@ class RouteSubscriberTest extends UnitTestCase {
|
|||
$this->entityTypeManager->expects($this->any())
|
||||
->method('getStorage')
|
||||
->with('view')
|
||||
->will($this->returnValue($this->viewStorage));
|
||||
->willReturn($this->viewStorage);
|
||||
$this->state = $this->createMock('\Drupal\Core\State\StateInterface');
|
||||
$this->routeSubscriber = new TestRouteSubscriber($this->entityTypeManager, $this->state);
|
||||
}
|
||||
|
@ -72,10 +72,10 @@ class RouteSubscriberTest extends UnitTestCase {
|
|||
|
||||
$display_1->expects($this->once())
|
||||
->method('collectRoutes')
|
||||
->will($this->returnValue(['test_id.page_1' => 'views.test_id.page_1']));
|
||||
->willReturn(['test_id.page_1' => 'views.test_id.page_1']);
|
||||
$display_2->expects($this->once())
|
||||
->method('collectRoutes')
|
||||
->will($this->returnValue(['test_id.page_2' => 'views.test_id.page_2']));
|
||||
->willReturn(['test_id.page_2' => 'views.test_id.page_2']);
|
||||
|
||||
$this->routeSubscriber->routes();
|
||||
|
||||
|
@ -155,14 +155,14 @@ class RouteSubscriberTest extends UnitTestCase {
|
|||
->getMock();
|
||||
$this->viewStorage->expects($this->any())
|
||||
->method('load')
|
||||
->will($this->returnValue($view));
|
||||
->willReturn($view);
|
||||
|
||||
$view->expects($this->any())
|
||||
->method('getExecutable')
|
||||
->will($this->returnValue($executable));
|
||||
->willReturn($executable);
|
||||
$view->expects($this->any())
|
||||
->method('id')
|
||||
->will($this->returnValue('test_id'));
|
||||
->willReturn('test_id');
|
||||
$executable->storage = $view;
|
||||
|
||||
$executable->expects($this->any())
|
||||
|
|
|
@ -63,7 +63,7 @@ class ViewsBlockTest extends UnitTestCase {
|
|||
$condition_plugin_manager = $this->createMock('Drupal\Core\Executable\ExecutableManagerInterface');
|
||||
$condition_plugin_manager->expects($this->any())
|
||||
->method('getDefinitions')
|
||||
->will($this->returnValue([]));
|
||||
->willReturn([]);
|
||||
$container = new ContainerBuilder();
|
||||
$container->set('plugin.manager.condition', $condition_plugin_manager);
|
||||
\Drupal::setContainer($container);
|
||||
|
@ -75,7 +75,7 @@ class ViewsBlockTest extends UnitTestCase {
|
|||
$this->executable->expects($this->any())
|
||||
->method('setDisplay')
|
||||
->with('block_1')
|
||||
->will($this->returnValue(TRUE));
|
||||
->willReturn(TRUE);
|
||||
$this->executable->expects($this->any())
|
||||
->method('getShowAdminLinks')
|
||||
->willReturn(FALSE);
|
||||
|
@ -99,7 +99,7 @@ class ViewsBlockTest extends UnitTestCase {
|
|||
$this->executableFactory->expects($this->any())
|
||||
->method('get')
|
||||
->with($this->view)
|
||||
->will($this->returnValue($this->executable));
|
||||
->willReturn($this->executable);
|
||||
|
||||
$this->displayHandler = $this->getMockBuilder('Drupal\views\Plugin\views\display\Block')
|
||||
->disableOriginalConstructor()
|
||||
|
@ -126,7 +126,7 @@ class ViewsBlockTest extends UnitTestCase {
|
|||
$this->storage->expects($this->any())
|
||||
->method('load')
|
||||
->with('test_view')
|
||||
->will($this->returnValue($this->view));
|
||||
->willReturn($this->view);
|
||||
$this->account = $this->createMock('Drupal\Core\Session\AccountInterface');
|
||||
}
|
||||
|
||||
|
|
|
@ -87,7 +87,7 @@ class ViewsLocalTaskTest extends UnitTestCase {
|
|||
$display_plugin->expects($this->once())
|
||||
->method('getOption')
|
||||
->with('menu')
|
||||
->will($this->returnValue(['type' => 'normal']));
|
||||
->willReturn(['type' => 'normal']);
|
||||
$executable->display_handler = $display_plugin;
|
||||
|
||||
$storage = $this->getMockBuilder('Drupal\views\Entity\View')
|
||||
|
@ -95,7 +95,7 @@ class ViewsLocalTaskTest extends UnitTestCase {
|
|||
->getMock();
|
||||
$storage->expects($this->any())
|
||||
->method('id')
|
||||
->will($this->returnValue('example_view'));
|
||||
->willReturn('example_view');
|
||||
$storage->expects($this->any())
|
||||
->method('getExecutable')
|
||||
->willReturn($executable);
|
||||
|
@ -124,7 +124,7 @@ class ViewsLocalTaskTest extends UnitTestCase {
|
|||
->getMock();
|
||||
$storage->expects($this->any())
|
||||
->method('id')
|
||||
->will($this->returnValue('example_view'));
|
||||
->willReturn('example_view');
|
||||
$storage->expects($this->any())
|
||||
->method('getExecutable')
|
||||
->willReturn($executable);
|
||||
|
@ -142,7 +142,11 @@ class ViewsLocalTaskTest extends UnitTestCase {
|
|||
$display_plugin->expects($this->once())
|
||||
->method('getOption')
|
||||
->with('menu')
|
||||
->will($this->returnValue(['type' => 'tab', 'weight' => 12, 'title' => 'Example title']));
|
||||
->willReturn([
|
||||
'type' => 'tab',
|
||||
'weight' => 12,
|
||||
'title' => 'Example title',
|
||||
]);
|
||||
$executable->display_handler = $display_plugin;
|
||||
|
||||
$result = [['example_view', 'page_1']];
|
||||
|
@ -154,7 +158,7 @@ class ViewsLocalTaskTest extends UnitTestCase {
|
|||
$this->state->expects($this->once())
|
||||
->method('get')
|
||||
->with('views.view_route_names')
|
||||
->will($this->returnValue($view_route_names));
|
||||
->willReturn($view_route_names);
|
||||
|
||||
$definitions = $this->localTaskDerivative->getDerivativeDefinitions($this->baseDefinition);
|
||||
$this->assertCount(1, $definitions);
|
||||
|
@ -177,7 +181,7 @@ class ViewsLocalTaskTest extends UnitTestCase {
|
|||
->getMock();
|
||||
$storage->expects($this->any())
|
||||
->method('id')
|
||||
->will($this->returnValue('example_view'));
|
||||
->willReturn('example_view');
|
||||
$storage->expects($this->any())
|
||||
->method('getExecutable')
|
||||
->willReturn($executable);
|
||||
|
@ -195,7 +199,7 @@ class ViewsLocalTaskTest extends UnitTestCase {
|
|||
$display_plugin->expects($this->once())
|
||||
->method('getOption')
|
||||
->with('menu')
|
||||
->will($this->returnValue(['type' => 'tab', 'weight' => 12]));
|
||||
->willReturn(['type' => 'tab', 'weight' => 12]);
|
||||
$executable->display_handler = $display_plugin;
|
||||
|
||||
$result = [['example_view', 'page_1']];
|
||||
|
@ -208,7 +212,7 @@ class ViewsLocalTaskTest extends UnitTestCase {
|
|||
$this->state->expects($this->once())
|
||||
->method('get')
|
||||
->with('views.view_route_names')
|
||||
->will($this->returnValue($view_route_names));
|
||||
->willReturn($view_route_names);
|
||||
|
||||
$definitions = $this->localTaskDerivative->getDerivativeDefinitions($this->baseDefinition);
|
||||
$this->assertCount(0, $definitions);
|
||||
|
@ -226,7 +230,7 @@ class ViewsLocalTaskTest extends UnitTestCase {
|
|||
->getMock();
|
||||
$storage->expects($this->any())
|
||||
->method('id')
|
||||
->will($this->returnValue('example_view'));
|
||||
->willReturn('example_view');
|
||||
$storage->expects($this->any())
|
||||
->method('getExecutable')
|
||||
->willReturn($executable);
|
||||
|
@ -244,7 +248,11 @@ class ViewsLocalTaskTest extends UnitTestCase {
|
|||
$display_plugin->expects($this->exactly(2))
|
||||
->method('getOption')
|
||||
->with('menu')
|
||||
->will($this->returnValue(['type' => 'default tab', 'weight' => 12, 'title' => 'Example title']));
|
||||
->willReturn([
|
||||
'type' => 'default tab',
|
||||
'weight' => 12,
|
||||
'title' => 'Example title',
|
||||
]);
|
||||
$executable->display_handler = $display_plugin;
|
||||
|
||||
$result = [['example_view', 'page_1']];
|
||||
|
@ -256,7 +264,7 @@ class ViewsLocalTaskTest extends UnitTestCase {
|
|||
$this->state->expects($this->exactly(2))
|
||||
->method('get')
|
||||
->with('views.view_route_names')
|
||||
->will($this->returnValue($view_route_names));
|
||||
->willReturn($view_route_names);
|
||||
|
||||
$definitions = $this->localTaskDerivative->getDerivativeDefinitions($this->baseDefinition);
|
||||
$this->assertCount(1, $definitions);
|
||||
|
@ -295,7 +303,7 @@ class ViewsLocalTaskTest extends UnitTestCase {
|
|||
->getMock();
|
||||
$storage->expects($this->any())
|
||||
->method('id')
|
||||
->will($this->returnValue('example_view'));
|
||||
->willReturn('example_view');
|
||||
$storage->expects($this->any())
|
||||
->method('getExecutable')
|
||||
->willReturn($executable);
|
||||
|
@ -313,10 +321,14 @@ class ViewsLocalTaskTest extends UnitTestCase {
|
|||
$display_plugin->expects($this->exactly(2))
|
||||
->method('getOption')
|
||||
->with('menu')
|
||||
->will($this->returnValue(['type' => 'tab', 'weight' => 12, 'title' => 'Example title']));
|
||||
->willReturn([
|
||||
'type' => 'tab',
|
||||
'weight' => 12,
|
||||
'title' => 'Example title',
|
||||
]);
|
||||
$display_plugin->expects($this->once())
|
||||
->method('getPath')
|
||||
->will($this->returnValue('path/example'));
|
||||
->willReturn('path/example');
|
||||
$executable->display_handler = $display_plugin;
|
||||
|
||||
$result = [['example_view', 'page_1']];
|
||||
|
@ -328,7 +340,7 @@ class ViewsLocalTaskTest extends UnitTestCase {
|
|||
$this->state->expects($this->exactly(2))
|
||||
->method('get')
|
||||
->with('views.view_route_names')
|
||||
->will($this->returnValue($view_route_names));
|
||||
->willReturn($view_route_names);
|
||||
|
||||
// Mock the route provider.
|
||||
$route_collection = new RouteCollection();
|
||||
|
@ -336,7 +348,7 @@ class ViewsLocalTaskTest extends UnitTestCase {
|
|||
$this->routeProvider->expects($this->any())
|
||||
->method('getRoutesByPattern')
|
||||
->with('/path')
|
||||
->will($this->returnValue($route_collection));
|
||||
->willReturn($route_collection);
|
||||
|
||||
// Setup the existing local task of the test_route.
|
||||
$definitions['test_route_tab'] = $other_tab = [
|
||||
|
|
|
@ -33,7 +33,7 @@ class RawTest extends UnitTestCase {
|
|||
$current_path->setPath('/test/example', $request);
|
||||
$view->expects($this->any())
|
||||
->method('getRequest')
|
||||
->will($this->returnValue($request));
|
||||
->willReturn($request);
|
||||
$alias_manager = $this->createMock(AliasManagerInterface::class);
|
||||
$alias_manager->expects($this->never())
|
||||
->method('getAliasByPath');
|
||||
|
@ -76,7 +76,7 @@ class RawTest extends UnitTestCase {
|
|||
$alias_manager->expects($this->any())
|
||||
->method('getAliasByPath')
|
||||
->with($this->equalTo('/test/example'))
|
||||
->will($this->returnValue('/other/example'));
|
||||
->willReturn('/other/example');
|
||||
|
||||
$raw = new Raw([], 'raw', [], $alias_manager, $current_path);
|
||||
$options = [
|
||||
|
|
|
@ -60,7 +60,7 @@ class EntityTest extends UnitTestCase {
|
|||
$mock_entity = $this->getMockForAbstractClass('Drupal\Core\Entity\EntityBase', [], '', FALSE, TRUE, TRUE, ['bundle', 'access']);
|
||||
$mock_entity->expects($this->any())
|
||||
->method('bundle')
|
||||
->will($this->returnValue('test_bundle'));
|
||||
->willReturn('test_bundle');
|
||||
$mock_entity->expects($this->any())
|
||||
->method('access')
|
||||
->willReturnMap([
|
||||
|
@ -72,7 +72,7 @@ class EntityTest extends UnitTestCase {
|
|||
$mock_entity_bundle_2 = $this->getMockForAbstractClass('Drupal\Core\Entity\EntityBase', [], '', FALSE, TRUE, TRUE, ['bundle', 'access']);
|
||||
$mock_entity_bundle_2->expects($this->any())
|
||||
->method('bundle')
|
||||
->will($this->returnValue('test_bundle_2'));
|
||||
->willReturn('test_bundle_2');
|
||||
$mock_entity_bundle_2->expects($this->any())
|
||||
->method('access')
|
||||
->willReturnMap([
|
||||
|
@ -100,7 +100,7 @@ class EntityTest extends UnitTestCase {
|
|||
$this->entityTypeManager->expects($this->any())
|
||||
->method('getStorage')
|
||||
->with('entity_test')
|
||||
->will($this->returnValue($storage));
|
||||
->willReturn($storage);
|
||||
|
||||
$this->executable = $this->getMockBuilder('Drupal\views\ViewExecutable')
|
||||
->disableOriginalConstructor()
|
||||
|
|
|
@ -546,7 +546,7 @@ class PathPluginBaseTest extends UnitTestCase {
|
|||
->getMock();
|
||||
$view_entity->expects($this->any())
|
||||
->method('id')
|
||||
->will($this->returnValue('test_id'));
|
||||
->willReturn('test_id');
|
||||
|
||||
$view = $this->getMockBuilder('Drupal\views\ViewExecutable')
|
||||
->disableOriginalConstructor()
|
||||
|
@ -559,7 +559,7 @@ class PathPluginBaseTest extends UnitTestCase {
|
|||
->getMockForAbstractClass();
|
||||
$this->accessPluginManager->expects($this->any())
|
||||
->method('createInstance')
|
||||
->will($this->returnValue($access_plugin));
|
||||
->willReturn($access_plugin);
|
||||
|
||||
return [$view, $view_entity, $access_plugin];
|
||||
}
|
||||
|
|
|
@ -213,7 +213,7 @@ class PagerPluginBaseTest extends UnitTestCase {
|
|||
|
||||
$statement->expects($this->once())
|
||||
->method('fetchField')
|
||||
->will($this->returnValue(3));
|
||||
->willReturn(3);
|
||||
|
||||
$query = $this->getMockBuilder('\Drupal\Core\Database\Query\Select')
|
||||
->disableOriginalConstructor()
|
||||
|
@ -221,7 +221,7 @@ class PagerPluginBaseTest extends UnitTestCase {
|
|||
|
||||
$query->expects($this->once())
|
||||
->method('execute')
|
||||
->will($this->returnValue($statement));
|
||||
->willReturn($statement);
|
||||
|
||||
$this->pager->setOffset(0);
|
||||
$this->assertEquals(3, $this->pager->executeCountQuery($query));
|
||||
|
@ -237,7 +237,7 @@ class PagerPluginBaseTest extends UnitTestCase {
|
|||
|
||||
$statement->expects($this->once())
|
||||
->method('fetchField')
|
||||
->will($this->returnValue(3));
|
||||
->willReturn(3);
|
||||
|
||||
$query = $this->getMockBuilder('\Drupal\Core\Database\Query\Select')
|
||||
->disableOriginalConstructor()
|
||||
|
@ -245,7 +245,7 @@ class PagerPluginBaseTest extends UnitTestCase {
|
|||
|
||||
$query->expects($this->once())
|
||||
->method('execute')
|
||||
->will($this->returnValue($statement));
|
||||
->willReturn($statement);
|
||||
|
||||
$this->pager->setOffset(2);
|
||||
$this->assertEquals(1, $this->pager->executeCountQuery($query));
|
||||
|
@ -261,7 +261,7 @@ class PagerPluginBaseTest extends UnitTestCase {
|
|||
|
||||
$statement->expects($this->once())
|
||||
->method('fetchField')
|
||||
->will($this->returnValue(2));
|
||||
->willReturn(2);
|
||||
|
||||
$query = $this->getMockBuilder(Select::class)
|
||||
->disableOriginalConstructor()
|
||||
|
@ -269,7 +269,7 @@ class PagerPluginBaseTest extends UnitTestCase {
|
|||
|
||||
$query->expects($this->once())
|
||||
->method('execute')
|
||||
->will($this->returnValue($statement));
|
||||
->willReturn($statement);
|
||||
|
||||
$this->pager->setOffset(3);
|
||||
$this->assertEquals(0, $this->pager->executeCountQuery($query));
|
||||
|
|
|
@ -44,7 +44,7 @@ class BlockTest extends UnitTestCase {
|
|||
$this->executable->expects($this->any())
|
||||
->method('setDisplay')
|
||||
->with('block_1')
|
||||
->will($this->returnValue(TRUE));
|
||||
->willReturn(TRUE);
|
||||
|
||||
$this->blockDisplay = $this->executable->display_handler = $this->getMockBuilder('Drupal\views\Plugin\views\display\Block')
|
||||
->disableOriginalConstructor()
|
||||
|
@ -67,7 +67,7 @@ class BlockTest extends UnitTestCase {
|
|||
|
||||
$this->blockPlugin->expects($this->once())
|
||||
->method('getConfiguration')
|
||||
->will($this->returnValue(['items_per_page' => 'none']));
|
||||
->willReturn(['items_per_page' => 'none']);
|
||||
|
||||
$this->blockDisplay->preBlockBuild($this->blockPlugin);
|
||||
}
|
||||
|
@ -82,7 +82,7 @@ class BlockTest extends UnitTestCase {
|
|||
|
||||
$this->blockPlugin->expects($this->once())
|
||||
->method('getConfiguration')
|
||||
->will($this->returnValue(['items_per_page' => 5]));
|
||||
->willReturn(['items_per_page' => 5]);
|
||||
|
||||
$this->blockDisplay->preBlockBuild($this->blockPlugin);
|
||||
}
|
||||
|
|
|
@ -101,7 +101,7 @@ class EntityOperationsUnitTest extends UnitTestCase {
|
|||
->getMock();
|
||||
$entity->expects($this->any())
|
||||
->method('getEntityTypeId')
|
||||
->will($this->returnValue($entity_type_id));
|
||||
->willReturn($entity_type_id);
|
||||
|
||||
$operations = [
|
||||
'foo' => [
|
||||
|
@ -112,12 +112,12 @@ class EntityOperationsUnitTest extends UnitTestCase {
|
|||
$list_builder->expects($this->once())
|
||||
->method('getOperations')
|
||||
->with($entity)
|
||||
->will($this->returnValue($operations));
|
||||
->willReturn($operations);
|
||||
|
||||
$this->entityTypeManager->expects($this->once())
|
||||
->method('getListBuilder')
|
||||
->with($entity_type_id)
|
||||
->will($this->returnValue($list_builder));
|
||||
->willReturn($list_builder);
|
||||
|
||||
$this->plugin->options['destination'] = TRUE;
|
||||
|
||||
|
@ -143,7 +143,7 @@ class EntityOperationsUnitTest extends UnitTestCase {
|
|||
->getMock();
|
||||
$entity->expects($this->any())
|
||||
->method('getEntityTypeId')
|
||||
->will($this->returnValue($entity_type_id));
|
||||
->willReturn($entity_type_id);
|
||||
|
||||
$operations = [
|
||||
'foo' => [
|
||||
|
@ -154,12 +154,12 @@ class EntityOperationsUnitTest extends UnitTestCase {
|
|||
$list_builder->expects($this->once())
|
||||
->method('getOperations')
|
||||
->with($entity)
|
||||
->will($this->returnValue($operations));
|
||||
->willReturn($operations);
|
||||
|
||||
$this->entityTypeManager->expects($this->once())
|
||||
->method('getListBuilder')
|
||||
->with($entity_type_id)
|
||||
->will($this->returnValue($list_builder));
|
||||
->willReturn($list_builder);
|
||||
|
||||
$this->plugin->options['destination'] = FALSE;
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ class ViewsDataHelperTest extends UnitTestCase {
|
|||
->getMock();
|
||||
$views_data->expects($this->once())
|
||||
->method('getAll')
|
||||
->will($this->returnValue($this->viewsData()));
|
||||
->willReturn($this->viewsData());
|
||||
|
||||
$data_helper = new ViewsDataHelper($views_data);
|
||||
|
||||
|
|
|
@ -70,7 +70,7 @@ class ViewsDataTest extends UnitTestCase {
|
|||
$this->languageManager = $this->createMock('Drupal\Core\Language\LanguageManagerInterface');
|
||||
$this->languageManager->expects($this->any())
|
||||
->method('getCurrentLanguage')
|
||||
->will($this->returnValue(new Language(['id' => 'en'])));
|
||||
->willReturn(new Language(['id' => 'en']));
|
||||
|
||||
$this->viewsData = new ViewsData($this->cacheBackend, $this->configFactory, $this->moduleHandler, $this->languageManager);
|
||||
}
|
||||
|
@ -192,7 +192,7 @@ class ViewsDataTest extends UnitTestCase {
|
|||
$this->cacheBackend->expects($this->once())
|
||||
->method('get')
|
||||
->with("views_data:en")
|
||||
->will($this->returnValue(FALSE));
|
||||
->willReturn(FALSE);
|
||||
|
||||
$expected_views_data = $this->viewsDataWithProvider();
|
||||
$views_data = $this->viewsData->getAll();
|
||||
|
@ -281,7 +281,7 @@ class ViewsDataTest extends UnitTestCase {
|
|||
$this->cacheBackend->expects($this->once())
|
||||
->method('get')
|
||||
->with("views_data:en")
|
||||
->will($this->returnValue(FALSE));
|
||||
->willReturn(FALSE);
|
||||
|
||||
$views_data = $this->viewsData->getAll();
|
||||
$this->assertSame($expected_views_data, $views_data);
|
||||
|
@ -404,7 +404,7 @@ class ViewsDataTest extends UnitTestCase {
|
|||
$this->cacheBackend->expects($this->once())
|
||||
->method('get')
|
||||
->with('views_data:views_test_data:en')
|
||||
->will($this->returnValue((object) ['data' => $expected_views_data['views_test_data']]));
|
||||
->willReturn((object) ['data' => $expected_views_data['views_test_data']]);
|
||||
$this->cacheBackend->expects($this->never())
|
||||
->method('set');
|
||||
|
||||
|
@ -512,7 +512,7 @@ class ViewsDataTest extends UnitTestCase {
|
|||
$this->cacheBackend->expects($this->once())
|
||||
->method('get')
|
||||
->with("views_data:$non_existing_table:en")
|
||||
->will($this->returnValue((object) ['data' => []]));
|
||||
->willReturn((object) ['data' => []]);
|
||||
$this->cacheBackend->expects($this->never())
|
||||
->method('set');
|
||||
|
||||
|
@ -565,7 +565,7 @@ class ViewsDataTest extends UnitTestCase {
|
|||
$this->cacheBackend->expects($this->once())
|
||||
->method('get')
|
||||
->with("views_data:en")
|
||||
->will($this->returnValue((object) ['data' => $expected_views_data]));
|
||||
->willReturn((object) ['data' => $expected_views_data]);
|
||||
$this->cacheBackend->expects($this->never())
|
||||
->method('set');
|
||||
|
||||
|
|
|
@ -58,13 +58,13 @@ class ViewsTest extends UnitTestCase {
|
|||
$view_storage->expects($this->once())
|
||||
->method('load')
|
||||
->with('test_view')
|
||||
->will($this->returnValue($view));
|
||||
->willReturn($view);
|
||||
|
||||
$entity_type_manager = $this->createMock('Drupal\Core\Entity\EntityTypeManagerInterface');
|
||||
$entity_type_manager->expects($this->once())
|
||||
->method('getStorage')
|
||||
->with('view')
|
||||
->will($this->returnValue($view_storage));
|
||||
->willReturn($view_storage);
|
||||
$this->container->set('entity_type.manager', $entity_type_manager);
|
||||
|
||||
$executable = Views::getView('test_view');
|
||||
|
@ -168,13 +168,17 @@ class ViewsTest extends UnitTestCase {
|
|||
$view_storage->expects($this->once())
|
||||
->method('loadMultiple')
|
||||
->with(['test_view_1', 'test_view_2', 'test_view_3'])
|
||||
->will($this->returnValue(['test_view_1' => $view_1, 'test_view_2' => $view_2, 'test_view_3' => $view_3]));
|
||||
->willReturn([
|
||||
'test_view_1' => $view_1,
|
||||
'test_view_2' => $view_2,
|
||||
'test_view_3' => $view_3,
|
||||
]);
|
||||
|
||||
$entity_type_manager = $this->createMock(EntityTypeManagerInterface::class);
|
||||
$entity_type_manager->expects($this->exactly(2))
|
||||
->method('getStorage')
|
||||
->with('view')
|
||||
->will($this->returnValue($view_storage));
|
||||
->willReturn($view_storage);
|
||||
$this->container->set('entity_type.manager', $entity_type_manager);
|
||||
|
||||
$definitions = [
|
||||
|
|
|
@ -90,10 +90,11 @@ class ViewListBuilderTest extends UnitTestCase {
|
|||
->getMock();
|
||||
$page_display->expects($this->any())
|
||||
->method('getPath')
|
||||
->will($this->onConsecutiveCalls(
|
||||
$this->returnValue('test_page'),
|
||||
$this->returnValue('<object>malformed_path</object>'),
|
||||
$this->returnValue('<script>alert("placeholder_page/%")</script>')));
|
||||
->willReturnOnConsecutiveCalls(
|
||||
'test_page',
|
||||
'<object>malformed_path</object>',
|
||||
'<script>alert("placeholder_page/%")</script>',
|
||||
);
|
||||
|
||||
$embed_display = $this->getMockBuilder('Drupal\views\Plugin\views\display\Embed')
|
||||
->onlyMethods(['initDisplay'])
|
||||
|
|
|
@ -85,7 +85,7 @@ class ViewUIObjectTest extends UnitTestCase {
|
|||
$account = $this->createMock('Drupal\Core\Session\AccountInterface');
|
||||
$account->expects($this->exactly(2))
|
||||
->method('id')
|
||||
->will($this->returnValue(1));
|
||||
->willReturn(1);
|
||||
|
||||
$container = new ContainerBuilder();
|
||||
$container->set('current_user', $account);
|
||||
|
|
|
@ -82,7 +82,7 @@ class ExportStorageManagerTest extends KernelTestBase {
|
|||
$lock->expects($this->exactly(2))
|
||||
->method('acquire')
|
||||
->with(ExportStorageManager::LOCK_NAME)
|
||||
->will($this->returnValue(FALSE));
|
||||
->willReturn(FALSE);
|
||||
$lock->expects($this->once())
|
||||
->method('wait')
|
||||
->with(ExportStorageManager::LOCK_NAME);
|
||||
|
|
|
@ -69,7 +69,7 @@ class ImportStorageTransformerTest extends KernelTestBase {
|
|||
$lock->expects($this->exactly(2))
|
||||
->method('acquire')
|
||||
->with(ImportStorageTransformer::LOCK_NAME)
|
||||
->will($this->returnValue(FALSE));
|
||||
->willReturn(FALSE);
|
||||
$lock->expects($this->once())
|
||||
->method('wait')
|
||||
->with(ImportStorageTransformer::LOCK_NAME);
|
||||
|
@ -100,7 +100,7 @@ class ImportStorageTransformerTest extends KernelTestBase {
|
|||
$lock->expects($this->once())
|
||||
->method('lockMayBeAvailable')
|
||||
->with(ConfigImporter::LOCK_NAME)
|
||||
->will($this->returnValue(FALSE));
|
||||
->willReturn(FALSE);
|
||||
|
||||
// The import transformer under test.
|
||||
$transformer = new ImportStorageTransformer(
|
||||
|
|
|
@ -163,7 +163,7 @@ class LoggingTest extends DatabaseTestBase {
|
|||
->getMock();
|
||||
$log->expects($this->once())
|
||||
->method('getDebugBacktrace')
|
||||
->will($this->returnValue($stack));
|
||||
->willReturn($stack);
|
||||
Database::addConnectionInfo('test', 'default', ['driver' => 'mysql', 'namespace' => $driver_namespace]);
|
||||
|
||||
$result = $log->findCaller($stack);
|
||||
|
|
|
@ -363,7 +363,7 @@ class AccessManagerTest extends UnitTestCase {
|
|||
$this->routeProvider->expects($this->any())
|
||||
->method('getRouteByName')
|
||||
->with('test_route_1')
|
||||
->will($this->returnValue($route));
|
||||
->willReturn($route);
|
||||
|
||||
$map[] = ['test_route_1', ['value' => 'example'], '/test-route-1/example'];
|
||||
|
||||
|
@ -371,7 +371,7 @@ class AccessManagerTest extends UnitTestCase {
|
|||
$this->paramConverter->expects($this->atLeastOnce())
|
||||
->method('convert')
|
||||
->with(['value' => 'example', RouteObjectInterface::ROUTE_NAME => 'test_route_1', RouteObjectInterface::ROUTE_OBJECT => $route])
|
||||
->will($this->returnValue(['value' => 'upcasted_value']));
|
||||
->willReturn(['value' => 'upcasted_value']);
|
||||
|
||||
$this->setupAccessArgumentsResolverFactory($this->exactly(2))
|
||||
->with($this->callback(function ($route_match) {
|
||||
|
@ -383,10 +383,10 @@ class AccessManagerTest extends UnitTestCase {
|
|||
$access_check = $this->createMock('Drupal\Tests\Core\Access\TestAccessCheckInterface');
|
||||
$access_check->expects($this->atLeastOnce())
|
||||
->method('applies')
|
||||
->will($this->returnValue(TRUE));
|
||||
->willReturn(TRUE);
|
||||
$access_check->expects($this->atLeastOnce())
|
||||
->method('access')
|
||||
->will($this->returnValue(AccessResult::forbidden()));
|
||||
->willReturn(AccessResult::forbidden());
|
||||
|
||||
$this->container->set('test_access', $access_check);
|
||||
$this->container->setParameter('dynamic_access_check_services', ['test_access']);
|
||||
|
@ -412,7 +412,7 @@ class AccessManagerTest extends UnitTestCase {
|
|||
$this->routeProvider->expects($this->any())
|
||||
->method('getRouteByName')
|
||||
->with('test_route_1')
|
||||
->will($this->returnValue($route));
|
||||
->willReturn($route);
|
||||
|
||||
$map[] = ['test_route_1', ['value' => 'example'], '/test-route-1/example'];
|
||||
|
||||
|
@ -420,7 +420,7 @@ class AccessManagerTest extends UnitTestCase {
|
|||
$this->paramConverter->expects($this->atLeastOnce())
|
||||
->method('convert')
|
||||
->with(['value' => 'example', RouteObjectInterface::ROUTE_NAME => 'test_route_1', RouteObjectInterface::ROUTE_OBJECT => $route])
|
||||
->will($this->returnValue(['value' => 'upcasted_value']));
|
||||
->willReturn(['value' => 'upcasted_value']);
|
||||
|
||||
$this->setupAccessArgumentsResolverFactory($this->exactly(2))
|
||||
->with($this->callback(function ($route_match) {
|
||||
|
@ -432,10 +432,10 @@ class AccessManagerTest extends UnitTestCase {
|
|||
$access_check = $this->createMock('Drupal\Tests\Core\Access\TestAccessCheckInterface');
|
||||
$access_check->expects($this->atLeastOnce())
|
||||
->method('applies')
|
||||
->will($this->returnValue(TRUE));
|
||||
->willReturn(TRUE);
|
||||
$access_check->expects($this->atLeastOnce())
|
||||
->method('access')
|
||||
->will($this->returnValue(AccessResult::forbidden()));
|
||||
->willReturn(AccessResult::forbidden());
|
||||
|
||||
$this->container->set('test_access', $access_check);
|
||||
$this->container->setParameter('dynamic_access_check_services', ['test_access']);
|
||||
|
@ -482,12 +482,12 @@ class AccessManagerTest extends UnitTestCase {
|
|||
|
||||
$route_provider->expects($this->any())
|
||||
->method('getRouteByName')
|
||||
->will($this->returnValue($route));
|
||||
->willReturn($route);
|
||||
|
||||
$this->paramConverter = $this->createMock('Drupal\Core\ParamConverter\ParamConverterManagerInterface');
|
||||
$this->paramConverter->expects($this->any())
|
||||
->method('convert')
|
||||
->will($this->returnValue([]));
|
||||
->willReturn([]);
|
||||
|
||||
$this->setupAccessArgumentsResolverFactory();
|
||||
|
||||
|
@ -497,7 +497,7 @@ class AccessManagerTest extends UnitTestCase {
|
|||
$access_check = $this->createMock('Drupal\Tests\Core\Access\TestAccessCheckInterface');
|
||||
$access_check->expects($this->any())
|
||||
->method('access')
|
||||
->will($this->returnValue($return_value));
|
||||
->willReturn($return_value);
|
||||
$container->set('test_incorrect_value', $access_check);
|
||||
|
||||
$access_manager = new AccessManager($route_provider, $this->paramConverter, $this->argumentsResolverFactory, $this->currentUser, $this->checkProvider);
|
||||
|
|
|
@ -462,7 +462,7 @@ class AccessResultTest extends UnitTestCase {
|
|||
$account->expects($this->any())
|
||||
->method('hasPermission')
|
||||
->with('may herd llamas')
|
||||
->will($this->returnValue(FALSE));
|
||||
->willReturn(FALSE);
|
||||
$contexts = ['user.permissions'];
|
||||
|
||||
// Verify the object when using the ::allowedIfHasPermission() convenience
|
||||
|
@ -514,7 +514,7 @@ class AccessResultTest extends UnitTestCase {
|
|||
$node = $this->createMock('\Drupal\node\NodeInterface');
|
||||
$node->expects($this->any())
|
||||
->method('getCacheTags')
|
||||
->will($this->returnValue(['node:20011988']));
|
||||
->willReturn(['node:20011988']);
|
||||
$node->expects($this->any())
|
||||
->method('getCacheMaxAge')
|
||||
->willReturn(600);
|
||||
|
|
|
@ -55,11 +55,11 @@ class CsrfAccessCheckTest extends UnitTestCase {
|
|||
$this->csrfToken->expects($this->once())
|
||||
->method('validate')
|
||||
->with('test_query', 'test-path/42')
|
||||
->will($this->returnValue(TRUE));
|
||||
->willReturn(TRUE);
|
||||
|
||||
$this->routeMatch->expects($this->once())
|
||||
->method('getRawParameters')
|
||||
->will($this->returnValue(['node' => 42]));
|
||||
->willReturn(['node' => 42]);
|
||||
|
||||
$route = new Route('/test-path/{node}', [], ['_csrf_token' => 'TRUE']);
|
||||
$request = Request::create('/test-path/42?token=test_query');
|
||||
|
@ -74,11 +74,11 @@ class CsrfAccessCheckTest extends UnitTestCase {
|
|||
$this->csrfToken->expects($this->once())
|
||||
->method('validate')
|
||||
->with('test_query', 'test-path')
|
||||
->will($this->returnValue(FALSE));
|
||||
->willReturn(FALSE);
|
||||
|
||||
$this->routeMatch->expects($this->once())
|
||||
->method('getRawParameters')
|
||||
->will($this->returnValue([]));
|
||||
->willReturn([]);
|
||||
|
||||
$route = new Route('/test-path', [], ['_csrf_token' => 'TRUE']);
|
||||
$request = Request::create('/test-path?token=test_query');
|
||||
|
@ -93,11 +93,11 @@ class CsrfAccessCheckTest extends UnitTestCase {
|
|||
$this->csrfToken->expects($this->once())
|
||||
->method('validate')
|
||||
->with('', 'test-path')
|
||||
->will($this->returnValue(FALSE));
|
||||
->willReturn(FALSE);
|
||||
|
||||
$this->routeMatch->expects($this->once())
|
||||
->method('getRawParameters')
|
||||
->will($this->returnValue([]));
|
||||
->willReturn([]);
|
||||
|
||||
$route = new Route('/test-path', [], ['_csrf_token' => 'TRUE']);
|
||||
$request = Request::create('/test-path');
|
||||
|
|
|
@ -67,12 +67,12 @@ class CsrfTokenGeneratorTest extends UnitTestCase {
|
|||
$key = Crypt::randomBytesBase64();
|
||||
$this->privateKey->expects($this->any())
|
||||
->method('get')
|
||||
->will($this->returnValue($key));
|
||||
->willReturn($key);
|
||||
|
||||
$seed = Crypt::randomBytesBase64();
|
||||
$this->sessionMetadata->expects($this->any())
|
||||
->method('getCsrfTokenSeed')
|
||||
->will($this->returnValue($seed));
|
||||
->willReturn($seed);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -97,11 +97,11 @@ class CsrfTokenGeneratorTest extends UnitTestCase {
|
|||
$key = Crypt::randomBytesBase64();
|
||||
$this->privateKey->expects($this->any())
|
||||
->method('get')
|
||||
->will($this->returnValue($key));
|
||||
->willReturn($key);
|
||||
|
||||
$this->sessionMetadata->expects($this->once())
|
||||
->method('getCsrfTokenSeed')
|
||||
->will($this->returnValue(NULL));
|
||||
->willReturn(NULL);
|
||||
|
||||
$this->sessionMetadata->expects($this->once())
|
||||
->method('setCsrfTokenSeed')
|
||||
|
|
|
@ -72,15 +72,15 @@ class CustomAccessCheckTest extends UnitTestCase {
|
|||
$resolver0 = $this->createMock('Drupal\Component\Utility\ArgumentsResolverInterface');
|
||||
$resolver0->expects($this->once())
|
||||
->method('getArguments')
|
||||
->will($this->returnValue([]));
|
||||
->willReturn([]);
|
||||
$resolver1 = $this->createMock('Drupal\Component\Utility\ArgumentsResolverInterface');
|
||||
$resolver1->expects($this->once())
|
||||
->method('getArguments')
|
||||
->will($this->returnValue([]));
|
||||
->willReturn([]);
|
||||
$resolver2 = $this->createMock('Drupal\Component\Utility\ArgumentsResolverInterface');
|
||||
$resolver2->expects($this->once())
|
||||
->method('getArguments')
|
||||
->will($this->returnValue(['parameter' => 'TRUE']));
|
||||
->willReturn(['parameter' => 'TRUE']);
|
||||
|
||||
$this->argumentsResolverFactory->expects($this->exactly(3))
|
||||
->method('getArgumentsResolver')
|
||||
|
|
|
@ -39,15 +39,15 @@ class AjaxResponseTest extends UnitTestCase {
|
|||
$command_one = $this->createMock('Drupal\Core\Ajax\CommandInterface');
|
||||
$command_one->expects($this->once())
|
||||
->method('render')
|
||||
->will($this->returnValue(['command' => 'one']));
|
||||
->willReturn(['command' => 'one']);
|
||||
$command_two = $this->createMock('Drupal\Core\Ajax\CommandInterface');
|
||||
$command_two->expects($this->once())
|
||||
->method('render')
|
||||
->will($this->returnValue(['command' => 'two']));
|
||||
->willReturn(['command' => 'two']);
|
||||
$command_three = $this->createMock('Drupal\Core\Ajax\CommandInterface');
|
||||
$command_three->expects($this->once())
|
||||
->method('render')
|
||||
->will($this->returnValue(['command' => 'three']));
|
||||
->willReturn(['command' => 'three']);
|
||||
|
||||
$this->ajaxResponse->addCommand($command_one);
|
||||
$this->ajaxResponse->addCommand($command_two);
|
||||
|
|
|
@ -60,7 +60,7 @@ class LibraryDependencyResolverTest extends UnitTestCase {
|
|||
$this->libraryDiscovery->expects($this->any())
|
||||
->method('getLibrariesByExtension')
|
||||
->with('test')
|
||||
->will($this->returnValue($this->libraryData));
|
||||
->willReturn($this->libraryData);
|
||||
$this->libraryDependencyResolver = new LibraryDependencyResolver($this->libraryDiscovery);
|
||||
}
|
||||
|
||||
|
|
|
@ -150,7 +150,7 @@ class LibraryDiscoveryCollectorTest extends UnitTestCase {
|
|||
$this->lock->expects($this->once())
|
||||
->method('acquire')
|
||||
->with($lock_key)
|
||||
->will($this->returnValue(TRUE));
|
||||
->willReturn(TRUE);
|
||||
$this->cache->expects($this->exactly(2))
|
||||
->method('get')
|
||||
->with('library_info:kitten_theme')
|
||||
|
|
|
@ -119,7 +119,7 @@ class LibraryDiscoveryParserTest extends UnitTestCase {
|
|||
$this->moduleHandler->expects($this->atLeastOnce())
|
||||
->method('moduleExists')
|
||||
->with('example_module')
|
||||
->will($this->returnValue(TRUE));
|
||||
->willReturn(TRUE);
|
||||
|
||||
$path = __DIR__ . '/library_test_files';
|
||||
$path = substr($path, strlen($this->root) + 1);
|
||||
|
@ -149,7 +149,7 @@ class LibraryDiscoveryParserTest extends UnitTestCase {
|
|||
$this->moduleHandler->expects($this->atLeastOnce())
|
||||
->method('moduleExists')
|
||||
->with('example_theme')
|
||||
->will($this->returnValue(FALSE));
|
||||
->willReturn(FALSE);
|
||||
|
||||
$path = __DIR__ . '/library_test_files';
|
||||
$path = substr($path, strlen($this->root) + 1);
|
||||
|
@ -176,7 +176,7 @@ class LibraryDiscoveryParserTest extends UnitTestCase {
|
|||
$this->moduleHandler->expects($this->atLeastOnce())
|
||||
->method('moduleExists')
|
||||
->with('example_module')
|
||||
->will($this->returnValue(TRUE));
|
||||
->willReturn(TRUE);
|
||||
|
||||
$path = __DIR__ . '/library_test_files_not_existing';
|
||||
$path = substr($path, strlen($this->root) + 1);
|
||||
|
@ -197,7 +197,7 @@ class LibraryDiscoveryParserTest extends UnitTestCase {
|
|||
$this->moduleHandler->expects($this->atLeastOnce())
|
||||
->method('moduleExists')
|
||||
->with('invalid_file')
|
||||
->will($this->returnValue(TRUE));
|
||||
->willReturn(TRUE);
|
||||
|
||||
$path = __DIR__ . '/library_test_files';
|
||||
$path = substr($path, strlen($this->root) + 1);
|
||||
|
@ -219,7 +219,7 @@ class LibraryDiscoveryParserTest extends UnitTestCase {
|
|||
$this->moduleHandler->expects($this->atLeastOnce())
|
||||
->method('moduleExists')
|
||||
->with('example_module_only_dependencies')
|
||||
->will($this->returnValue(TRUE));
|
||||
->willReturn(TRUE);
|
||||
|
||||
$path = __DIR__ . '/library_test_files';
|
||||
$path = substr($path, strlen($this->root) + 1);
|
||||
|
@ -241,7 +241,7 @@ class LibraryDiscoveryParserTest extends UnitTestCase {
|
|||
$this->moduleHandler->expects($this->atLeastOnce())
|
||||
->method('moduleExists')
|
||||
->with('example_module_missing_information')
|
||||
->will($this->returnValue(TRUE));
|
||||
->willReturn(TRUE);
|
||||
|
||||
$path = __DIR__ . '/library_test_files';
|
||||
$path = substr($path, strlen($this->root) + 1);
|
||||
|
@ -264,7 +264,7 @@ class LibraryDiscoveryParserTest extends UnitTestCase {
|
|||
$this->moduleHandler->expects($this->atLeastOnce())
|
||||
->method('moduleExists')
|
||||
->with('versions')
|
||||
->will($this->returnValue(TRUE));
|
||||
->willReturn(TRUE);
|
||||
|
||||
$path = __DIR__ . '/library_test_files';
|
||||
$path = substr($path, strlen($this->root) + 1);
|
||||
|
@ -297,7 +297,7 @@ class LibraryDiscoveryParserTest extends UnitTestCase {
|
|||
$this->moduleHandler->expects($this->atLeastOnce())
|
||||
->method('moduleExists')
|
||||
->with('external')
|
||||
->will($this->returnValue(TRUE));
|
||||
->willReturn(TRUE);
|
||||
|
||||
$path = __DIR__ . '/library_test_files';
|
||||
$path = substr($path, strlen($this->root) + 1);
|
||||
|
@ -323,7 +323,7 @@ class LibraryDiscoveryParserTest extends UnitTestCase {
|
|||
$this->moduleHandler->expects($this->atLeastOnce())
|
||||
->method('moduleExists')
|
||||
->with('css_weights')
|
||||
->will($this->returnValue(TRUE));
|
||||
->willReturn(TRUE);
|
||||
|
||||
$path = __DIR__ . '/library_test_files';
|
||||
$path = substr($path, strlen($this->root) + 1);
|
||||
|
@ -364,7 +364,7 @@ class LibraryDiscoveryParserTest extends UnitTestCase {
|
|||
$this->moduleHandler->expects($this->atLeastOnce())
|
||||
->method('moduleExists')
|
||||
->with('js_positive_weight')
|
||||
->will($this->returnValue(TRUE));
|
||||
->willReturn(TRUE);
|
||||
|
||||
$path = __DIR__ . '/library_test_files';
|
||||
$path = substr($path, strlen($this->root) + 1);
|
||||
|
@ -386,7 +386,7 @@ class LibraryDiscoveryParserTest extends UnitTestCase {
|
|||
$this->moduleHandler->expects($this->atLeastOnce())
|
||||
->method('moduleExists')
|
||||
->with('css_js_settings')
|
||||
->will($this->returnValue(TRUE));
|
||||
->willReturn(TRUE);
|
||||
|
||||
$path = __DIR__ . '/library_test_files';
|
||||
$path = substr($path, strlen($this->root) + 1);
|
||||
|
@ -419,7 +419,7 @@ class LibraryDiscoveryParserTest extends UnitTestCase {
|
|||
$this->moduleHandler->expects($this->atLeastOnce())
|
||||
->method('moduleExists')
|
||||
->with('dependencies')
|
||||
->will($this->returnValue(TRUE));
|
||||
->willReturn(TRUE);
|
||||
|
||||
$path = __DIR__ . '/library_test_files';
|
||||
$path = substr($path, strlen($this->root) + 1);
|
||||
|
@ -445,10 +445,10 @@ class LibraryDiscoveryParserTest extends UnitTestCase {
|
|||
$this->moduleHandler->expects($this->atLeastOnce())
|
||||
->method('moduleExists')
|
||||
->with('data_types')
|
||||
->will($this->returnValue(TRUE));
|
||||
->willReturn(TRUE);
|
||||
$this->streamWrapperManager->expects($this->atLeastOnce())
|
||||
->method('isValidUri')
|
||||
->will($this->returnValue(TRUE));
|
||||
->willReturn(TRUE);
|
||||
|
||||
$path = __DIR__ . '/library_test_files';
|
||||
$path = substr($path, strlen($this->root) + 1);
|
||||
|
@ -483,7 +483,7 @@ class LibraryDiscoveryParserTest extends UnitTestCase {
|
|||
$this->moduleHandler->expects($this->atLeastOnce())
|
||||
->method('moduleExists')
|
||||
->with('js')
|
||||
->will($this->returnValue(TRUE));
|
||||
->willReturn(TRUE);
|
||||
|
||||
$path = __DIR__ . '/library_test_files';
|
||||
$path = substr($path, strlen($this->root) + 1);
|
||||
|
@ -509,7 +509,7 @@ class LibraryDiscoveryParserTest extends UnitTestCase {
|
|||
$this->moduleHandler->expects($this->atLeastOnce())
|
||||
->method('moduleExists')
|
||||
->with('licenses_missing_information')
|
||||
->will($this->returnValue(TRUE));
|
||||
->willReturn(TRUE);
|
||||
|
||||
$path = __DIR__ . '/library_test_files';
|
||||
$path = substr($path, strlen($this->root) + 1);
|
||||
|
@ -532,7 +532,7 @@ class LibraryDiscoveryParserTest extends UnitTestCase {
|
|||
$this->moduleHandler->expects($this->atLeastOnce())
|
||||
->method('moduleExists')
|
||||
->with('licenses')
|
||||
->will($this->returnValue(TRUE));
|
||||
->willReturn(TRUE);
|
||||
|
||||
$path = __DIR__ . '/library_test_files';
|
||||
$path = substr($path, strlen($this->root) + 1);
|
||||
|
@ -651,7 +651,7 @@ class LibraryDiscoveryParserTest extends UnitTestCase {
|
|||
$this->moduleHandler->expects($this->atLeastOnce())
|
||||
->method('moduleExists')
|
||||
->with('example_module')
|
||||
->will($this->returnValue(TRUE));
|
||||
->willReturn(TRUE);
|
||||
|
||||
$libraries = $this->libraryDiscoveryParser->buildByExtension('example_module');
|
||||
$library = $libraries['example'];
|
||||
|
@ -704,7 +704,7 @@ class LibraryDiscoveryParserTest extends UnitTestCase {
|
|||
$this->moduleHandler->expects($this->atLeastOnce())
|
||||
->method('moduleExists')
|
||||
->with('deprecated')
|
||||
->will($this->returnValue(TRUE));
|
||||
->willReturn(TRUE);
|
||||
|
||||
$this->libraryDiscoveryParser->buildByExtension('deprecated');
|
||||
}
|
||||
|
@ -729,7 +729,7 @@ class LibraryDiscoveryParserTest extends UnitTestCase {
|
|||
$this->moduleHandler->expects($this->atLeastOnce())
|
||||
->method('moduleExists')
|
||||
->with($extension)
|
||||
->will($this->returnValue(TRUE));
|
||||
->willReturn(TRUE);
|
||||
|
||||
$path = __DIR__ . '/library_test_files';
|
||||
$path = substr($path, strlen($this->root) + 1);
|
||||
|
@ -761,7 +761,7 @@ class LibraryDiscoveryParserTest extends UnitTestCase {
|
|||
$this->moduleHandler->expects($this->atLeastOnce())
|
||||
->method('moduleExists')
|
||||
->with('example_contrib_module')
|
||||
->will($this->returnValue(TRUE));
|
||||
->willReturn(TRUE);
|
||||
|
||||
$path = __DIR__ . '/library_test_files';
|
||||
$path = substr($path, strlen($this->root) + 1);
|
||||
|
@ -773,7 +773,7 @@ class LibraryDiscoveryParserTest extends UnitTestCase {
|
|||
$this->librariesDirectoryFileFinder->expects($this->once())
|
||||
->method('find')
|
||||
->with('third_party_library/css/example.css')
|
||||
->will($this->returnValue('sites/example.com/libraries/third_party_library/css/example.css'));
|
||||
->willReturn('sites/example.com/libraries/third_party_library/css/example.css');
|
||||
|
||||
$libraries = $this->libraryDiscoveryParser->buildByExtension('example_contrib_module');
|
||||
$library = $libraries['third_party_library'];
|
||||
|
@ -792,7 +792,7 @@ class LibraryDiscoveryParserTest extends UnitTestCase {
|
|||
$this->moduleHandler->expects($this->atLeastOnce())
|
||||
->method('moduleExists')
|
||||
->with('example_contrib_module')
|
||||
->will($this->returnValue(TRUE));
|
||||
->willReturn(TRUE);
|
||||
|
||||
$path = __DIR__ . '/library_test_files';
|
||||
$path = substr($path, strlen($this->root) + 1);
|
||||
|
@ -807,7 +807,7 @@ class LibraryDiscoveryParserTest extends UnitTestCase {
|
|||
$this->librariesDirectoryFileFinder->expects($this->once())
|
||||
->method('find')
|
||||
->with('third_party_library/css/example.css')
|
||||
->will($this->returnValue(FALSE));
|
||||
->willReturn(FALSE);
|
||||
|
||||
$libraries = $this->libraryDiscoveryParser->buildByExtension('example_contrib_module');
|
||||
$library = $libraries['third_party_library'];
|
||||
|
@ -827,7 +827,7 @@ class LibraryDiscoveryParserTest extends UnitTestCase {
|
|||
$this->moduleHandler->expects($this->atLeastOnce())
|
||||
->method('moduleExists')
|
||||
->with('empty')
|
||||
->will($this->returnValue(TRUE));
|
||||
->willReturn(TRUE);
|
||||
|
||||
$path = __DIR__ . '/library_test_files';
|
||||
$path = substr($path, strlen($this->root) + 1);
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue