Issue #2929133 by voleger, alexpott, Lendude: Replace all usages of getMock()

merge-requests/1119/head
Alex Pott 2019-05-31 10:22:21 +01:00
parent 2bb3bba520
commit 91fe1d2f77
No known key found for this signature in database
GPG Key ID: 31905460D4A69276
266 changed files with 1327 additions and 1261 deletions

View File

@ -83,11 +83,10 @@ class AggregatorPluginSettingsBaseTest extends UnitTestCase {
'aggregator_allowed_html_tags' => '',
]);
$test_processor = $this->getMock(
'Drupal\aggregator_test\Plugin\aggregator\processor\TestProcessor',
['buildConfigurationForm', 'validateConfigurationForm', 'submitConfigurationForm'],
[[], 'aggregator_test', ['description' => ''], $this->configFactory]
);
$test_processor = $this->getMockBuilder('Drupal\aggregator_test\Plugin\aggregator\processor\TestProcessor')
->setMethods(['buildConfigurationForm', 'validateConfigurationForm', 'submitConfigurationForm'])
->setConstructorArgs([[], 'aggregator_test', ['description' => ''], $this->configFactory])
->getMock();
$test_processor->expects($this->at(0))
->method('buildConfigurationForm')
->with($this->anything(), $form_state)

View File

@ -41,8 +41,8 @@ class BanMiddlewareTest extends UnitTestCase {
protected function setUp() {
parent::setUp();
$this->kernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface');
$this->banManager = $this->getMock('Drupal\ban\BanIpManagerInterface');
$this->kernel = $this->createMock('Symfony\Component\HttpKernel\HttpKernelInterface');
$this->banManager = $this->createMock('Drupal\ban\BanIpManagerInterface');
$this->banMiddleware = new BanMiddleware($this->kernel, $this->banManager);
}

View File

@ -63,18 +63,18 @@ class BlockConfigEntityUnitTest extends UnitTestCase {
protected function setUp() {
$this->entityTypeId = $this->randomMachineName();
$this->entityType = $this->getMock('\Drupal\Core\Entity\EntityTypeInterface');
$this->entityType = $this->createMock('\Drupal\Core\Entity\EntityTypeInterface');
$this->entityType->expects($this->any())
->method('getProvider')
->will($this->returnValue('block'));
$this->entityTypeManager = $this->getMock(EntityTypeManagerInterface::class);
$this->entityTypeManager = $this->createMock(EntityTypeManagerInterface::class);
$this->entityTypeManager->expects($this->any())
->method('getDefinition')
->with($this->entityTypeId)
->will($this->returnValue($this->entityType));
$this->uuid = $this->getMock('\Drupal\Component\Uuid\UuidInterface');
$this->uuid = $this->createMock('\Drupal\Component\Uuid\UuidInterface');
$this->moduleHandler = $this->prophesize(ModuleHandlerInterface::class);
$this->themeHandler = $this->prophesize(ThemeHandlerInterface::class);

View File

@ -70,13 +70,13 @@ class BlockFormTest extends UnitTestCase {
protected function setUp() {
parent::setUp();
$this->conditionManager = $this->getMock('Drupal\Core\Executable\ExecutableManagerInterface');
$this->language = $this->getMock('Drupal\Core\Language\LanguageManagerInterface');
$this->contextRepository = $this->getMock('Drupal\Core\Plugin\Context\ContextRepositoryInterface');
$this->conditionManager = $this->createMock('Drupal\Core\Executable\ExecutableManagerInterface');
$this->language = $this->createMock('Drupal\Core\Language\LanguageManagerInterface');
$this->contextRepository = $this->createMock('Drupal\Core\Plugin\Context\ContextRepositoryInterface');
$this->entityTypeManager = $this->getMock('Drupal\Core\Entity\EntityTypeManagerInterface');
$this->storage = $this->getMock('Drupal\Core\Config\Entity\ConfigEntityStorageInterface');
$this->themeHandler = $this->getMock('Drupal\Core\Extension\ThemeHandlerInterface');
$this->entityTypeManager = $this->createMock('Drupal\Core\Entity\EntityTypeManagerInterface');
$this->storage = $this->createMock('Drupal\Core\Config\Entity\ConfigEntityStorageInterface');
$this->themeHandler = $this->createMock('Drupal\Core\Extension\ThemeHandlerInterface');
$this->entityTypeManager->expects($this->any())
->method('getStorage')
->will($this->returnValue($this->storage));
@ -123,7 +123,7 @@ class BlockFormTest extends UnitTestCase {
$blocks['other_test_1'] = $this->getBlockMockWithMachineName('other_test');
$blocks['other_test_2'] = $this->getBlockMockWithMachineName('other_test');
$query = $this->getMock('Drupal\Core\Entity\Query\QueryInterface');
$query = $this->createMock('Drupal\Core\Entity\Query\QueryInterface');
$query->expects($this->exactly(5))
->method('condition')
->will($this->returnValue($query));

View File

@ -60,13 +60,13 @@ class BlockRepositoryTest extends UnitTestCase {
'bottom',
]);
$theme_manager = $this->getMock('Drupal\Core\Theme\ThemeManagerInterface');
$theme_manager = $this->createMock('Drupal\Core\Theme\ThemeManagerInterface');
$theme_manager->expects($this->atLeastOnce())
->method('getActiveTheme')
->will($this->returnValue($active_theme));
$this->contextHandler = $this->getMock('Drupal\Core\Plugin\Context\ContextHandlerInterface');
$this->blockStorage = $this->getMock('Drupal\Core\Entity\EntityStorageInterface');
$this->contextHandler = $this->createMock('Drupal\Core\Plugin\Context\ContextHandlerInterface');
$this->blockStorage = $this->createMock('Drupal\Core\Entity\EntityStorageInterface');
/** @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())
@ -86,7 +86,7 @@ class BlockRepositoryTest extends UnitTestCase {
public function testGetVisibleBlocksPerRegion(array $blocks_config, array $expected_blocks) {
$blocks = [];
foreach ($blocks_config as $block_id => $block_config) {
$block = $this->getMock('Drupal\block\BlockInterface');
$block = $this->createMock('Drupal\block\BlockInterface');
$block->expects($this->once())
->method('access')
->will($this->returnValue($block_config[0]));
@ -155,7 +155,7 @@ class BlockRepositoryTest extends UnitTestCase {
* @covers ::getVisibleBlocksPerRegion
*/
public function testGetVisibleBlocksPerRegionWithContext() {
$block = $this->getMock('Drupal\block\BlockInterface');
$block = $this->createMock('Drupal\block\BlockInterface');
$block->expects($this->once())
->method('access')
->willReturn(AccessResult::allowed()->addCacheTags(['config:block.block.block_id']));

View File

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

View File

@ -40,7 +40,7 @@ class BlockLocalTasksTest extends LocalTaskIntegrationTestBase {
'name' => 'test_c',
],
];
$theme_handler = $this->getMock('Drupal\Core\Extension\ThemeHandlerInterface');
$theme_handler = $this->createMock('Drupal\Core\Extension\ThemeHandlerInterface');
$theme_handler->expects($this->any())
->method('listInfo')
->will($this->returnValue($themes));

View File

@ -57,8 +57,8 @@ class BlockPageVariantTest extends UnitTestCase {
->willReturn(TRUE);
\Drupal::setContainer($container);
$this->blockRepository = $this->getMock('Drupal\block\BlockRepositoryInterface');
$this->blockViewBuilder = $this->getMock('Drupal\Core\Entity\EntityViewBuilderInterface');
$this->blockRepository = $this->createMock('Drupal\block\BlockRepositoryInterface');
$this->blockViewBuilder = $this->createMock('Drupal\Core\Entity\EntityViewBuilderInterface');
return $this->getMockBuilder('Drupal\block\Plugin\DisplayVariant\BlockPageVariant')
->setConstructorArgs([$configuration, 'test', $definition, $this->blockRepository, $this->blockViewBuilder, ['config:block_list']])
@ -206,12 +206,12 @@ class BlockPageVariantTest extends UnitTestCase {
$display_variant->setMainContent(['#markup' => 'Hello kittens!']);
$blocks = ['top' => [], 'center' => [], 'bottom' => []];
$block_plugin = $this->getMock('Drupal\Core\Block\BlockPluginInterface');
$main_content_block_plugin = $this->getMock('Drupal\Core\Block\MainContentBlockPluginInterface');
$messages_block_plugin = $this->getMock('Drupal\Core\Block\MessagesBlockPluginInterface');
$title_block_plugin = $this->getMock('Drupal\Core\Block\TitleBlockPluginInterface');
$block_plugin = $this->createMock('Drupal\Core\Block\BlockPluginInterface');
$main_content_block_plugin = $this->createMock('Drupal\Core\Block\MainContentBlockPluginInterface');
$messages_block_plugin = $this->createMock('Drupal\Core\Block\MessagesBlockPluginInterface');
$title_block_plugin = $this->createMock('Drupal\Core\Block\TitleBlockPluginInterface');
foreach ($blocks_config as $block_id => $block_config) {
$block = $this->getMock('Drupal\block\BlockInterface');
$block = $this->createMock('Drupal\block\BlockInterface');
$block->expects($this->atLeastOnce())
->method('getPlugin')
->willReturn($block_config[1] ? $main_content_block_plugin : ($block_config[2] ? $messages_block_plugin : ($block_config[3] ? $title_block_plugin : $block_plugin)));

View File

@ -39,7 +39,7 @@ class BlockContentLocalTasksTest extends LocalTaskIntegrationTestBase {
'name' => 'test_c',
],
];
$theme_handler = $this->getMock('Drupal\Core\Extension\ThemeHandlerInterface');
$theme_handler = $this->createMock('Drupal\Core\Extension\ThemeHandlerInterface');
$theme_handler->expects($this->any())
->method('listInfo')
->will($this->returnValue($themes));

View File

@ -61,8 +61,8 @@ class BookManagerTest extends UnitTestCase {
$this->entityTypeManager = $this->createMock(EntityTypeManagerInterface::class);
$this->translation = $this->getStringTranslationStub();
$this->configFactory = $this->getConfigFactoryStub([]);
$this->bookOutlineStorage = $this->getMock('Drupal\book\BookOutlineStorageInterface');
$this->renderer = $this->getMock('\Drupal\Core\Render\RendererInterface');
$this->bookOutlineStorage = $this->createMock('Drupal\book\BookOutlineStorageInterface');
$this->renderer = $this->createMock('\Drupal\Core\Render\RendererInterface');
$this->bookManager = new BookManager($this->entityTypeManager, $this->translation, $this->configFactory, $this->bookOutlineStorage, $this->renderer);
}

View File

@ -45,7 +45,7 @@ class BreakpointTest extends UnitTestCase {
protected function setUp() {
parent::setUp();
$this->stringTranslation = $this->getMock('Drupal\Core\StringTranslation\TranslationInterface');
$this->stringTranslation = $this->createMock('Drupal\Core\StringTranslation\TranslationInterface');
}
/**

View File

@ -69,11 +69,11 @@ class CommentLinkBuilderTest extends UnitTestCase {
* Prepares mocks for the test.
*/
protected function setUp() {
$this->commentManager = $this->getMock('\Drupal\comment\CommentManagerInterface');
$this->commentManager = $this->createMock('\Drupal\comment\CommentManagerInterface');
$this->stringTranslation = $this->getStringTranslationStub();
$this->entityTypeManager = $this->createMock(EntityTypeManagerInterface::class);
$this->moduleHandler = $this->getMock('\Drupal\Core\Extension\ModuleHandlerInterface');
$this->currentUser = $this->getMock('\Drupal\Core\Session\AccountProxyInterface');
$this->moduleHandler = $this->createMock('\Drupal\Core\Extension\ModuleHandlerInterface');
$this->currentUser = $this->createMock('\Drupal\Core\Session\AccountProxyInterface');
$this->commentLinkBuilder = new CommentLinkBuilder($this->currentUser, $this->commentManager, $this->moduleHandler, $this->stringTranslation, $this->entityTypeManager);
$this->commentManager->expects($this->any())
->method('getFields')
@ -269,7 +269,7 @@ class CommentLinkBuilderTest extends UnitTestCase {
* Mock node for testing.
*/
protected function getMockNode($has_field, $comment_status, $form_location, $comment_count) {
$node = $this->getMock('\Drupal\node\NodeInterface');
$node = $this->createMock('\Drupal\node\NodeInterface');
$node->expects($this->any())
->method('hasField')
->willReturn($has_field);
@ -287,7 +287,7 @@ class CommentLinkBuilderTest extends UnitTestCase {
->with('comment')
->willReturn($field_item);
$field_definition = $this->getMock('\Drupal\Core\Field\FieldDefinitionInterface');
$field_definition = $this->createMock('\Drupal\Core\Field\FieldDefinitionInterface');
$field_definition->expects($this->any())
->method('getSetting')
->with('form_location')

View File

@ -23,7 +23,7 @@ class CommentManagerTest extends UnitTestCase {
*/
public function testGetFields() {
// Set up a content entity type.
$entity_type = $this->getMock('Drupal\Core\Entity\ContentEntityTypeInterface');
$entity_type = $this->createMock('Drupal\Core\Entity\ContentEntityTypeInterface');
$entity_type->expects($this->any())
->method('getClass')
->will($this->returnValue('Node'));
@ -51,9 +51,9 @@ class CommentManagerTest extends UnitTestCase {
$comment_manager = new CommentManager(
$entity_type_manager,
$this->getMock('Drupal\Core\Config\ConfigFactoryInterface'),
$this->getMock('Drupal\Core\StringTranslation\TranslationInterface'),
$this->getMock('Drupal\Core\Extension\ModuleHandlerInterface'),
$this->createMock('Drupal\Core\Config\ConfigFactoryInterface'),
$this->createMock('Drupal\Core\StringTranslation\TranslationInterface'),
$this->createMock('Drupal\Core\Extension\ModuleHandlerInterface'),
$this->createMock(AccountInterface::class),
$entity_field_manager,
$this->prophesize(EntityDisplayRepositoryInterface::class)->reveal()

View File

@ -83,7 +83,7 @@ class CommentStatisticsUnitTest extends UnitTestCase {
->method('select')
->will($this->returnValue($this->select));
$this->commentStatistics = new CommentStatistics($this->database, $this->getMock('Drupal\Core\Session\AccountInterface'), $this->createMock(EntityTypeManagerInterface::class), $this->getMock('Drupal\Core\State\StateInterface'), $this->database);
$this->commentStatistics = new CommentStatistics($this->database, $this->createMock('Drupal\Core\Session\AccountInterface'), $this->createMock(EntityTypeManagerInterface::class), $this->createMock('Drupal\Core\State\StateInterface'), $this->database);
}
/**

View File

@ -19,15 +19,15 @@ class CommentLockTest extends UnitTestCase {
*/
public function testLocks() {
$container = new ContainerBuilder();
$container->set('module_handler', $this->getMock('Drupal\Core\Extension\ModuleHandlerInterface'));
$container->set('current_user', $this->getMock('Drupal\Core\Session\AccountInterface'));
$container->set('cache.test', $this->getMock('Drupal\Core\Cache\CacheBackendInterface'));
$container->set('comment.statistics', $this->getMock('Drupal\comment\CommentStatisticsInterface'));
$container->set('module_handler', $this->createMock('Drupal\Core\Extension\ModuleHandlerInterface'));
$container->set('current_user', $this->createMock('Drupal\Core\Session\AccountInterface'));
$container->set('cache.test', $this->createMock('Drupal\Core\Cache\CacheBackendInterface'));
$container->set('comment.statistics', $this->createMock('Drupal\comment\CommentStatisticsInterface'));
$request_stack = new RequestStack();
$request_stack->push(Request::create('/'));
$container->set('request_stack', $request_stack);
$container->setParameter('cache_bins', ['cache.test' => 'test']);
$lock = $this->getMock('Drupal\Core\Lock\LockBackendInterface');
$lock = $this->createMock('Drupal\Core\Lock\LockBackendInterface');
$cid = 2;
$lock_name = "comment:$cid:.00/";
$lock->expects($this->at(0))
@ -41,7 +41,7 @@ class CommentLockTest extends UnitTestCase {
->method($this->anything());
$container->set('lock', $lock);
$cache_tag_invalidator = $this->getMock('Drupal\Core\Cache\CacheTagsInvalidator');
$cache_tag_invalidator = $this->createMock('Drupal\Core\Cache\CacheTagsInvalidator');
$container->set('cache_tags.invalidator', $cache_tag_invalidator);
\Drupal::setContainer($container);
@ -69,7 +69,7 @@ class CommentLockTest extends UnitTestCase {
->method('getThread')
->will($this->returnValue(''));
$anon_user = $this->getMock('Drupal\Core\Session\AccountInterface');
$anon_user = $this->createMock('Drupal\Core\Session\AccountInterface');
$anon_user->expects($this->any())
->method('isAnonymous')
->will($this->returnValue(TRUE));
@ -77,7 +77,7 @@ class CommentLockTest extends UnitTestCase {
->method('getOwner')
->will($this->returnValue($anon_user));
$parent_entity = $this->getMock('\Drupal\Core\Entity\ContentEntityInterface');
$parent_entity = $this->createMock('\Drupal\Core\Entity\ContentEntityInterface');
$parent_entity->expects($this->atLeastOnce())
->method('getCacheTagsToInvalidate')
->willReturn(['node:1']);
@ -85,11 +85,11 @@ class CommentLockTest extends UnitTestCase {
->method('getCommentedEntity')
->willReturn($parent_entity);
$entity_type = $this->getMock('\Drupal\Core\Entity\EntityTypeInterface');
$entity_type = $this->createMock('\Drupal\Core\Entity\EntityTypeInterface');
$comment->expects($this->any())
->method('getEntityType')
->will($this->returnValue($entity_type));
$storage = $this->getMock('Drupal\comment\CommentStorageInterface');
$storage = $this->createMock('Drupal\comment\CommentStorageInterface');
// preSave() should acquire the lock. (This is what's really being tested.)
$comment->preSave($storage);

View File

@ -30,20 +30,20 @@ class CommentBulkFormTest extends UnitTestCase {
$actions = [];
for ($i = 1; $i <= 2; $i++) {
$action = $this->getMock('\Drupal\system\ActionConfigEntityInterface');
$action = $this->createMock('\Drupal\system\ActionConfigEntityInterface');
$action->expects($this->any())
->method('getType')
->will($this->returnValue('comment'));
$actions[$i] = $action;
}
$action = $this->getMock('\Drupal\system\ActionConfigEntityInterface');
$action = $this->createMock('\Drupal\system\ActionConfigEntityInterface');
$action->expects($this->any())
->method('getType')
->will($this->returnValue('user'));
$actions[] = $action;
$entity_storage = $this->getMock('Drupal\Core\Entity\EntityStorageInterface');
$entity_storage = $this->createMock('Drupal\Core\Entity\EntityStorageInterface');
$entity_storage->expects($this->any())
->method('loadMultiple')
->will($this->returnValue($actions));
@ -56,9 +56,9 @@ class CommentBulkFormTest extends UnitTestCase {
$entity_repository = $this->createMock(EntityRepositoryInterface::class);
$language_manager = $this->getMock('Drupal\Core\Language\LanguageManagerInterface');
$language_manager = $this->createMock('Drupal\Core\Language\LanguageManagerInterface');
$messenger = $this->getMock('Drupal\Core\Messenger\MessengerInterface');
$messenger = $this->createMock('Drupal\Core\Messenger\MessengerInterface');
$views_data = $this->getMockBuilder('Drupal\views\ViewsData')
->disableOriginalConstructor()
@ -72,7 +72,7 @@ class CommentBulkFormTest extends UnitTestCase {
$container->set('string_translation', $this->getStringTranslationStub());
\Drupal::setContainer($container);
$storage = $this->getMock('Drupal\views\ViewEntityInterface');
$storage = $this->createMock('Drupal\views\ViewEntityInterface');
$storage->expects($this->any())
->method('get')
->with('base_table')

View File

@ -57,11 +57,11 @@ class ConfigEntityMapperTest extends UnitTestCase {
protected $eventDispatcher;
protected function setUp() {
$this->entityTypeManager = $this->getMock('Drupal\Core\Entity\EntityTypeManagerInterface');
$this->entityTypeManager = $this->createMock('Drupal\Core\Entity\EntityTypeManagerInterface');
$this->entity = $this->getMock('Drupal\Core\Config\Entity\ConfigEntityInterface');
$this->entity = $this->createMock('Drupal\Core\Config\Entity\ConfigEntityInterface');
$this->routeProvider = $this->getMock('Drupal\Core\Routing\RouteProviderInterface');
$this->routeProvider = $this->createMock('Drupal\Core\Routing\RouteProviderInterface');
$this->routeProvider
->expects($this->any())
@ -78,15 +78,15 @@ class ConfigEntityMapperTest extends UnitTestCase {
'route_name' => 'config_translation.item.overview.entity.configurable_language.edit_form',
];
$typed_config_manager = $this->getMock('Drupal\Core\Config\TypedConfigManagerInterface');
$typed_config_manager = $this->createMock('Drupal\Core\Config\TypedConfigManagerInterface');
$locale_config_manager = $this->getMockBuilder('Drupal\locale\LocaleConfigManager')
->disableOriginalConstructor()
->getMock();
$this->languageManager = $this->getMock('Drupal\Core\Language\LanguageManagerInterface');
$this->languageManager = $this->createMock('Drupal\Core\Language\LanguageManagerInterface');
$this->eventDispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
$this->eventDispatcher = $this->createMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
$this->configEntityMapper = new ConfigEntityMapper(
'configurable_language',
@ -94,7 +94,7 @@ class ConfigEntityMapperTest extends UnitTestCase {
$this->getConfigFactoryStub(),
$typed_config_manager,
$locale_config_manager,
$this->getMock('Drupal\config_translation\ConfigMapperManagerInterface'),
$this->createMock('Drupal\config_translation\ConfigMapperManagerInterface'),
$this->routeProvider,
$this->getStringTranslationStub(),
$this->entityTypeManager,
@ -113,7 +113,7 @@ class ConfigEntityMapperTest extends UnitTestCase {
->with()
->will($this->returnValue('entity_id'));
$entity_type = $this->getMock('Drupal\Core\Config\Entity\ConfigEntityTypeInterface');
$entity_type = $this->createMock('Drupal\Core\Config\Entity\ConfigEntityTypeInterface');
$entity_type
->expects($this->any())
->method('getConfigPrefix')
@ -146,7 +146,7 @@ class ConfigEntityMapperTest extends UnitTestCase {
* Tests ConfigEntityMapper::getOverviewRouteParameters().
*/
public function testGetOverviewRouteParameters() {
$entity_type = $this->getMock('Drupal\Core\Config\Entity\ConfigEntityTypeInterface');
$entity_type = $this->createMock('Drupal\Core\Config\Entity\ConfigEntityTypeInterface');
$this->entityTypeManager
->expects($this->once())
->method('getDefinition')
@ -177,7 +177,7 @@ class ConfigEntityMapperTest extends UnitTestCase {
* Tests ConfigEntityMapper::getTypeName().
*/
public function testGetTypeName() {
$entity_type = $this->getMock('Drupal\Core\Config\Entity\ConfigEntityTypeInterface');
$entity_type = $this->createMock('Drupal\Core\Config\Entity\ConfigEntityTypeInterface');
$entity_type->expects($this->once())
->method('getLabel')
->will($this->returnValue('test'));
@ -195,7 +195,7 @@ class ConfigEntityMapperTest extends UnitTestCase {
* Tests ConfigEntityMapper::getTypeLabel().
*/
public function testGetTypeLabel() {
$entity_type = $this->getMock('Drupal\Core\Config\Entity\ConfigEntityTypeInterface');
$entity_type = $this->createMock('Drupal\Core\Config\Entity\ConfigEntityTypeInterface');
$entity_type->expects($this->once())
->method('getLabel')
->will($this->returnValue('test'));

View File

@ -46,8 +46,8 @@ class ConfigFieldMapperTest extends UnitTestCase {
* {@inheritdoc}
*/
protected function setUp() {
$this->entityTypeManager = $this->getMock('Drupal\Core\Entity\EntityTypeManagerInterface');
$this->entity = $this->getMock('Drupal\field\FieldConfigInterface');
$this->entityTypeManager = $this->createMock('Drupal\Core\Entity\EntityTypeManagerInterface');
$this->entity = $this->createMock('Drupal\field\FieldConfigInterface');
$definition = [
'class' => '\Drupal\config_translation\ConfigFieldMapper',
@ -61,19 +61,19 @@ class ConfigFieldMapperTest extends UnitTestCase {
->disableOriginalConstructor()
->getMock();
$this->eventDispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
$this->eventDispatcher = $this->createMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
$this->configFieldMapper = new ConfigFieldMapper(
'node_fields',
$definition,
$this->getConfigFactoryStub(),
$this->getMock('Drupal\Core\Config\TypedConfigManagerInterface'),
$this->createMock('Drupal\Core\Config\TypedConfigManagerInterface'),
$locale_config_manager,
$this->getMock('Drupal\config_translation\ConfigMapperManagerInterface'),
$this->getMock('Drupal\Core\Routing\RouteProviderInterface'),
$this->createMock('Drupal\config_translation\ConfigMapperManagerInterface'),
$this->createMock('Drupal\Core\Routing\RouteProviderInterface'),
$this->getStringTranslationStub(),
$this->entityTypeManager,
$this->getMock('Drupal\Core\Language\LanguageManagerInterface'),
$this->createMock('Drupal\Core\Language\LanguageManagerInterface'),
$this->eventDispatcher
);
}
@ -84,7 +84,7 @@ class ConfigFieldMapperTest extends UnitTestCase {
* @covers ::setEntity
*/
public function testSetEntity() {
$entity_type = $this->getMock('Drupal\Core\Config\Entity\ConfigEntityTypeInterface');
$entity_type = $this->createMock('Drupal\Core\Config\Entity\ConfigEntityTypeInterface');
$entity_type
->expects($this->any())
->method('getConfigPrefix')
@ -95,7 +95,7 @@ class ConfigFieldMapperTest extends UnitTestCase {
->method('getDefinition')
->will($this->returnValue($entity_type));
$field_storage = $this->getMock('Drupal\field\FieldStorageConfigInterface');
$field_storage = $this->createMock('Drupal\field\FieldStorageConfigInterface');
$field_storage
->expects($this->any())
->method('id')

View File

@ -32,7 +32,7 @@ class ConfigMapperManagerTest extends UnitTestCase {
protected function setUp() {
$language = new Language(['id' => 'en']);
$language_manager = $this->getMock('Drupal\Core\Language\LanguageManagerInterface');
$language_manager = $this->createMock('Drupal\Core\Language\LanguageManagerInterface');
$language_manager->expects($this->once())
->method('getCurrentLanguage')
->with(LanguageInterface::TYPE_INTERFACE)
@ -41,11 +41,11 @@ class ConfigMapperManagerTest extends UnitTestCase {
$this->typedConfigManager = $this->getMockBuilder('Drupal\Core\Config\TypedConfigManagerInterface')
->getMock();
$module_handler = $this->getMock('Drupal\Core\Extension\ModuleHandlerInterface');
$theme_handler = $this->getMock('Drupal\Core\Extension\ThemeHandlerInterface');
$module_handler = $this->createMock('Drupal\Core\Extension\ModuleHandlerInterface');
$theme_handler = $this->createMock('Drupal\Core\Extension\ThemeHandlerInterface');
$this->configMapperManager = new ConfigMapperManager(
$this->getMock('Drupal\Core\Cache\CacheBackendInterface'),
$this->createMock('Drupal\Core\Cache\CacheBackendInterface'),
$language_manager,
$module_handler,
$this->typedConfigManager,
@ -148,7 +148,7 @@ class ConfigMapperManagerTest extends UnitTestCase {
*/
protected function getElement(array $definition) {
$data_definition = new DataDefinition($definition);
$element = $this->getMock('Drupal\Core\TypedData\TypedDataInterface');
$element = $this->createMock('Drupal\Core\TypedData\TypedDataInterface');
$element->expects($this->any())
->method('getDataDefinition')
->will($this->returnValue($data_definition));

View File

@ -96,7 +96,7 @@ class ConfigNamesMapperTest extends UnitTestCase {
protected $eventDispatcher;
protected function setUp() {
$this->routeProvider = $this->getMock('Drupal\Core\Routing\RouteProviderInterface');
$this->routeProvider = $this->createMock('Drupal\Core\Routing\RouteProviderInterface');
$this->pluginDefinition = [
'class' => '\Drupal\config_translation\ConfigNamesMapper',
@ -106,15 +106,15 @@ class ConfigNamesMapperTest extends UnitTestCase {
'weight' => 42,
];
$this->typedConfigManager = $this->getMock('Drupal\Core\Config\TypedConfigManagerInterface');
$this->typedConfigManager = $this->createMock('Drupal\Core\Config\TypedConfigManagerInterface');
$this->localeConfigManager = $this->getMockBuilder('Drupal\locale\LocaleConfigManager')
->disableOriginalConstructor()
->getMock();
$this->configMapperManager = $this->getMock('Drupal\config_translation\ConfigMapperManagerInterface');
$this->configMapperManager = $this->createMock('Drupal\config_translation\ConfigMapperManagerInterface');
$this->urlGenerator = $this->getMock('Drupal\Core\Routing\UrlGeneratorInterface');
$this->urlGenerator = $this->createMock('Drupal\Core\Routing\UrlGeneratorInterface');
$container = new ContainerBuilder();
$container->set('url_generator', $this->urlGenerator);
\Drupal::setContainer($container);
@ -127,9 +127,9 @@ class ConfigNamesMapperTest extends UnitTestCase {
->with('system.site_information_settings')
->will($this->returnValue($this->baseRoute));
$this->languageManager = $this->getMock('Drupal\Core\Language\LanguageManagerInterface');
$this->languageManager = $this->createMock('Drupal\Core\Language\LanguageManagerInterface');
$this->eventDispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
$this->eventDispatcher = $this->createMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
$this->configNamesMapper = new TestConfigNamesMapper(
'system.site_information_settings',

View File

@ -70,11 +70,11 @@ class MailHandlerTest extends UnitTestCase {
*/
protected function setUp() {
parent::setUp();
$this->mailManager = $this->getMock('\Drupal\Core\Mail\MailManagerInterface');
$this->languageManager = $this->getMock('\Drupal\Core\Language\LanguageManagerInterface');
$this->logger = $this->getMock('\Psr\Log\LoggerInterface');
$this->mailManager = $this->createMock('\Drupal\Core\Mail\MailManagerInterface');
$this->languageManager = $this->createMock('\Drupal\Core\Language\LanguageManagerInterface');
$this->logger = $this->createMock('\Psr\Log\LoggerInterface');
$this->entityTypeManager = $this->createMock(EntityTypeManagerInterface::class);
$this->userStorage = $this->getMock('\Drupal\Core\Entity\EntityStorageInterface');
$this->userStorage = $this->createMock('\Drupal\Core\Entity\EntityStorageInterface');
$this->entityTypeManager->expects($this->any())
->method('getStorage')
->with('user')
@ -99,7 +99,7 @@ class MailHandlerTest extends UnitTestCase {
* @covers ::sendMailMessages
*/
public function testInvalidRecipient() {
$message = $this->getMock('\Drupal\contact\MessageInterface');
$message = $this->createMock('\Drupal\contact\MessageInterface');
$message->expects($this->once())
->method('isPersonal')
->willReturn(TRUE);
@ -108,8 +108,8 @@ class MailHandlerTest extends UnitTestCase {
->willReturn(NULL);
$message->expects($this->once())
->method('getContactForm')
->willReturn($this->getMock('\Drupal\contact\ContactFormInterface'));
$sender = $this->getMock('\Drupal\Core\Session\AccountInterface');
->willReturn($this->createMock('\Drupal\contact\ContactFormInterface'));
$sender = $this->createMock('\Drupal\Core\Session\AccountInterface');
$this->userStorage->expects($this->any())
->method('load')
->willReturn($sender);
@ -291,7 +291,7 @@ class MailHandlerTest extends UnitTestCase {
* Mock sender for testing.
*/
protected function getMockSender($anonymous = TRUE, $mail_address = 'anonymous@drupal.org') {
$sender = $this->getMock('\Drupal\Core\Session\AccountInterface');
$sender = $this->createMock('\Drupal\Core\Session\AccountInterface');
$sender->expects($this->once())
->method('isAnonymous')
->willReturn($anonymous);
@ -328,7 +328,7 @@ class MailHandlerTest extends UnitTestCase {
* Mock message for testing.
*/
protected function getAnonymousMockMessage($recipients, $auto_reply, $copy_sender = FALSE) {
$message = $this->getMock('\Drupal\contact\MessageInterface');
$message = $this->createMock('\Drupal\contact\MessageInterface');
$message->expects($this->any())
->method('getSenderName')
->willReturn('Anonymous');
@ -357,14 +357,14 @@ class MailHandlerTest extends UnitTestCase {
* Mock message for testing.
*/
protected function getAuthenticatedMockMessage($copy_sender = FALSE) {
$message = $this->getMock('\Drupal\contact\MessageInterface');
$message = $this->createMock('\Drupal\contact\MessageInterface');
$message->expects($this->any())
->method('isPersonal')
->willReturn(TRUE);
$message->expects($this->once())
->method('copySender')
->willReturn($copy_sender);
$recipient = $this->getMock('\Drupal\user\UserInterface');
$recipient = $this->createMock('\Drupal\user\UserInterface');
$recipient->expects($this->once())
->method('getEmail')
->willReturn('user2@drupal.org');
@ -395,7 +395,7 @@ class MailHandlerTest extends UnitTestCase {
* Mock message for testing.
*/
protected function getMockContactForm($recipients, $auto_reply) {
$contact_form = $this->getMock('\Drupal\contact\ContactFormInterface');
$contact_form = $this->createMock('\Drupal\contact\ContactFormInterface');
$contact_form->expects($this->once())
->method('getRecipients')
->willReturn($recipients);

View File

@ -50,7 +50,7 @@ class ContentTranslationManageAccessCheckTest extends UnitTestCase {
*/
public function testCreateAccess() {
// Set the mock translation handler.
$translation_handler = $this->getMock('\Drupal\content_translation\ContentTranslationHandlerInterface');
$translation_handler = $this->createMock('\Drupal\content_translation\ContentTranslationHandlerInterface');
$translation_handler->expects($this->once())
->method('getTranslationAccess')
->will($this->returnValue(AccessResult::allowed()));
@ -66,7 +66,7 @@ class ContentTranslationManageAccessCheckTest extends UnitTestCase {
$target = 'it';
// Set the mock language manager.
$language_manager = $this->getMock('Drupal\Core\Language\LanguageManagerInterface');
$language_manager = $this->createMock('Drupal\Core\Language\LanguageManagerInterface');
$language_manager->expects($this->at(0))
->method('getLanguage')
->with($this->equalTo($source))
@ -112,14 +112,14 @@ class ContentTranslationManageAccessCheckTest extends UnitTestCase {
$route->setRequirement('_access_content_translation_manage', 'create');
// Set up the route match.
$route_match = $this->getMock('Drupal\Core\Routing\RouteMatchInterface');
$route_match = $this->createMock('Drupal\Core\Routing\RouteMatchInterface');
$route_match->expects($this->once())
->method('getParameter')
->with('node')
->will($this->returnValue($entity));
// Set the mock account.
$account = $this->getMock('Drupal\Core\Session\AccountInterface');
$account = $this->createMock('Drupal\Core\Session\AccountInterface');
// The access check under test.
$check = new ContentTranslationManageAccessCheck($entity_type_manager, $language_manager);

View File

@ -18,14 +18,14 @@ class ContentTranslationLocalTasksTest extends LocalTaskIntegrationTestBase {
];
parent::setUp();
$entity_type = $this->getMock('Drupal\Core\Entity\EntityTypeInterface');
$entity_type = $this->createMock('Drupal\Core\Entity\EntityTypeInterface');
$entity_type->expects($this->any())
->method('getLinkTemplate')
->will($this->returnValueMap([
['canonical', 'entity.node.canonical'],
['drupal:content-translation-overview', 'entity.node.content_translation_overview'],
]));
$content_translation_manager = $this->getMock('Drupal\content_translation\ContentTranslationManagerInterface');
$content_translation_manager = $this->createMock('Drupal\content_translation\ContentTranslationManagerInterface');
$content_translation_manager->expects($this->any())
->method('getSupportedEntityTypes')
->will($this->returnValue([

View File

@ -62,18 +62,18 @@ class EditorConfigEntityUnitTest extends UnitTestCase {
$this->editorId = $this->randomMachineName();
$this->entityTypeId = $this->randomMachineName();
$this->entityType = $this->getMock('\Drupal\Core\Entity\EntityTypeInterface');
$this->entityType = $this->createMock('\Drupal\Core\Entity\EntityTypeInterface');
$this->entityType->expects($this->any())
->method('getProvider')
->will($this->returnValue('editor'));
$this->entityTypeManager = $this->getMock(EntityTypeManagerInterface::class);
$this->entityTypeManager = $this->createMock(EntityTypeManagerInterface::class);
$this->entityTypeManager->expects($this->any())
->method('getDefinition')
->with($this->entityTypeId)
->will($this->returnValue($this->entityType));
$this->uuid = $this->getMock('\Drupal\Component\Uuid\UuidInterface');
$this->uuid = $this->createMock('\Drupal\Component\Uuid\UuidInterface');
$this->editorPluginManager = $this->getMockBuilder('Drupal\editor\Plugin\EditorManager')
->disableOriginalConstructor()
@ -110,12 +110,12 @@ class EditorConfigEntityUnitTest extends UnitTestCase {
$entity = new Editor($values, $this->entityTypeId);
$filter_format = $this->getMock('Drupal\Core\Config\Entity\ConfigEntityInterface');
$filter_format = $this->createMock('Drupal\Core\Config\Entity\ConfigEntityInterface');
$filter_format->expects($this->once())
->method('getConfigDependencyName')
->will($this->returnValue('filter.format.test'));
$storage = $this->getMock('Drupal\Core\Entity\EntityStorageInterface');
$storage = $this->createMock('Drupal\Core\Entity\EntityStorageInterface');
$storage->expects($this->once())
->method('load')
->with($format_id)

View File

@ -75,14 +75,14 @@ class FieldConfigEntityUnitTest extends UnitTestCase {
*/
protected function setUp() {
$this->entityTypeId = $this->randomMachineName();
$this->entityType = $this->getMock('\Drupal\Core\Config\Entity\ConfigEntityTypeInterface');
$this->entityType = $this->createMock('\Drupal\Core\Config\Entity\ConfigEntityTypeInterface');
$this->entityTypeManager = $this->getMock(EntityTypeManagerInterface::class);
$this->entityFieldManager = $this->getMock(EntityFieldManagerInterface::class);
$this->entityTypeManager = $this->createMock(EntityTypeManagerInterface::class);
$this->entityFieldManager = $this->createMock(EntityFieldManagerInterface::class);
$this->uuid = $this->getMock('\Drupal\Component\Uuid\UuidInterface');
$this->uuid = $this->createMock('\Drupal\Component\Uuid\UuidInterface');
$this->fieldTypePluginManager = $this->getMock('Drupal\Core\Field\FieldTypePluginManagerInterface');
$this->fieldTypePluginManager = $this->createMock('Drupal\Core\Field\FieldTypePluginManagerInterface');
$container = new ContainerBuilder();
$container->set('entity_field.manager', $this->entityFieldManager);
@ -92,7 +92,7 @@ class FieldConfigEntityUnitTest extends UnitTestCase {
\Drupal::setContainer($container);
// Create a mock FieldStorageConfig object.
$this->fieldStorage = $this->getMock('\Drupal\field\FieldStorageConfigInterface');
$this->fieldStorage = $this->createMock('\Drupal\field\FieldStorageConfigInterface');
$this->fieldStorage->expects($this->any())
->method('getType')
->will($this->returnValue('test_field'));
@ -116,7 +116,7 @@ class FieldConfigEntityUnitTest extends UnitTestCase {
*/
public function testCalculateDependencies() {
// Mock the interfaces necessary to create a dependency on a bundle entity.
$target_entity_type = $this->getMock('\Drupal\Core\Entity\EntityTypeInterface');
$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']));
@ -163,7 +163,7 @@ class FieldConfigEntityUnitTest extends UnitTestCase {
* Test that invalid bundles are handled.
*/
public function testCalculateDependenciesIncorrectBundle() {
$storage = $this->getMock('\Drupal\Core\Config\Entity\ConfigEntityStorageInterface');
$storage = $this->createMock('\Drupal\Core\Config\Entity\ConfigEntityStorageInterface');
$storage->expects($this->any())
->method('load')
->with('test_bundle_not_exists')

View File

@ -64,7 +64,7 @@ class FieldStorageConfigAccessControlHandlerTest extends UnitTestCase {
protected function setUp() {
parent::setUp();
$this->anon = $this->getMock(AccountInterface::class);
$this->anon = $this->createMock(AccountInterface::class);
$this->anon
->expects($this->any())
->method('hasPermission')
@ -74,7 +74,7 @@ class FieldStorageConfigAccessControlHandlerTest extends UnitTestCase {
->method('id')
->will($this->returnValue(0));
$this->member = $this->getMock(AccountInterface::class);
$this->member = $this->createMock(AccountInterface::class);
$this->member
->expects($this->any())
->method('hasPermission')
@ -86,7 +86,7 @@ class FieldStorageConfigAccessControlHandlerTest extends UnitTestCase {
->method('id')
->will($this->returnValue(2));
$storageType = $this->getMock(ConfigEntityTypeInterface::class);
$storageType = $this->createMock(ConfigEntityTypeInterface::class);
$storageType
->expects($this->any())
->method('getProvider')
@ -96,7 +96,7 @@ class FieldStorageConfigAccessControlHandlerTest extends UnitTestCase {
->method('getConfigPrefix')
->will($this->returnValue('field.storage'));
$entityType = $this->getMock(ConfigEntityTypeInterface::class);
$entityType = $this->createMock(ConfigEntityTypeInterface::class);
$entityType
->expects($this->any())
->method('getProvider')
@ -106,7 +106,7 @@ class FieldStorageConfigAccessControlHandlerTest extends UnitTestCase {
->method('getConfigPrefix')
->willReturn('node');
$this->moduleHandler = $this->getMock(ModuleHandlerInterface::class);
$this->moduleHandler = $this->createMock(ModuleHandlerInterface::class);
$this->moduleHandler
->expects($this->any())
->method('getImplementations')
@ -119,7 +119,7 @@ class FieldStorageConfigAccessControlHandlerTest extends UnitTestCase {
$storage_access_control_handler = new FieldStorageConfigAccessControlHandler($storageType);
$storage_access_control_handler->setModuleHandler($this->moduleHandler);
$entity_type_manager = $this->getMock(EntityTypeManagerInterface::class);
$entity_type_manager = $this->createMock(EntityTypeManagerInterface::class);
$entity_type_manager
->expects($this->any())
->method('getDefinition')
@ -131,7 +131,7 @@ class FieldStorageConfigAccessControlHandlerTest extends UnitTestCase {
->expects($this->any())
->method('getStorage')
->willReturnMap([
['field_storage_config', $this->getMock(EntityStorageInterface::class)],
['field_storage_config', $this->createMock(EntityStorageInterface::class)],
]);
$entity_type_manager
->expects($this->any())
@ -142,7 +142,7 @@ class FieldStorageConfigAccessControlHandlerTest extends UnitTestCase {
$container = new Container();
$container->set('entity_type.manager', $entity_type_manager);
$container->set('uuid', $this->getMock(UuidInterface::class));
$container->set('uuid', $this->createMock(UuidInterface::class));
$container->set('cache_contexts_manager', $this->prophesize(CacheContextsManager::class));
\Drupal::setContainer($container);

View File

@ -54,9 +54,9 @@ class FieldStorageConfigEntityUnitTest extends UnitTestCase {
* {@inheritdoc}
*/
protected function setUp() {
$this->entityTypeManager = $this->getMock(EntityTypeManagerInterface::class);
$this->uuid = $this->getMock('\Drupal\Component\Uuid\UuidInterface');
$this->fieldTypeManager = $this->getMock(FieldTypePluginManagerInterface::class);
$this->entityTypeManager = $this->createMock(EntityTypeManagerInterface::class);
$this->uuid = $this->createMock('\Drupal\Component\Uuid\UuidInterface');
$this->fieldTypeManager = $this->createMock(FieldTypePluginManagerInterface::class);
$container = new ContainerBuilder();
$container->set('entity_type.manager', $this->entityTypeManager);
@ -70,14 +70,14 @@ class FieldStorageConfigEntityUnitTest extends UnitTestCase {
*/
public function testCalculateDependencies() {
// Create a mock entity type for FieldStorageConfig.
$fieldStorageConfigentityType = $this->getMock('\Drupal\Core\Config\Entity\ConfigEntityTypeInterface');
$fieldStorageConfigentityType = $this->createMock('\Drupal\Core\Config\Entity\ConfigEntityTypeInterface');
$fieldStorageConfigentityType->expects($this->any())
->method('getProvider')
->will($this->returnValue('field'));
// Create a mock entity type to attach the field to.
$attached_entity_type_id = $this->randomMachineName();
$attached_entity_type = $this->getMock('\Drupal\Core\Entity\EntityTypeInterface');
$attached_entity_type = $this->createMock('\Drupal\Core\Entity\EntityTypeInterface');
$attached_entity_type->expects($this->any())
->method('getProvider')
->will($this->returnValue('entity_provider_module'));

View File

@ -20,10 +20,10 @@ class FieldSettingsTest extends UnitTestCase {
* @dataProvider getSettingsProvider
*/
public function testGetSettings($field_type, $field_settings, $allowed_values) {
$migration = $this->getMock(MigrationInterface::class);
$migration = $this->createMock(MigrationInterface::class);
$plugin = new FieldSettings([], 'd6_field_settings', [], $migration);
$executable = $this->getMock(MigrateExecutableInterface::class);
$executable = $this->createMock(MigrateExecutableInterface::class);
$row = $this->getMockBuilder(Row::class)
->disableOriginalConstructor()
->getMock();

View File

@ -20,10 +20,10 @@ class FieldInstanceSettingsTest extends MigrateTestCase {
* @covers ::transform
*/
public function testTransformImageSettings() {
$migration = $this->getMock(MigrationInterface::class);
$migration = $this->createMock(MigrationInterface::class);
$plugin = new FieldInstanceSettings([], 'd7_field_instance_settings', [], $migration);
$executable = $this->getMock(MigrateExecutableInterface::class);
$executable = $this->createMock(MigrateExecutableInterface::class);
$row = $this->getMockBuilder(Row::class)
->disableOriginalConstructor()
->getMock();

View File

@ -20,10 +20,10 @@ class FieldSettingsTest extends MigrateTestCase {
* @covers ::transform
*/
public function testTransformImageSettings() {
$migration = $this->getMock(MigrationInterface::class);
$migration = $this->createMock(MigrationInterface::class);
$plugin = new FieldSettings([], 'd7_field_settings', [], $migration);
$executable = $this->getMock(MigrateExecutableInterface::class);
$executable = $this->createMock(MigrateExecutableInterface::class);
$row = $this->getMockBuilder(Row::class)
->disableOriginalConstructor()
->getMock();

View File

@ -26,7 +26,7 @@ class FieldUiTest extends UnitTestCase {
protected function setUp() {
parent::setUp();
$this->pathValidator = $this->getMock('Drupal\Core\Path\PathValidatorInterface');
$this->pathValidator = $this->createMock('Drupal\Core\Path\PathValidatorInterface');
$container = new ContainerBuilder();
$container->set('path.validator', $this->pathValidator);
\Drupal::setContainer($container);

View File

@ -33,7 +33,7 @@ class FilterIdTest extends KernelTestBase {
*/
protected function setUp() {
parent::setUp();
$this->executable = $this->getMock(MigrateExecutableInterface::class);
$this->executable = $this->createMock(MigrateExecutableInterface::class);
}
/**

View File

@ -23,10 +23,10 @@ class FilterSettingsTest extends MigrateTestCase {
* @covers ::transform
*/
public function testTransform($value, $destination_id, $expected_value) {
$migration = $this->getMock(MigrationInterface::class);
$migration = $this->createMock(MigrationInterface::class);
$plugin = new FilterSettings([], 'filter_settings', [], $migration);
$executable = $this->getMock(MigrateExecutableInterface::class);
$executable = $this->createMock(MigrateExecutableInterface::class);
$row = $this->getMockBuilder(Row::class)
->disableOriginalConstructor()
->getMock();

View File

@ -117,7 +117,7 @@ class FilterUninstallValidatorTest extends UnitTestCase {
['test_filter_plugin4', $filter_plugin_enabled],
]);
$filter_format1 = $this->getMock('Drupal\filter\FilterFormatInterface');
$filter_format1 = $this->createMock('Drupal\filter\FilterFormatInterface');
$filter_format1->expects($this->once())
->method('filters')
->willReturn($filter_plugin_collection1);
@ -142,7 +142,7 @@ class FilterUninstallValidatorTest extends UnitTestCase {
->with('test_filter_plugin4')
->willReturn($filter_plugin_enabled);
$filter_format2 = $this->getMock('Drupal\filter\FilterFormatInterface');
$filter_format2 = $this->createMock('Drupal\filter\FilterFormatInterface');
$filter_format2->expects($this->once())
->method('filters')
->willReturn($filter_plugin_collection2);

View File

@ -42,8 +42,8 @@ class ForumBreadcrumbBuilderBaseTest extends UnitTestCase {
'forum.settings' => ['IAmATestKey' => 'IAmATestValue'],
]
);
$forum_manager = $this->getMock('Drupal\forum\ForumManagerInterface');
$translation_manager = $this->getMock('Drupal\Core\StringTranslation\TranslationInterface');
$forum_manager = $this->createMock('Drupal\forum\ForumManagerInterface');
$translation_manager = $this->createMock('Drupal\Core\StringTranslation\TranslationInterface');
// Make an object to test.
$builder = $this->getMockForAbstractClass(
@ -101,7 +101,7 @@ class ForumBreadcrumbBuilderBaseTest extends UnitTestCase {
$prophecy->getCacheContexts()->willReturn([]);
$prophecy->getCacheMaxAge()->willReturn(Cache::PERMANENT);
$vocab_storage = $this->getMock('Drupal\Core\Entity\EntityStorageInterface');
$vocab_storage = $this->createMock('Drupal\Core\Entity\EntityStorageInterface');
$vocab_storage->expects($this->any())
->method('load')
->will($this->returnValueMap([
@ -140,7 +140,7 @@ class ForumBreadcrumbBuilderBaseTest extends UnitTestCase {
$breadcrumb_builder->setStringTranslation($translation_manager);
// Our empty data set.
$route_match = $this->getMock('Drupal\Core\Routing\RouteMatchInterface');
$route_match = $this->createMock('Drupal\Core\Routing\RouteMatchInterface');
// Expected result set.
$expected = [

View File

@ -4,6 +4,7 @@ namespace Drupal\Tests\forum\Unit\Breadcrumb;
use Drupal\Core\Cache\Cache;
use Drupal\Core\Link;
use Drupal\forum\Breadcrumb\ForumListingBreadcrumbBuilder;
use Drupal\taxonomy\TermStorageInterface;
use Drupal\Tests\UnitTestCase;
use Symfony\Component\DependencyInjection\Container;
@ -44,10 +45,10 @@ class ForumListingBreadcrumbBuilderTest extends UnitTestCase {
*/
public function testApplies($expected, $route_name = NULL, $parameter_map = []) {
// Make some test doubles.
$entity_manager = $this->getMock('Drupal\Core\Entity\EntityManagerInterface');
$entity_manager = $this->createMock('Drupal\Core\Entity\EntityManagerInterface');
$config_factory = $this->getConfigFactoryStub([]);
$forum_manager = $this->getMock('Drupal\forum\ForumManagerInterface');
$translation_manager = $this->getMock('Drupal\Core\StringTranslation\TranslationInterface');
$forum_manager = $this->createMock('Drupal\forum\ForumManagerInterface');
$translation_manager = $this->createMock('Drupal\Core\StringTranslation\TranslationInterface');
// Make an object to test.
$builder = $this->getMockBuilder('Drupal\forum\Breadcrumb\ForumListingBreadcrumbBuilder')
@ -60,7 +61,7 @@ class ForumListingBreadcrumbBuilderTest extends UnitTestCase {
->setMethods(NULL)
->getMock();
$route_match = $this->getMock('Drupal\Core\Routing\RouteMatchInterface');
$route_match = $this->createMock('Drupal\Core\Routing\RouteMatchInterface');
$route_match->expects($this->once())
->method('getRouteName')
->will($this->returnValue($route_name));
@ -154,7 +155,7 @@ class ForumListingBreadcrumbBuilderTest extends UnitTestCase {
$prophecy->getCacheTags()->willReturn(['taxonomy_vocabulary:5']);
$prophecy->getCacheContexts()->willReturn([]);
$prophecy->getCacheMaxAge()->willReturn(Cache::PERMANENT);
$vocab_storage = $this->getMock('Drupal\Core\Entity\EntityStorageInterface');
$vocab_storage = $this->createMock('Drupal\Core\Entity\EntityStorageInterface');
$vocab_storage->expects($this->any())
->method('load')
->will($this->returnValueMap([
@ -179,17 +180,10 @@ class ForumListingBreadcrumbBuilderTest extends UnitTestCase {
]
);
$forum_manager = $this->getMock('Drupal\forum\ForumManagerInterface');
$forum_manager = $this->createMock('Drupal\forum\ForumManagerInterface');
// Build a breadcrumb builder to test.
$breadcrumb_builder = $this->getMock(
'Drupal\forum\Breadcrumb\ForumListingBreadcrumbBuilder', NULL, [
$entity_manager,
$config_factory,
$forum_manager,
$translation_manager,
]
);
$breadcrumb_builder = new ForumListingBreadcrumbBuilder($entity_manager, $config_factory, $forum_manager, $translation_manager);
// Add a translation manager for t().
$translation_manager = $this->getStringTranslationStub();
@ -205,7 +199,7 @@ class ForumListingBreadcrumbBuilderTest extends UnitTestCase {
$forum_listing = $prophecy->reveal();
// Our data set.
$route_match = $this->getMock('Drupal\Core\Routing\RouteMatchInterface');
$route_match = $this->createMock('Drupal\Core\Routing\RouteMatchInterface');
$route_match->expects($this->exactly(2))
->method('getParameter')
->with('taxonomy_term')

View File

@ -4,6 +4,7 @@ namespace Drupal\Tests\forum\Unit\Breadcrumb;
use Drupal\Core\Cache\Cache;
use Drupal\Core\Link;
use Drupal\forum\Breadcrumb\ForumNodeBreadcrumbBuilder;
use Drupal\taxonomy\TermStorageInterface;
use Drupal\Tests\UnitTestCase;
use Symfony\Component\DependencyInjection\Container;
@ -44,15 +45,15 @@ class ForumNodeBreadcrumbBuilderTest extends UnitTestCase {
*/
public function testApplies($expected, $route_name = NULL, $parameter_map = []) {
// Make some test doubles.
$entity_manager = $this->getMock('Drupal\Core\Entity\EntityManagerInterface');
$entity_manager = $this->createMock('Drupal\Core\Entity\EntityManagerInterface');
$config_factory = $this->getConfigFactoryStub([]);
$forum_manager = $this->getMock('Drupal\forum\ForumManagerInterface');
$forum_manager = $this->createMock('Drupal\forum\ForumManagerInterface');
$forum_manager->expects($this->any())
->method('checkNodeType')
->will($this->returnValue(TRUE));
$translation_manager = $this->getMock('Drupal\Core\StringTranslation\TranslationInterface');
$translation_manager = $this->createMock('Drupal\Core\StringTranslation\TranslationInterface');
// Make an object to test.
$builder = $this->getMockBuilder('Drupal\forum\Breadcrumb\ForumNodeBreadcrumbBuilder')
@ -67,7 +68,7 @@ class ForumNodeBreadcrumbBuilderTest extends UnitTestCase {
->setMethods(NULL)
->getMock();
$route_match = $this->getMock('Drupal\Core\Routing\RouteMatchInterface');
$route_match = $this->createMock('Drupal\Core\Routing\RouteMatchInterface');
$route_match->expects($this->once())
->method('getRouteName')
->will($this->returnValue($route_name));
@ -164,7 +165,7 @@ class ForumNodeBreadcrumbBuilderTest extends UnitTestCase {
$prophecy->getCacheTags()->willReturn(['taxonomy_vocabulary:5']);
$prophecy->getCacheContexts()->willReturn([]);
$prophecy->getCacheMaxAge()->willReturn(Cache::PERMANENT);
$vocab_storage = $this->getMock('Drupal\Core\Entity\EntityStorageInterface');
$vocab_storage = $this->createMock('Drupal\Core\Entity\EntityStorageInterface');
$vocab_storage->expects($this->any())
->method('load')
->will($this->returnValueMap([
@ -190,20 +191,14 @@ class ForumNodeBreadcrumbBuilderTest extends UnitTestCase {
);
// Build a breadcrumb builder to test.
$breadcrumb_builder = $this->getMock(
'Drupal\forum\Breadcrumb\ForumNodeBreadcrumbBuilder', NULL, [
$entity_manager,
$config_factory,
$forum_manager,
$translation_manager,
]
);
$breadcrumb_builder = new ForumNodeBreadcrumbBuilder($entity_manager,
$config_factory,
$forum_manager,
$translation_manager);
// Add a translation manager for t().
$translation_manager = $this->getStringTranslationStub();
$property = new \ReflectionProperty('Drupal\forum\Breadcrumb\ForumNodeBreadcrumbBuilder', 'stringTranslation');
$property->setAccessible(TRUE);
$property->setValue($breadcrumb_builder, $translation_manager);
$breadcrumb_builder->setStringTranslation($translation_manager);
// The forum node we need a breadcrumb back from.
$forum_node = $this->getMockBuilder('Drupal\node\Entity\Node')
@ -211,7 +206,7 @@ class ForumNodeBreadcrumbBuilderTest extends UnitTestCase {
->getMock();
// Our data set.
$route_match = $this->getMock('Drupal\Core\Routing\RouteMatchInterface');
$route_match = $this->createMock('Drupal\Core\Routing\RouteMatchInterface');
$route_match->expects($this->exactly(2))
->method('getParameter')
->with('node')

View File

@ -23,7 +23,7 @@ class ForumManagerTest extends UnitTestCase {
->disableOriginalConstructor()
->getMock();
$config_factory = $this->getMock('\Drupal\Core\Config\ConfigFactoryInterface');
$config_factory = $this->createMock('\Drupal\Core\Config\ConfigFactoryInterface');
$config = $this->getMockBuilder('\Drupal\Core\Config\Config')
->disableOriginalConstructor()
@ -60,14 +60,17 @@ class ForumManagerTest extends UnitTestCase {
->disableOriginalConstructor()
->getMock();
$manager = $this->getMock('\Drupal\forum\ForumManager', ['getChildren'], [
$config_factory,
$entity_type_manager,
$connection,
$translation_manager,
$comment_manager,
$entity_field_manager,
]);
$manager = $this->getMockBuilder('\Drupal\forum\ForumManager')
->setMethods(['getChildren'])
->setConstructorArgs([
$config_factory,
$entity_type_manager,
$connection,
$translation_manager,
$comment_manager,
$entity_field_manager,
])
->getMock();
$manager->expects($this->once())
->method('getChildren')

View File

@ -56,7 +56,7 @@ class ForumUninstallValidatorTest extends UnitTestCase {
->method('hasForumNodes')
->willReturn(FALSE);
$vocabulary = $this->getMock('Drupal\taxonomy\VocabularyInterface');
$vocabulary = $this->createMock('Drupal\taxonomy\VocabularyInterface');
$this->forumUninstallValidator->expects($this->once())
->method('getForumVocabulary')
->willReturn($vocabulary);
@ -79,7 +79,7 @@ class ForumUninstallValidatorTest extends UnitTestCase {
->method('hasForumNodes')
->willReturn(TRUE);
$vocabulary = $this->getMock('Drupal\taxonomy\VocabularyInterface');
$vocabulary = $this->createMock('Drupal\taxonomy\VocabularyInterface');
$this->forumUninstallValidator->expects($this->once())
->method('getForumVocabulary')
->willReturn($vocabulary);
@ -107,7 +107,7 @@ class ForumUninstallValidatorTest extends UnitTestCase {
$url = $this->prophesize(Url::class);
$url->toString()->willReturn('/path/to/vocabulary/overview');
$vocabulary = $this->getMock('Drupal\taxonomy\VocabularyInterface');
$vocabulary = $this->createMock('Drupal\taxonomy\VocabularyInterface');
$vocabulary->expects($this->once())
->method('label')
->willReturn('Vocabulary label');
@ -142,7 +142,7 @@ class ForumUninstallValidatorTest extends UnitTestCase {
->method('hasForumNodes')
->willReturn(TRUE);
$vocabulary = $this->getMock('Drupal\taxonomy\VocabularyInterface');
$vocabulary = $this->createMock('Drupal\taxonomy\VocabularyInterface');
$vocabulary->expects($this->once())
->method('label')
->willReturn('Vocabulary label');
@ -179,7 +179,7 @@ class ForumUninstallValidatorTest extends UnitTestCase {
$url = $this->prophesize(Url::class);
$url->toString()->willReturn('/path/to/vocabulary/overview');
$vocabulary = $this->getMock('Drupal\taxonomy\VocabularyInterface');
$vocabulary = $this->createMock('Drupal\taxonomy\VocabularyInterface');
$vocabulary->expects($this->once())
->method('toUrl')
->willReturn($url->reveal());
@ -213,7 +213,7 @@ class ForumUninstallValidatorTest extends UnitTestCase {
->method('hasForumNodes')
->willReturn(FALSE);
$vocabulary = $this->getMock('Drupal\taxonomy\VocabularyInterface');
$vocabulary = $this->createMock('Drupal\taxonomy\VocabularyInterface');
$vocabulary->expects($this->once())
->method('label')
->willReturn('Vocabulary label');

View File

@ -18,7 +18,9 @@ abstract class NormalizerDenormalizeExceptionsUnitTestBase extends UnitTestCase
* @return array Test data.
*/
public function providerNormalizerDenormalizeExceptions() {
$mock = $this->getMock('\Drupal\Core\Field\Plugin\DataType\FieldItem', ['getParent']);
$mock = $this->getMockBuilder('\Drupal\Core\Field\Plugin\DataType\FieldItem')
->setMethods(['getParent'])
->getMock();
$mock->expects($this->any())
->method('getParent')
->will($this->returnValue(NULL));

View File

@ -88,11 +88,11 @@ class ImageStyleTest extends UnitTestCase {
protected function setUp() {
$this->entityTypeId = $this->randomMachineName();
$this->provider = $this->randomMachineName();
$this->entityType = $this->getMock('\Drupal\Core\Entity\EntityTypeInterface');
$this->entityType = $this->createMock('\Drupal\Core\Entity\EntityTypeInterface');
$this->entityType->expects($this->any())
->method('getProvider')
->will($this->returnValue($this->provider));
$this->entityTypeManager = $this->getMock('\Drupal\Core\Entity\EntityTypeManagerInterface');
$this->entityTypeManager = $this->createMock('\Drupal\Core\Entity\EntityTypeManagerInterface');
$this->entityTypeManager->expects($this->any())
->method('getDefinition')
->with($this->entityTypeId)

View File

@ -43,7 +43,7 @@ class DenyPrivateImageStyleDownloadTest extends UnitTestCase {
protected $routeMatch;
protected function setUp() {
$this->routeMatch = $this->getMock('Drupal\Core\Routing\RouteMatchInterface');
$this->routeMatch = $this->createMock('Drupal\Core\Routing\RouteMatchInterface');
$this->policy = new DenyPrivateImageStyleDownload($this->routeMatch);
$this->response = new Response();
$this->request = new Request();

View File

@ -52,11 +52,11 @@ class LanguageConfigOverrideTest extends UnitTestCase {
* {@inheritdoc}
*/
protected function setUp() {
$this->storage = $this->getMock('Drupal\Core\Config\StorageInterface');
$this->eventDispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
$this->typedConfig = $this->getMock('\Drupal\Core\Config\TypedConfigManagerInterface');
$this->storage = $this->createMock('Drupal\Core\Config\StorageInterface');
$this->eventDispatcher = $this->createMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
$this->typedConfig = $this->createMock('\Drupal\Core\Config\TypedConfigManagerInterface');
$this->configTranslation = new LanguageConfigOverride('config.test', $this->storage, $this->typedConfig, $this->eventDispatcher);
$this->cacheTagsInvalidator = $this->getMock('Drupal\Core\Cache\CacheTagsInvalidatorInterface');
$this->cacheTagsInvalidator = $this->createMock('Drupal\Core\Cache\CacheTagsInvalidatorInterface');
$container = new ContainerBuilder();
$container->set('cache_tags.invalidator', $this->cacheTagsInvalidator);

View File

@ -62,15 +62,15 @@ class ContentLanguageSettingsUnitTest extends UnitTestCase {
*/
protected function setUp() {
$this->entityTypeId = $this->randomMachineName();
$this->entityType = $this->getMock('\Drupal\Core\Entity\EntityTypeInterface');
$this->entityType = $this->createMock('\Drupal\Core\Entity\EntityTypeInterface');
$this->entityTypeManager = $this->getMock(EntityTypeManagerInterface::class);
$this->entityTypeManager = $this->createMock(EntityTypeManagerInterface::class);
$this->uuid = $this->getMock('\Drupal\Component\Uuid\UuidInterface');
$this->uuid = $this->createMock('\Drupal\Component\Uuid\UuidInterface');
$this->typedConfigManager = $this->getMock('Drupal\Core\Config\TypedConfigManagerInterface');
$this->typedConfigManager = $this->createMock('Drupal\Core\Config\TypedConfigManagerInterface');
$this->configEntityStorageInterface = $this->getMock('Drupal\Core\Entity\EntityStorageInterface');
$this->configEntityStorageInterface = $this->createMock('Drupal\Core\Entity\EntityStorageInterface');
$container = new ContainerBuilder();
$container->set('entity_type.manager', $this->entityTypeManager);
@ -85,7 +85,7 @@ class ContentLanguageSettingsUnitTest extends UnitTestCase {
*/
public function testCalculateDependencies() {
// Mock the interfaces necessary to create a dependency on a bundle entity.
$target_entity_type = $this->getMock('\Drupal\Core\Entity\EntityTypeInterface');
$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']));

View File

@ -25,11 +25,11 @@ class LanguageNegotiationUrlTest extends UnitTestCase {
protected function setUp() {
// Set up some languages to be used by the language-based path processor.
$language_de = $this->getMock('\Drupal\Core\Language\LanguageInterface');
$language_de = $this->createMock('\Drupal\Core\Language\LanguageInterface');
$language_de->expects($this->any())
->method('getId')
->will($this->returnValue('de'));
$language_en = $this->getMock('\Drupal\Core\Language\LanguageInterface');
$language_en = $this->createMock('\Drupal\Core\Language\LanguageInterface');
$language_en->expects($this->any())
->method('getId')
->will($this->returnValue('en'));

View File

@ -30,7 +30,7 @@ class LinkAccessConstraintValidatorTest extends UnitTestCase {
* @dataProvider providerValidate
*/
public function testValidate($value, $user, $valid) {
$context = $this->getMock(ExecutionContextInterface::class);
$context = $this->createMock(ExecutionContextInterface::class);
if ($valid) {
$context->expects($this->never())
@ -75,13 +75,13 @@ class LinkAccessConstraintValidatorTest extends UnitTestCase {
->method('access')
->willReturn($case['url_access']);
// Mock a link object that returns the URL object.
$link = $this->getMock('Drupal\link\LinkItemInterface');
$link = $this->createMock('Drupal\link\LinkItemInterface');
$link->expects($this->any())
->method('getUrl')
->willReturn($url);
// Mock a user object that returns a boolean indicating user access to all
// links.
$user = $this->getMock('Drupal\Core\Session\AccountProxyInterface');
$user = $this->createMock('Drupal\Core\Session\AccountProxyInterface');
$user->expects($this->any())
->method('hasPermission')
->with($this->equalTo('link to any page'))

View File

@ -20,7 +20,7 @@ class LinkExternalProtocolsConstraintValidatorTest extends UnitTestCase {
* @dataProvider providerValidate
*/
public function testValidate($value, $valid) {
$context = $this->getMock(ExecutionContextInterface::class);
$context = $this->createMock(ExecutionContextInterface::class);
if ($valid) {
$context->expects($this->never())
@ -57,7 +57,7 @@ class LinkExternalProtocolsConstraintValidatorTest extends UnitTestCase {
foreach ($data as &$single_data) {
$url = Url::fromUri($single_data[0]);
$link = $this->getMock('Drupal\link\LinkItemInterface');
$link = $this->createMock('Drupal\link\LinkItemInterface');
$link->expects($this->any())
->method('getUrl')
->willReturn($url);
@ -73,12 +73,12 @@ class LinkExternalProtocolsConstraintValidatorTest extends UnitTestCase {
* @see \Drupal\Core\Url::fromUri
*/
public function testValidateWithMalformedUri() {
$link = $this->getMock('Drupal\link\LinkItemInterface');
$link = $this->createMock('Drupal\link\LinkItemInterface');
$link->expects($this->any())
->method('getUrl')
->willThrowException(new \InvalidArgumentException());
$context = $this->getMock(ExecutionContextInterface::class);
$context = $this->createMock(ExecutionContextInterface::class);
$context->expects($this->never())
->method('addViolation');
@ -93,12 +93,12 @@ class LinkExternalProtocolsConstraintValidatorTest extends UnitTestCase {
* @covers ::validate
*/
public function testValidateIgnoresInternalUrls() {
$link = $this->getMock('Drupal\link\LinkItemInterface');
$link = $this->createMock('Drupal\link\LinkItemInterface');
$link->expects($this->any())
->method('getUrl')
->willReturn(Url::fromRoute('example.test'));
$context = $this->getMock(ExecutionContextInterface::class);
$context = $this->createMock(ExecutionContextInterface::class);
$context->expects($this->never())
->method('addViolation');

View File

@ -20,7 +20,7 @@ class LinkNotExistingInternalConstraintValidatorTest extends UnitTestCase {
* @dataProvider providerValidate
*/
public function testValidate($value, $valid) {
$context = $this->getMock(ExecutionContextInterface::class);
$context = $this->createMock(ExecutionContextInterface::class);
if ($valid) {
$context->expects($this->never())
@ -50,7 +50,7 @@ class LinkNotExistingInternalConstraintValidatorTest extends UnitTestCase {
// Existing routed URL.
$url = Url::fromRoute('example.existing_route');
$url_generator = $this->getMock('Drupal\Core\Routing\UrlGeneratorInterface');
$url_generator = $this->createMock('Drupal\Core\Routing\UrlGeneratorInterface');
$url_generator->expects($this->any())
->method('generateFromRoute')
->with('example.existing_route', [], [])
@ -62,7 +62,7 @@ class LinkNotExistingInternalConstraintValidatorTest extends UnitTestCase {
// Not existing routed URL.
$url = Url::fromRoute('example.not_existing_route');
$url_generator = $this->getMock('Drupal\Core\Routing\UrlGeneratorInterface');
$url_generator = $this->createMock('Drupal\Core\Routing\UrlGeneratorInterface');
$url_generator->expects($this->any())
->method('generateFromRoute')
->with('example.not_existing_route', [], [])
@ -72,7 +72,7 @@ class LinkNotExistingInternalConstraintValidatorTest extends UnitTestCase {
$data[] = [$url, FALSE];
foreach ($data as &$single_data) {
$link = $this->getMock('Drupal\link\LinkItemInterface');
$link = $this->createMock('Drupal\link\LinkItemInterface');
$link->expects($this->any())
->method('getUrl')
->willReturn($single_data[0]);
@ -89,12 +89,12 @@ class LinkNotExistingInternalConstraintValidatorTest extends UnitTestCase {
* @see \Drupal\Core\Url::fromUri
*/
public function testValidateWithMalformedUri() {
$link = $this->getMock('Drupal\link\LinkItemInterface');
$link = $this->createMock('Drupal\link\LinkItemInterface');
$link->expects($this->any())
->method('getUrl')
->willThrowException(new \InvalidArgumentException());
$context = $this->getMock(ExecutionContextInterface::class);
$context = $this->createMock(ExecutionContextInterface::class);
$context->expects($this->never())
->method('addViolation');

View File

@ -19,12 +19,12 @@ class FieldLinkTest extends UnitTestCase {
* @dataProvider canonicalizeUriDataProvider
*/
public function testCanonicalizeUri($url, $expected, $configuration = []) {
$link_plugin = new FieldLink($configuration, '', [], $this->getMock(MigrationInterface::class));
$link_plugin = new FieldLink($configuration, '', [], $this->createMock(MigrationInterface::class));
$transformed = $link_plugin->transform([
'url' => $url,
'title' => '',
'attributes' => serialize([]),
], $this->getMock(MigrateExecutableInterface::class), $this->getMockBuilder(Row::class)->disableOriginalConstructor()->getMock(), NULL);
], $this->createMock(MigrateExecutableInterface::class), $this->getMockBuilder(Row::class)->disableOriginalConstructor()->getMock(), NULL);
$this->assertEquals($expected, $transformed['uri']);
}
@ -93,8 +93,8 @@ class FieldLinkTest extends UnitTestCase {
* Test the attributes that are deeply serialized are discarded.
*/
public function testCanonicalizeUriSerialized() {
$link_plugin = new FieldLink([], '', [], $this->getMock(MigrationInterface::class));
$migrate_executable = $this->getMock(MigrateExecutableInterface::class);
$link_plugin = new FieldLink([], '', [], $this->createMock(MigrationInterface::class));
$migrate_executable = $this->createMock(MigrateExecutableInterface::class);
$row = new Row();
$transformed = $link_plugin->transform([

View File

@ -17,12 +17,12 @@ class FieldLinkTest extends UnitTestCase {
* @dataProvider canonicalizeUriDataProvider
*/
public function testCanonicalizeUri($url, $expected) {
$link_plugin = new FieldLink([], '', [], $this->getMock('\Drupal\migrate\Plugin\MigrationInterface'));
$link_plugin = new FieldLink([], '', [], $this->createMock('\Drupal\migrate\Plugin\MigrationInterface'));
$transformed = $link_plugin->transform([
'url' => $url,
'title' => '',
'attributes' => serialize([]),
], $this->getMock('\Drupal\migrate\MigrateExecutableInterface'), $this->getMockBuilder('\Drupal\migrate\Row')->disableOriginalConstructor()->getMock(), NULL);
], $this->createMock('\Drupal\migrate\MigrateExecutableInterface'), $this->getMockBuilder('\Drupal\migrate\Row')->disableOriginalConstructor()->getMock(), NULL);
$this->assertEquals($expected, $transformed['uri']);
}

View File

@ -68,20 +68,20 @@ class LocaleLookupTest extends UnitTestCase {
* {@inheritdoc}
*/
protected function setUp() {
$this->storage = $this->getMock('Drupal\locale\StringStorageInterface');
$this->cache = $this->getMock('Drupal\Core\Cache\CacheBackendInterface');
$this->lock = $this->getMock('Drupal\Core\Lock\LockBackendInterface');
$this->storage = $this->createMock('Drupal\locale\StringStorageInterface');
$this->cache = $this->createMock('Drupal\Core\Cache\CacheBackendInterface');
$this->lock = $this->createMock('Drupal\Core\Lock\LockBackendInterface');
$this->lock->expects($this->never())
->method($this->anything());
$this->user = $this->getMock('Drupal\Core\Session\AccountInterface');
$this->user = $this->createMock('Drupal\Core\Session\AccountInterface');
$this->user->expects($this->any())
->method('getRoles')
->will($this->returnValue(['anonymous']));
$this->configFactory = $this->getConfigFactoryStub(['locale.settings' => ['cache_strings' => FALSE]]);
$this->languageManager = $this->getMock('Drupal\Core\Language\LanguageManagerInterface');
$this->languageManager = $this->createMock('Drupal\Core\Language\LanguageManagerInterface');
$this->requestStack = new RequestStack();
$container = new ContainerBuilder();
@ -243,7 +243,7 @@ class LocaleLookupTest extends UnitTestCase {
* @covers ::resolveCacheMiss
*/
public function testResolveCacheMissNoTranslation() {
$string = $this->getMock('Drupal\locale\StringInterface');
$string = $this->createMock('Drupal\locale\StringInterface');
$string->expects($this->once())
->method('addLocation')
->will($this->returnSelf());

View File

@ -37,10 +37,10 @@ class LocaleTranslationTest extends UnitTestCase {
* {@inheritdoc}
*/
protected function setUp() {
$this->storage = $this->getMock('Drupal\locale\StringStorageInterface');
$this->cache = $this->getMock('Drupal\Core\Cache\CacheBackendInterface');
$this->lock = $this->getMock('Drupal\Core\Lock\LockBackendInterface');
$this->languageManager = $this->getMock('Drupal\Core\Language\LanguageManagerInterface');
$this->storage = $this->createMock('Drupal\locale\StringStorageInterface');
$this->cache = $this->createMock('Drupal\Core\Cache\CacheBackendInterface');
$this->lock = $this->createMock('Drupal\Core\Lock\LockBackendInterface');
$this->languageManager = $this->createMock('Drupal\Core\Language\LanguageManagerInterface');
$this->requestStack = new RequestStack();
}

View File

@ -89,7 +89,7 @@ class MigrateEntityContentBaseTest extends KernelTestBase {
$configuration,
'fake_plugin_id',
[],
$this->getMock(MigrationInterface::class),
$this->createMock(MigrationInterface::class),
$this->storage,
[],
$this->container->get('entity_field.manager'),

View File

@ -35,7 +35,7 @@ class SqlBaseTest extends MigrateTestBase {
protected function setUp() {
parent::setUp();
$this->migration = $this->getMock(MigrationInterface::class);
$this->migration = $this->createMock(MigrationInterface::class);
$this->migration->method('id')->willReturn('fubar');
}
@ -156,7 +156,7 @@ class SqlBaseTest extends MigrateTestBase {
$query->method('execute')->willReturn($statement);
$query->expects($this->atLeastOnce())->method('orderBy')->with('order', 'ASC');
$condition_group = $this->getMock(ConditionInterface::class);
$condition_group = $this->createMock(ConditionInterface::class);
$query->method('orConditionGroup')->willReturn($condition_group);
$source->setQuery($query);

View File

@ -100,14 +100,14 @@ class DownloadTest extends FileTestBase {
*/
protected function doTransform($destination_uri, $configuration = []) {
// Prepare a mock HTTP client.
$this->container->set('http_client', $this->getMock(Client::class));
$this->container->set('http_client', $this->createMock(Client::class));
// Instantiate the plugin statically so it can pull dependencies out of
// the container.
$plugin = Download::create($this->container, $configuration, 'download', []);
// Execute the transformation.
$executable = $this->getMock(MigrateExecutableInterface::class);
$executable = $this->createMock(MigrateExecutableInterface::class);
$row = new Row([], []);
// Return the downloaded file's local URI.

View File

@ -211,7 +211,7 @@ class FileCopyTest extends FileTestBase {
* Tests that remote URIs are delegated to the download plugin.
*/
public function testDownloadRemoteUri() {
$download_plugin = $this->getMock(MigrateProcessInterface::class);
$download_plugin = $this->createMock(MigrateProcessInterface::class);
$download_plugin->expects($this->once())->method('transform');
$plugin = new FileCopy(
@ -225,7 +225,7 @@ class FileCopyTest extends FileTestBase {
$plugin->transform(
['http://drupal.org/favicon.ico', '/destination/path'],
$this->getMock(MigrateExecutableInterface::class),
$this->createMock(MigrateExecutableInterface::class),
new Row([], []),
$this->randomMachineName()
);

View File

@ -52,7 +52,7 @@ class MigrateExecutableMemoryExceededTest extends MigrateTestCase {
protected function setUp() {
parent::setUp();
$this->migration = $this->getMigration();
$this->message = $this->getMock('Drupal\migrate\MigrateMessageInterface');
$this->message = $this->createMock('Drupal\migrate\MigrateMessageInterface');
$this->executable = new TestMigrateExecutable($this->migration, $this->message);
$this->executable->setStringTranslation($this->getStringTranslationStub());

View File

@ -51,8 +51,8 @@ class MigrateExecutableTest extends MigrateTestCase {
protected function setUp() {
parent::setUp();
$this->migration = $this->getMigration();
$this->message = $this->getMock('Drupal\migrate\MigrateMessageInterface');
$event_dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
$this->message = $this->createMock('Drupal\migrate\MigrateMessageInterface');
$event_dispatcher = $this->createMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
$this->executable = new TestMigrateExecutable($this->migration, $this->message, $event_dispatcher);
$this->executable->setStringTranslation($this->getStringTranslationStub());
}
@ -62,7 +62,7 @@ class MigrateExecutableTest extends MigrateTestCase {
*/
public function testImportWithFailingRewind() {
$exception_message = $this->getRandomGenerator()->string();
$source = $this->getMock('Drupal\migrate\Plugin\MigrateSourceInterface');
$source = $this->createMock('Drupal\migrate\Plugin\MigrateSourceInterface');
$source->expects($this->once())
->method('rewind')
->will($this->throwException(new \Exception($exception_message)));
@ -109,7 +109,7 @@ class MigrateExecutableTest extends MigrateTestCase {
->method('getProcessPlugins')
->will($this->returnValue([]));
$destination = $this->getMock('Drupal\migrate\Plugin\MigrateDestinationInterface');
$destination = $this->createMock('Drupal\migrate\Plugin\MigrateDestinationInterface');
$destination->expects($this->once())
->method('import')
->with($row, ['test'])
@ -151,7 +151,7 @@ class MigrateExecutableTest extends MigrateTestCase {
->method('getProcessPlugins')
->will($this->returnValue([]));
$destination = $this->getMock('Drupal\migrate\Plugin\MigrateDestinationInterface');
$destination = $this->createMock('Drupal\migrate\Plugin\MigrateDestinationInterface');
$destination->expects($this->once())
->method('import')
->with($row, ['test'])
@ -191,7 +191,7 @@ class MigrateExecutableTest extends MigrateTestCase {
->method('getProcessPlugins')
->will($this->returnValue([]));
$destination = $this->getMock('Drupal\migrate\Plugin\MigrateDestinationInterface');
$destination = $this->createMock('Drupal\migrate\Plugin\MigrateDestinationInterface');
$destination->expects($this->once())
->method('import')
->with($row, ['test'])
@ -251,7 +251,7 @@ class MigrateExecutableTest extends MigrateTestCase {
->method('getProcessPlugins')
->will($this->returnValue([]));
$destination = $this->getMock('Drupal\migrate\Plugin\MigrateDestinationInterface');
$destination = $this->createMock('Drupal\migrate\Plugin\MigrateDestinationInterface');
$destination->expects($this->once())
->method('import')
->with($row, ['test'])
@ -303,7 +303,7 @@ class MigrateExecutableTest extends MigrateTestCase {
->method('getProcessPlugins')
->willThrowException(new MigrateException($exception_message));
$destination = $this->getMock('Drupal\migrate\Plugin\MigrateDestinationInterface');
$destination = $this->createMock('Drupal\migrate\Plugin\MigrateDestinationInterface');
$destination->expects($this->never())
->method('import');
@ -349,7 +349,7 @@ class MigrateExecutableTest extends MigrateTestCase {
->method('getProcessPlugins')
->will($this->returnValue([]));
$destination = $this->getMock('Drupal\migrate\Plugin\MigrateDestinationInterface');
$destination = $this->createMock('Drupal\migrate\Plugin\MigrateDestinationInterface');
$destination->expects($this->once())
->method('import')
->with($row, ['test'])
@ -387,7 +387,7 @@ class MigrateExecutableTest extends MigrateTestCase {
'test1' => 'test1 destination',
];
foreach ($expected as $key => $value) {
$plugins[$key][0] = $this->getMock('Drupal\migrate\Plugin\MigrateProcessInterface');
$plugins[$key][0] = $this->createMock('Drupal\migrate\Plugin\MigrateProcessInterface');
$plugins[$key][0]->expects($this->once())
->method('getPluginDefinition')
->will($this->returnValue([]));
@ -473,7 +473,7 @@ class MigrateExecutableTest extends MigrateTestCase {
* The mocked migration source.
*/
protected function getMockSource() {
$iterator = $this->getMock('\Iterator');
$iterator = $this->createMock('\Iterator');
$class = 'Drupal\migrate\Plugin\migrate\source\SourcePluginBase';
$source = $this->getMockBuilder($class)

View File

@ -82,16 +82,16 @@ class MigrateSourceTest extends MigrateTestCase {
$container = new ContainerBuilder();
\Drupal::setContainer($container);
$key_value = $this->getMock(KeyValueStoreInterface::class);
$key_value = $this->createMock(KeyValueStoreInterface::class);
$key_value_factory = $this->getMock(KeyValueFactoryInterface::class);
$key_value_factory = $this->createMock(KeyValueFactoryInterface::class);
$key_value_factory
->method('get')
->with('migrate:high_water')
->willReturn($key_value);
$container->set('keyvalue', $key_value_factory);
$container->set('cache.migrate', $this->getMock(CacheBackendInterface::class));
$container->set('cache.migrate', $this->createMock(CacheBackendInterface::class));
$this->migrationConfiguration = $this->defaultMigrationConfiguration + $migrate_config;
$this->migration = parent::getMigration();
@ -108,7 +108,10 @@ class MigrateSourceTest extends MigrateTestCase {
$constructor_args = [$configuration, 'd6_action', [], $this->migration];
$methods = ['getModuleHandler', 'fields', 'getIds', '__toString', 'prepareRow', 'initializeIterator'];
$source_plugin = $this->getMock(SourcePluginBase::class, $methods, $constructor_args);
$source_plugin = $this->getMockBuilder(SourcePluginBase::class)
->setMethods($methods)
->setConstructorArgs($constructor_args)
->getMock();
$source_plugin
->method('fields')
@ -136,7 +139,7 @@ class MigrateSourceTest extends MigrateTestCase {
->method('initializeIterator')
->willReturn($iterator);
$module_handler = $this->getMock(ModuleHandlerInterface::class);
$module_handler = $this->createMock(ModuleHandlerInterface::class);
$source_plugin
->method('getModuleHandler')
->willReturn($module_handler);
@ -165,7 +168,7 @@ class MigrateSourceTest extends MigrateTestCase {
public function testCount() {
// Mock the cache to validate set() receives appropriate arguments.
$container = new ContainerBuilder();
$cache = $this->getMock(CacheBackendInterface::class);
$cache = $this->createMock(CacheBackendInterface::class);
$cache->expects($this->any())->method('set')
->with($this->isType('string'), $this->isType('int'), $this->isType('int'));
$container->set('cache.migrate', $cache);
@ -203,7 +206,7 @@ class MigrateSourceTest extends MigrateTestCase {
public function testCountCacheKey() {
// Mock the cache to validate set() receives appropriate arguments.
$container = new ContainerBuilder();
$cache = $this->getMock(CacheBackendInterface::class);
$cache = $this->createMock(CacheBackendInterface::class);
$cache->expects($this->any())->method('set')
->with('test_key', $this->isType('int'), $this->isType('int'));
$container->set('cache.migrate', $cache);
@ -440,9 +443,9 @@ class MigrateSourceTest extends MigrateTestCase {
*/
protected function getMigrateExecutable($migration) {
/** @var \Drupal\migrate\MigrateMessageInterface $message */
$message = $this->getMock('Drupal\migrate\MigrateMessageInterface');
$message = $this->createMock('Drupal\migrate\MigrateMessageInterface');
/** @var \Symfony\Component\EventDispatcher\EventDispatcherInterface $event_dispatcher */
$event_dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
$event_dispatcher = $this->createMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
return new MigrateExecutable($migration, $message, $event_dispatcher);
}

View File

@ -205,7 +205,7 @@ class MigrateSqlIdMapEnsureTablesTest extends MigrateTestCase {
->method('schema')
->willReturn($schema);
$migration = $this->getMigration();
$plugin = $this->getMock('Drupal\migrate\Plugin\MigrateSourceInterface');
$plugin = $this->createMock('Drupal\migrate\Plugin\MigrateSourceInterface');
$plugin->expects($this->any())
->method('getIds')
->willReturn([
@ -219,7 +219,7 @@ class MigrateSqlIdMapEnsureTablesTest extends MigrateTestCase {
$migration->expects($this->any())
->method('getSourcePlugin')
->willReturn($plugin);
$plugin = $this->getMock('Drupal\migrate\Plugin\MigrateSourceInterface');
$plugin = $this->createMock('Drupal\migrate\Plugin\MigrateSourceInterface');
$plugin->expects($this->any())
->method('getIds')
->willReturn([
@ -231,7 +231,7 @@ class MigrateSqlIdMapEnsureTablesTest extends MigrateTestCase {
->method('getDestinationPlugin')
->willReturn($plugin);
/** @var \Symfony\Component\EventDispatcher\EventDispatcherInterface $event_dispatcher */
$event_dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
$event_dispatcher = $this->createMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
$map = new TestSqlIdMap($database, [], 'sql', [], $migration, $event_dispatcher);
$map->getDatabase();
}

View File

@ -95,7 +95,7 @@ class MigrateSqlIdMapTest extends MigrateTestCase {
protected function getIdMap() {
$migration = $this->getMigration();
$plugin = $this->getMock('Drupal\migrate\Plugin\MigrateSourceInterface');
$plugin = $this->createMock('Drupal\migrate\Plugin\MigrateSourceInterface');
$plugin
->method('getIds')
->willReturn($this->sourceIds);
@ -103,14 +103,14 @@ class MigrateSqlIdMapTest extends MigrateTestCase {
->method('getSourcePlugin')
->willReturn($plugin);
$plugin = $this->getMock('Drupal\migrate\Plugin\MigrateDestinationInterface');
$plugin = $this->createMock('Drupal\migrate\Plugin\MigrateDestinationInterface');
$plugin
->method('getIds')
->willReturn($this->destinationIds);
$migration
->method('getDestinationPlugin')
->willReturn($plugin);
$event_dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
$event_dispatcher = $this->createMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
$id_map = new TestSqlIdMap($this->database, [], 'sql', [], $migration, $event_dispatcher);
$migration
@ -191,7 +191,7 @@ class MigrateSqlIdMapTest extends MigrateTestCase {
* Tests the SQL ID map set message method.
*/
public function testSetMessage() {
$message = $this->getMock('Drupal\migrate\MigrateMessageInterface');
$message = $this->createMock('Drupal\migrate\MigrateMessageInterface');
$id_map = $this->getIdMap();
$id_map->setMessage($message);
$this->assertAttributeEquals($message, 'message', $id_map);

View File

@ -80,17 +80,17 @@ abstract class MigrateSqlSourceTestCase extends MigrateTestCase {
* {@inheritdoc}
*/
protected function setUp() {
$module_handler = $this->getMock('Drupal\Core\Extension\ModuleHandlerInterface');
$state = $this->getMock('Drupal\Core\State\StateInterface');
$entity_manager = $this->getMock('Drupal\Core\Entity\EntityManagerInterface');
$module_handler = $this->createMock('Drupal\Core\Extension\ModuleHandlerInterface');
$state = $this->createMock('Drupal\Core\State\StateInterface');
$entity_manager = $this->createMock('Drupal\Core\Entity\EntityManagerInterface');
// Mock a key-value store to return high-water values.
$key_value = $this->getMock(KeyValueStoreInterface::class);
$key_value = $this->createMock(KeyValueStoreInterface::class);
// SourcePluginBase does not yet support full dependency injection so we
// need to make sure that \Drupal::keyValue() works as expected by mocking
// the keyvalue service.
$key_value_factory = $this->getMock(KeyValueFactoryInterface::class);
$key_value_factory = $this->createMock(KeyValueFactoryInterface::class);
$key_value_factory
->method('get')
->with('migrate:high_water')

View File

@ -41,7 +41,7 @@ abstract class MigrateTestCase extends UnitTestCase {
*/
protected function getMigration() {
$this->migrationConfiguration += ['migrationClass' => 'Drupal\migrate\Plugin\Migration'];
$this->idMap = $this->getMock('Drupal\migrate\Plugin\MigrateIdMapInterface');
$this->idMap = $this->createMock('Drupal\migrate\Plugin\MigrateIdMapInterface');
$this->idMap
->method('getQualifiedMapTableName')
@ -114,7 +114,7 @@ abstract class MigrateTestCase extends UnitTestCase {
// Initialize the DIC with a fake module handler for alterable queries.
$container = new ContainerBuilder();
$container->set('module_handler', $this->getMock('\Drupal\Core\Extension\ModuleHandlerInterface'));
$container->set('module_handler', $this->createMock('\Drupal\Core\Extension\ModuleHandlerInterface'));
\Drupal::setContainer($container);
// Create the tables and load them up with data, skipping empty ones.

View File

@ -26,9 +26,9 @@ class MigrationPluginManagerTest extends UnitTestCase {
parent::setUp();
// Get a plugin manager for testing.
$module_handler = $this->getMock('Drupal\Core\Extension\ModuleHandlerInterface');
$cache_backend = $this->getMock('Drupal\Core\Cache\CacheBackendInterface');
$language_manager = $this->getMock('Drupal\Core\Language\LanguageManagerInterface');
$module_handler = $this->createMock('Drupal\Core\Extension\ModuleHandlerInterface');
$cache_backend = $this->createMock('Drupal\Core\Cache\CacheBackendInterface');
$language_manager = $this->createMock('Drupal\Core\Language\LanguageManagerInterface');
$this->pluginManager = new MigrationPluginManager($module_handler, $cache_backend, $language_manager);
}

View File

@ -31,11 +31,11 @@ class MigrationTest extends UnitTestCase {
public function testRequirementsForSourcePlugin() {
$migration = new TestMigration();
$source_plugin = $this->getMock('Drupal\Tests\migrate\Unit\RequirementsAwareSourceInterface');
$source_plugin = $this->createMock('Drupal\Tests\migrate\Unit\RequirementsAwareSourceInterface');
$source_plugin->expects($this->once())
->method('checkRequirements')
->willThrowException(new RequirementsException('Missing source requirement', ['key' => 'value']));
$destination_plugin = $this->getMock('Drupal\Tests\migrate\Unit\RequirementsAwareDestinationInterface');
$destination_plugin = $this->createMock('Drupal\Tests\migrate\Unit\RequirementsAwareDestinationInterface');
$migration->setSourcePlugin($source_plugin);
$migration->setDestinationPlugin($destination_plugin);
@ -52,8 +52,8 @@ class MigrationTest extends UnitTestCase {
public function testRequirementsForDestinationPlugin() {
$migration = new TestMigration();
$source_plugin = $this->getMock('Drupal\migrate\Plugin\MigrateSourceInterface');
$destination_plugin = $this->getMock('Drupal\Tests\migrate\Unit\RequirementsAwareDestinationInterface');
$source_plugin = $this->createMock('Drupal\migrate\Plugin\MigrateSourceInterface');
$destination_plugin = $this->createMock('Drupal\Tests\migrate\Unit\RequirementsAwareDestinationInterface');
$destination_plugin->expects($this->once())
->method('checkRequirements')
->willThrowException(new RequirementsException('Missing destination requirement', ['key' => 'value']));
@ -74,21 +74,21 @@ class MigrationTest extends UnitTestCase {
$migration = new TestMigration();
// Setup source and destination plugins without any requirements.
$source_plugin = $this->getMock('Drupal\migrate\Plugin\MigrateSourceInterface');
$destination_plugin = $this->getMock('Drupal\migrate\Plugin\MigrateDestinationInterface');
$source_plugin = $this->createMock('Drupal\migrate\Plugin\MigrateSourceInterface');
$destination_plugin = $this->createMock('Drupal\migrate\Plugin\MigrateDestinationInterface');
$migration->setSourcePlugin($source_plugin);
$migration->setDestinationPlugin($destination_plugin);
$plugin_manager = $this->getMock('Drupal\migrate\Plugin\MigrationPluginManagerInterface');
$plugin_manager = $this->createMock('Drupal\migrate\Plugin\MigrationPluginManagerInterface');
$migration->setMigrationPluginManager($plugin_manager);
// We setup the requirements that test_a doesn't exist and test_c is not
// completed yet.
$migration->setRequirements(['test_a', 'test_b', 'test_c', 'test_d']);
$migration_b = $this->getMock(MigrationInterface::class);
$migration_c = $this->getMock(MigrationInterface::class);
$migration_d = $this->getMock(MigrationInterface::class);
$migration_b = $this->createMock(MigrationInterface::class);
$migration_c = $this->createMock(MigrationInterface::class);
$migration_d = $this->createMock(MigrationInterface::class);
$migration_b->expects($this->once())
->method('allRowsProcessed')

View File

@ -62,7 +62,7 @@ class SqlBaseTest extends UnitTestCase {
->willReturn($idmap_connection);
// Setup a migration entity.
$migration = $this->getMock(MigrationInterface::class);
$migration = $this->createMock(MigrationInterface::class);
$migration->expects($with_id_map ? $this->once() : $this->never())
->method('getIdMap')
->willReturn($id_map_is_sql ? $sql : NULL);

View File

@ -36,7 +36,7 @@ class ConfigTest extends UnitTestCase {
$config->expects($this->once())
->method('getName')
->willReturn('d8_config');
$config_factory = $this->getMock('Drupal\Core\Config\ConfigFactoryInterface');
$config_factory = $this->createMock('Drupal\Core\Config\ConfigFactoryInterface');
$config_factory->expects($this->once())
->method('getEditable')
->with('d8_config')
@ -83,7 +83,7 @@ class ConfigTest extends UnitTestCase {
$config->expects($this->any())
->method('getName')
->willReturn('d8_config');
$config_factory = $this->getMock('Drupal\Core\Config\ConfigFactoryInterface');
$config_factory = $this->createMock('Drupal\Core\Config\ConfigFactoryInterface');
$config_factory->expects($this->once())
->method('getEditable')
->with('d8_config')

View File

@ -44,9 +44,9 @@ class DedupeEntityTest extends MigrateProcessTestCase {
$this->entityQuery = $this->getMockBuilder('Drupal\Core\Entity\Query\QueryInterface')
->disableOriginalConstructor()
->getMock();
$this->entityTypeManager = $this->getMock(EntityTypeManagerInterface::class);
$this->entityTypeManager = $this->createMock(EntityTypeManagerInterface::class);
$storage = $this->getMock(EntityStorageInterface::class);
$storage = $this->createMock(EntityStorageInterface::class);
$storage->expects($this->any())
->method('getQuery')
->willReturn($this->entityQuery);

View File

@ -59,8 +59,8 @@ class IteratorTest extends MigrateTestCase {
$migration->expects($this->at(2))
->method('getProcessPlugins')
->will($this->returnValue($key_plugin));
$event_dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
$migrate_executable = new MigrateExecutable($migration, $this->getMock('Drupal\migrate\MigrateMessageInterface'), $event_dispatcher);
$event_dispatcher = $this->createMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
$migrate_executable = new MigrateExecutable($migration, $this->createMock('Drupal\migrate\MigrateMessageInterface'), $event_dispatcher);
// The current value of the pipeline.
$current_value = [

View File

@ -43,9 +43,9 @@ class MakeUniqueEntityFieldTest extends MigrateProcessTestCase {
$this->entityQuery = $this->getMockBuilder('Drupal\Core\Entity\Query\QueryInterface')
->disableOriginalConstructor()
->getMock();
$this->entityTypeManager = $this->getMock(EntityTypeManagerInterface::class);
$this->entityTypeManager = $this->createMock(EntityTypeManagerInterface::class);
$storage = $this->getMock(EntityStorageInterface::class);
$storage = $this->createMock(EntityStorageInterface::class);
$storage->expects($this->any())
->method('getQuery')
->willReturn($this->entityQuery);

View File

@ -53,8 +53,8 @@ class SubProcessTest extends MigrateTestCase {
$migration->expects($this->at(2))
->method('getProcessPlugins')
->will($this->returnValue($key_plugin));
$event_dispatcher = $this->getMock(EventDispatcherInterface::class);
$migrate_executable = new MigrateExecutable($migration, $this->getMock(MigrateMessageInterface::class), $event_dispatcher);
$event_dispatcher = $this->createMock(EventDispatcherInterface::class);
$migrate_executable = new MigrateExecutable($migration, $this->createMock(MigrateMessageInterface::class), $event_dispatcher);
// The current value of the pipeline.
$current_value = [

View File

@ -45,9 +45,9 @@ class DrupalSqlBaseTest extends MigrateTestCase {
$plugin_definition['requirements_met'] = TRUE;
$plugin_definition['source_module'] = 'module1';
/** @var \Drupal\Core\State\StateInterface $state */
$state = $this->getMock('Drupal\Core\State\StateInterface');
$state = $this->createMock('Drupal\Core\State\StateInterface');
/** @var \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager */
$entity_type_manager = $this->getMock('Drupal\Core\Entity\EntityTypeManagerInterface');
$entity_type_manager = $this->createMock('Drupal\Core\Entity\EntityTypeManagerInterface');
$plugin = new TestDrupalSqlBase([], 'placeholder_id', $plugin_definition, $this->getMigration(), $state, $entity_type_manager);
$plugin->setDatabase($this->getDatabase($this->databaseContents));
$system_data = $plugin->getSystemData();
@ -70,9 +70,9 @@ class DrupalSqlBaseTest extends MigrateTestCase {
$plugin_definition['requirements_met'] = TRUE;
$plugin_definition['source_module'] = 'module1';
/** @var \Drupal\Core\State\StateInterface $state */
$state = $this->getMock('Drupal\Core\State\StateInterface');
$state = $this->createMock('Drupal\Core\State\StateInterface');
/** @var \Drupal\Core\Entity\EntityTypeManagerInterface $entity_manager */
$entity_manager = $this->getMock('Drupal\Core\Entity\EntityTypeManagerInterface');
$entity_manager = $this->createMock('Drupal\Core\Entity\EntityTypeManagerInterface');
$plugin = new TestDrupalSqlBase([], 'test', $plugin_definition, $this->getMigration(), $state, $entity_manager);
$system_data = $plugin->getSystemData();
$this->setExpectedException(RequirementsException::class, 'No database connection configured for source plugin test');

View File

@ -69,9 +69,9 @@ class Drupal6SqlBaseTest extends MigrateTestCase {
protected function setUp() {
$plugin = 'placeholder_id';
/** @var \Drupal\Core\State\StateInterface $state */
$state = $this->getMock('Drupal\Core\State\StateInterface');
$state = $this->createMock('Drupal\Core\State\StateInterface');
/** @var \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager */
$entity_type_manager = $this->getMock('Drupal\Core\Entity\EntityTypeManagerInterface');
$entity_type_manager = $this->createMock('Drupal\Core\Entity\EntityTypeManagerInterface');
$this->base = new TestDrupal6SqlBase($this->migrationConfiguration, $plugin, [], $this->getMigration(), $state, $entity_type_manager);
$this->base->setDatabase($this->getDatabase($this->databaseContents));
}

View File

@ -43,7 +43,7 @@ class DenyNodePreviewTest extends UnitTestCase {
protected $routeMatch;
protected function setUp() {
$this->routeMatch = $this->getMock('Drupal\Core\Routing\RouteMatchInterface');
$this->routeMatch = $this->createMock('Drupal\Core\Routing\RouteMatchInterface');
$this->policy = new DenyNodePreview($this->routeMatch);
$this->response = new Response();
$this->request = new Request();

View File

@ -30,20 +30,20 @@ class NodeBulkFormTest extends UnitTestCase {
$actions = [];
for ($i = 1; $i <= 2; $i++) {
$action = $this->getMock('\Drupal\system\ActionConfigEntityInterface');
$action = $this->createMock('\Drupal\system\ActionConfigEntityInterface');
$action->expects($this->any())
->method('getType')
->will($this->returnValue('node'));
$actions[$i] = $action;
}
$action = $this->getMock('\Drupal\system\ActionConfigEntityInterface');
$action = $this->createMock('\Drupal\system\ActionConfigEntityInterface');
$action->expects($this->any())
->method('getType')
->will($this->returnValue('user'));
$actions[] = $action;
$entity_storage = $this->getMock('Drupal\Core\Entity\EntityStorageInterface');
$entity_storage = $this->createMock('Drupal\Core\Entity\EntityStorageInterface');
$entity_storage->expects($this->any())
->method('loadMultiple')
->will($this->returnValue($actions));
@ -56,9 +56,9 @@ class NodeBulkFormTest extends UnitTestCase {
$entity_repository = $this->createMock(EntityRepositoryInterface::class);
$language_manager = $this->getMock('Drupal\Core\Language\LanguageManagerInterface');
$language_manager = $this->createMock('Drupal\Core\Language\LanguageManagerInterface');
$messenger = $this->getMock('Drupal\Core\Messenger\MessengerInterface');
$messenger = $this->createMock('Drupal\Core\Messenger\MessengerInterface');
$views_data = $this->getMockBuilder('Drupal\views\ViewsData')
->disableOriginalConstructor()
@ -72,7 +72,7 @@ class NodeBulkFormTest extends UnitTestCase {
$container->set('string_translation', $this->getStringTranslationStub());
\Drupal::setContainer($container);
$storage = $this->getMock('Drupal\views\ViewEntityInterface');
$storage = $this->createMock('Drupal\views\ViewEntityInterface');
$storage->expects($this->any())
->method('get')
->with('base_table')

View File

@ -70,7 +70,7 @@ class QuickEditEntityFieldAccessCheckTest extends UnitTestCase {
->method('access')
->willReturn(AccessResult::allowedIf($entity_is_editable)->cachePerPermissions());
$field_storage = $this->getMock('Drupal\field\FieldStorageConfigInterface');
$field_storage = $this->createMock('Drupal\field\FieldStorageConfigInterface');
$field_storage->expects($this->any())
->method('access')
->willReturn(AccessResult::allowedIf($field_storage_is_accessible));
@ -88,7 +88,7 @@ class QuickEditEntityFieldAccessCheckTest extends UnitTestCase {
->with(LanguageInterface::LANGCODE_NOT_SPECIFIED)
->will($this->returnValue(TRUE));
$account = $this->getMock('Drupal\Core\Session\AccountInterface');
$account = $this->createMock('Drupal\Core\Session\AccountInterface');
$access = $this->editAccessCheck->access($entity_with_field, $field_name, LanguageInterface::LANGCODE_NOT_SPECIFIED, $account);
$this->assertEquals($expected_result, $access);
}
@ -99,7 +99,7 @@ class QuickEditEntityFieldAccessCheckTest extends UnitTestCase {
* @dataProvider providerTestAccessForbidden
*/
public function testAccessForbidden($field_name, $langcode) {
$account = $this->getMock('Drupal\Core\Session\AccountInterface');
$account = $this->createMock('Drupal\Core\Session\AccountInterface');
$entity = $this->createMockEntity();
$this->assertEquals(AccessResult::forbidden(), $this->editAccessCheck->access($entity, $field_name, $langcode, $account));
}

View File

@ -47,14 +47,14 @@ class RdfMappingConfigEntityUnitTest extends UnitTestCase {
protected function setUp() {
$this->entityTypeId = $this->randomMachineName();
$this->entityType = $this->getMock('\Drupal\Core\Entity\EntityTypeInterface');
$this->entityType = $this->createMock('\Drupal\Core\Entity\EntityTypeInterface');
$this->entityType->expects($this->any())
->method('getProvider')
->will($this->returnValue('entity'));
$this->entityTypeManager = $this->getMock(EntityTypeManagerInterface::class);
$this->entityTypeManager = $this->createMock(EntityTypeManagerInterface::class);
$this->uuid = $this->getMock('\Drupal\Component\Uuid\UuidInterface');
$this->uuid = $this->createMock('\Drupal\Component\Uuid\UuidInterface');
$container = new ContainerBuilder();
$container->set('entity_type.manager', $this->entityTypeManager);
@ -69,7 +69,7 @@ class RdfMappingConfigEntityUnitTest extends UnitTestCase {
public function testCalculateDependencies() {
$target_entity_type_id = $this->randomMachineName(16);
$target_entity_type = $this->getMock('\Drupal\Core\Entity\EntityTypeInterface');
$target_entity_type = $this->createMock('\Drupal\Core\Entity\EntityTypeInterface');
$target_entity_type->expects($this->any())
->method('getProvider')
->will($this->returnValue('test_module'));
@ -98,7 +98,7 @@ class RdfMappingConfigEntityUnitTest extends UnitTestCase {
*/
public function testCalculateDependenciesWithEntityBundle() {
$target_entity_type_id = $this->randomMachineName(16);
$target_entity_type = $this->getMock('\Drupal\Core\Entity\EntityTypeInterface');
$target_entity_type = $this->createMock('\Drupal\Core\Entity\EntityTypeInterface');
$target_entity_type->expects($this->any())
->method('getProvider')
->will($this->returnValue('test_module'));

View File

@ -39,18 +39,18 @@ class ResponsiveImageStyleConfigEntityUnitTest extends UnitTestCase {
* {@inheritdoc}
*/
protected function setUp() {
$this->entityType = $this->getMock('\Drupal\Core\Entity\EntityTypeInterface');
$this->entityType = $this->createMock('\Drupal\Core\Entity\EntityTypeInterface');
$this->entityType->expects($this->any())
->method('getProvider')
->will($this->returnValue('responsive_image'));
$this->entityTypeManager = $this->getMock(EntityTypeManagerInterface::class);
$this->entityTypeManager = $this->createMock(EntityTypeManagerInterface::class);
$this->entityTypeManager->expects($this->any())
->method('getDefinition')
->with('responsive_image_style')
->will($this->returnValue($this->entityType));
$this->breakpointManager = $this->getMock('\Drupal\breakpoint\BreakpointManagerInterface');
$this->breakpointManager = $this->createMock('\Drupal\breakpoint\BreakpointManagerInterface');
$container = new ContainerBuilder();
$container->set('entity_type.manager', $this->entityTypeManager);
@ -65,13 +65,13 @@ class ResponsiveImageStyleConfigEntityUnitTest extends UnitTestCase {
// Set up image style loading mock.
$styles = [];
foreach (['fallback', 'small', 'medium', 'large'] as $style) {
$mock = $this->getMock('Drupal\Core\Config\Entity\ConfigEntityInterface');
$mock = $this->createMock('Drupal\Core\Config\Entity\ConfigEntityInterface');
$mock->expects($this->any())
->method('getConfigDependencyName')
->willReturn('image.style.' . $style);
$styles[$style] = $mock;
}
$storage = $this->getMock('\Drupal\Core\Config\Entity\ConfigEntityStorageInterface');
$storage = $this->createMock('\Drupal\Core\Config\Entity\ConfigEntityStorageInterface');
$storage->expects($this->any())
->method('loadMultiple')
->with(array_keys($styles))

View File

@ -39,12 +39,15 @@ class CollectRoutesTest extends UnitTestCase {
->disableOriginalConstructor()
->getMock();
$this->view = $this->getMock('\Drupal\views\Entity\View', ['initHandlers'], [
['id' => 'test_view'],
'view',
]);
$this->view = $this->getMockBuilder('\Drupal\views\Entity\View')
->setMethods(['initHandlers'])
->setConstructorArgs([['id' => 'test_view'], 'view'])
->getMock();
$view_executable = $this->getMock('\Drupal\views\ViewExecutable', ['initHandlers', 'getTitle'], [], '', FALSE);
$view_executable = $this->getMockBuilder('\Drupal\views\ViewExecutable')
->setMethods(['initHandlers', 'getTitle'])
->disableOriginalConstructor()
->getMock();
$view_executable->expects($this->any())
->method('getTitle')
->willReturn('View title');
@ -69,16 +72,16 @@ class CollectRoutesTest extends UnitTestCase {
$container->setParameter('authentication_providers', ['basic_auth' => 'basic_auth']);
$state = $this->getMock('\Drupal\Core\State\StateInterface');
$state = $this->createMock('\Drupal\Core\State\StateInterface');
$container->set('state', $state);
$style_manager = $this->getMockBuilder('\Drupal\views\Plugin\ViewsPluginManager')
->disableOriginalConstructor()
->getMock();
$container->set('plugin.manager.views.style', $style_manager);
$container->set('renderer', $this->getMock('Drupal\Core\Render\RendererInterface'));
$container->set('renderer', $this->createMock('Drupal\Core\Render\RendererInterface'));
$authentication_collector = $this->getMock('\Drupal\Core\Authentication\AuthenticationCollectorInterface');
$authentication_collector = $this->createMock('\Drupal\Core\Authentication\AuthenticationCollectorInterface');
$container->set('authentication_collector', $authentication_collector);
$authentication_collector->expects($this->any())
->method('getSortedProviders')
@ -112,7 +115,10 @@ class CollectRoutesTest extends UnitTestCase {
->method('createInstance')
->will($this->returnValue($none));
$style_plugin = $this->getMock('\Drupal\rest\Plugin\views\style\Serializer', ['getFormats', 'init'], [], '', FALSE);
$style_plugin = $this->getMockBuilder('\Drupal\rest\Plugin\views\style\Serializer')
->setMethods(['getFormats', 'init'])
->disableOriginalConstructor()
->getMock();
$style_plugin->expects($this->once())
->method('getFormats')

View File

@ -50,9 +50,9 @@ class SearchPageRepositoryTest extends UnitTestCase {
* {@inheritdoc}
*/
protected function setUp() {
$this->query = $this->getMock('Drupal\Core\Entity\Query\QueryInterface');
$this->query = $this->createMock('Drupal\Core\Entity\Query\QueryInterface');
$this->storage = $this->getMock('Drupal\Core\Config\Entity\ConfigEntityStorageInterface');
$this->storage = $this->createMock('Drupal\Core\Config\Entity\ConfigEntityStorageInterface');
$this->storage->expects($this->any())
->method('getQuery')
->will($this->returnValue($this->query));
@ -63,7 +63,7 @@ class SearchPageRepositoryTest extends UnitTestCase {
->method('getStorage')
->will($this->returnValue($this->storage));
$this->configFactory = $this->getMock('Drupal\Core\Config\ConfigFactoryInterface');
$this->configFactory = $this->createMock('Drupal\Core\Config\ConfigFactoryInterface');
$this->searchPageRepository = new SearchPageRepository($this->configFactory, $entity_type_manager);
}
@ -80,8 +80,8 @@ class SearchPageRepositoryTest extends UnitTestCase {
->will($this->returnValue(['test' => 'test', 'other_test' => 'other_test']));
$entities = [];
$entities['test'] = $this->getMock('Drupal\search\SearchPageInterface');
$entities['other_test'] = $this->getMock('Drupal\search\SearchPageInterface');
$entities['test'] = $this->createMock('Drupal\search\SearchPageInterface');
$entities['other_test'] = $this->createMock('Drupal\search\SearchPageInterface');
$this->storage->expects($this->once())
->method('loadMultiple')
->with(['test' => 'test', 'other_test' => 'other_test'])
@ -123,11 +123,11 @@ class SearchPageRepositoryTest extends UnitTestCase {
->will($this->returnValue(['test' => 'test', 'other_test' => 'other_test']));
$entities = [];
$entities['test'] = $this->getMock('Drupal\search\SearchPageInterface');
$entities['test'] = $this->createMock('Drupal\search\SearchPageInterface');
$entities['test']->expects($this->once())
->method('isIndexable')
->will($this->returnValue(TRUE));
$entities['other_test'] = $this->getMock('Drupal\search\SearchPageInterface');
$entities['other_test'] = $this->createMock('Drupal\search\SearchPageInterface');
$entities['other_test']->expects($this->once())
->method('isIndexable')
->will($this->returnValue(FALSE));
@ -233,7 +233,7 @@ class SearchPageRepositoryTest extends UnitTestCase {
->with('search.settings')
->will($this->returnValue($config));
$search_page = $this->getMock('Drupal\search\SearchPageInterface');
$search_page = $this->createMock('Drupal\search\SearchPageInterface');
$search_page->expects($this->once())
->method('id')
->will($this->returnValue($id));
@ -250,7 +250,7 @@ class SearchPageRepositoryTest extends UnitTestCase {
* Tests the sortSearchPages() method.
*/
public function testSortSearchPages() {
$entity_type = $this->getMock('Drupal\Core\Entity\EntityTypeInterface');
$entity_type = $this->createMock('Drupal\Core\Entity\EntityTypeInterface');
$entity_type->expects($this->any())
->method('getClass')
->will($this->returnValue('Drupal\Tests\search\Unit\TestSearchPage'));

View File

@ -36,7 +36,7 @@ class SearchPluginCollectionTest extends UnitTestCase {
* {@inheritdoc}
*/
protected function setUp() {
$this->pluginManager = $this->getMock('Drupal\Component\Plugin\PluginManagerInterface');
$this->pluginManager = $this->createMock('Drupal\Component\Plugin\PluginManagerInterface');
$this->searchPluginCollection = new SearchPluginCollection($this->pluginManager, 'banana', ['id' => 'banana', 'color' => 'yellow'], 'fruit_stand');
}
@ -44,7 +44,7 @@ class SearchPluginCollectionTest extends UnitTestCase {
* Tests the get() method.
*/
public function testGet() {
$plugin = $this->getMock('Drupal\search\Plugin\SearchInterface');
$plugin = $this->createMock('Drupal\search\Plugin\SearchInterface');
$this->pluginManager->expects($this->once())
->method('createInstance')
->will($this->returnValue($plugin));
@ -55,7 +55,7 @@ class SearchPluginCollectionTest extends UnitTestCase {
* Tests the get() method with a configurable plugin.
*/
public function testGetWithConfigurablePlugin() {
$plugin = $this->getMock('Drupal\search\Plugin\ConfigurableSearchPluginInterface');
$plugin = $this->createMock('Drupal\search\Plugin\ConfigurableSearchPluginInterface');
$plugin->expects($this->once())
->method('setSearchPageId')
->with('fruit_stand')

View File

@ -34,7 +34,7 @@ class XmlEncoderTest extends UnitTestCase {
protected $testArray = ['test' => 'test'];
protected function setUp() {
$this->baseEncoder = $this->getMock(BaseXmlEncoder::class);
$this->baseEncoder = $this->createMock(BaseXmlEncoder::class);
$this->encoder = new XmlEncoder();
$this->encoder->setBaseEncoder($this->baseEncoder);
}

View File

@ -36,7 +36,7 @@ class ChainEntityResolverTest extends UnitTestCase {
* {@inheritdoc}
*/
protected function setUp() {
$this->testNormalizer = $this->getMock('Symfony\Component\Serializer\Normalizer\NormalizerInterface');
$this->testNormalizer = $this->createMock('Symfony\Component\Serializer\Normalizer\NormalizerInterface');
$this->testData = new \stdClass();
}
@ -134,7 +134,7 @@ class ChainEntityResolverTest extends UnitTestCase {
* The mocked entity resolver.
*/
protected function createEntityResolverMock($return = NULL, $called = TRUE) {
$mock = $this->getMock('Drupal\serialization\EntityResolver\EntityResolverInterface');
$mock = $this->createMock('Drupal\serialization\EntityResolver\EntityResolverInterface');
if ($called) {
$mock->expects($this->once())

View File

@ -42,7 +42,7 @@ class UuidResolverTest extends UnitTestCase {
$this->entityRepository->expects($this->never())
->method('loadEntityByUuid');
$normalizer = $this->getMock('Symfony\Component\Serializer\Normalizer\NormalizerInterface');
$normalizer = $this->createMock('Symfony\Component\Serializer\Normalizer\NormalizerInterface');
$this->assertNull($this->resolver->resolve($normalizer, [], 'test_type'));
}
@ -53,7 +53,7 @@ class UuidResolverTest extends UnitTestCase {
$this->entityRepository->expects($this->never())
->method('loadEntityByUuid');
$normalizer = $this->getMock('Drupal\serialization\EntityResolver\UuidReferenceInterface');
$normalizer = $this->createMock('Drupal\serialization\EntityResolver\UuidReferenceInterface');
$normalizer->expects($this->once())
->method('getUuid')
->with([])
@ -72,7 +72,7 @@ class UuidResolverTest extends UnitTestCase {
->with('test_type')
->will($this->returnValue(NULL));
$normalizer = $this->getMock('Drupal\serialization\EntityResolver\UuidReferenceInterface');
$normalizer = $this->createMock('Drupal\serialization\EntityResolver\UuidReferenceInterface');
$normalizer->expects($this->once())
->method('getUuid')
->with([])
@ -87,7 +87,7 @@ class UuidResolverTest extends UnitTestCase {
public function testResolveWithEntity() {
$uuid = '392eab92-35c2-4625-872d-a9dab4da008e';
$entity = $this->getMock('Drupal\Core\Entity\EntityInterface');
$entity = $this->createMock('Drupal\Core\Entity\EntityInterface');
$entity->expects($this->once())
->method('id')
->will($this->returnValue(1));
@ -97,7 +97,7 @@ class UuidResolverTest extends UnitTestCase {
->with('test_type', $uuid)
->will($this->returnValue($entity));
$normalizer = $this->getMock('Drupal\serialization\EntityResolver\UuidReferenceInterface');
$normalizer = $this->createMock('Drupal\serialization\EntityResolver\UuidReferenceInterface');
$normalizer->expects($this->once())
->method('getUuid')
->with([])

View File

@ -39,7 +39,7 @@ class ConfigEntityNormalizerTest extends UnitTestCase {
$entity_field_manager
);
$config_entity = $this->getMock('Drupal\Core\Config\Entity\ConfigEntityInterface');
$config_entity = $this->createMock('Drupal\Core\Config\Entity\ConfigEntityInterface');
$config_entity->expects($this->once())
->method('toArray')
->will($this->returnValue($test_export_properties));

View File

@ -52,8 +52,8 @@ class ContentEntityNormalizerTest extends UnitTestCase {
* @covers ::supportsNormalization
*/
public function testSupportsNormalization() {
$content_mock = $this->getMock('Drupal\Core\Entity\ContentEntityInterface');
$config_mock = $this->getMock('Drupal\Core\Entity\ConfigEntityInterface');
$content_mock = $this->createMock('Drupal\Core\Entity\ContentEntityInterface');
$config_mock = $this->createMock('Drupal\Core\Config\Entity\ConfigEntityInterface');
$this->assertTrue($this->contentEntityNormalizer->supportsNormalization($content_mock));
$this->assertFalse($this->contentEntityNormalizer->supportsNormalization($config_mock));
}
@ -92,7 +92,7 @@ class ContentEntityNormalizerTest extends UnitTestCase {
* @covers ::normalize
*/
public function testNormalizeWithAccountContext() {
$mock_account = $this->getMock('Drupal\Core\Session\AccountInterface');
$mock_account = $this->createMock('Drupal\Core\Session\AccountInterface');
$context = [
'account' => $mock_account,
@ -152,7 +152,7 @@ class ContentEntityNormalizerTest extends UnitTestCase {
*/
protected function createMockFieldListItem($access, $internal, AccountInterface $user_context = NULL) {
$data_definition = $this->prophesize(DataDefinitionInterface::class);
$mock = $this->getMock('Drupal\Core\Field\FieldItemListInterface');
$mock = $this->createMock('Drupal\Core\Field\FieldItemListInterface');
$mock->expects($this->once())
->method('getDataDefinition')
->will($this->returnValue($data_definition->reveal()));

View File

@ -73,8 +73,8 @@ class EntityNormalizerTest extends UnitTestCase {
* @covers ::normalize
*/
public function testNormalize() {
$list_item_1 = $this->getMock('Drupal\Core\TypedData\TypedDataInterface');
$list_item_2 = $this->getMock('Drupal\Core\TypedData\TypedDataInterface');
$list_item_1 = $this->createMock('Drupal\Core\TypedData\TypedDataInterface');
$list_item_2 = $this->createMock('Drupal\Core\TypedData\TypedDataInterface');
$definitions = [
'field_1' => $list_item_1,
@ -129,7 +129,7 @@ class EntityNormalizerTest extends UnitTestCase {
],
];
$entity_type = $this->getMock('Drupal\Core\Entity\EntityTypeInterface');
$entity_type = $this->createMock('Drupal\Core\Entity\EntityTypeInterface');
$entity_type->expects($this->once())
->method('id')
@ -151,12 +151,12 @@ class EntityNormalizerTest extends UnitTestCase {
->method('getBundleEntityType')
->will($this->returnValue('test_bundle'));
$entity_type_storage_definition = $this->getmock('Drupal\Core\Field\FieldStorageDefinitionInterface');
$entity_type_storage_definition = $this->createMock('Drupal\Core\Field\FieldStorageDefinitionInterface');
$entity_type_storage_definition->expects($this->once())
->method('getMainPropertyName')
->will($this->returnValue('name'));
$entity_type_definition = $this->getMock('Drupal\Core\Field\FieldDefinitionInterface');
$entity_type_definition = $this->createMock('Drupal\Core\Field\FieldDefinitionInterface');
$entity_type_definition->expects($this->once())
->method('getFieldStorageDefinition')
->will($this->returnValue($entity_type_storage_definition));
@ -174,12 +174,12 @@ class EntityNormalizerTest extends UnitTestCase {
->with('test')
->will($this->returnValue($base_definitions));
$entity_query_mock = $this->getMock('Drupal\Core\Entity\Query\QueryInterface');
$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']));
$entity_type_storage = $this->getMock('Drupal\Core\Entity\EntityStorageInterface');
$entity_type_storage = $this->createMock('Drupal\Core\Entity\EntityStorageInterface');
$entity_type_storage->expects($this->once())
->method('getQuery')
->will($this->returnValue($entity_query_mock));
@ -189,10 +189,10 @@ class EntityNormalizerTest extends UnitTestCase {
->with('test_bundle')
->will($this->returnValue($entity_type_storage));
$key_1 = $this->getMock(FieldItemListInterface::class);
$key_2 = $this->getMock(FieldItemListInterface::class);
$key_1 = $this->createMock(FieldItemListInterface::class);
$key_2 = $this->createMock(FieldItemListInterface::class);
$entity = $this->getMock(FieldableEntityInterface::class);
$entity = $this->createMock(FieldableEntityInterface::class);
$entity->expects($this->at(0))
->method('get')
->with('key_1')
@ -202,7 +202,7 @@ class EntityNormalizerTest extends UnitTestCase {
->with('key_2')
->willReturn($key_2);
$storage = $this->getMock('Drupal\Core\Entity\EntityStorageInterface');
$storage = $this->createMock('Drupal\Core\Entity\EntityStorageInterface');
// Create should only be called with the bundle property at first.
$expected_test_data = [
'test_type' => 'test_bundle',
@ -250,7 +250,7 @@ class EntityNormalizerTest extends UnitTestCase {
],
];
$entity_type = $this->getMock('Drupal\Core\Entity\EntityTypeInterface');
$entity_type = $this->createMock('Drupal\Core\Entity\EntityTypeInterface');
$entity_type->expects($this->once())
->method('id')
@ -272,12 +272,12 @@ class EntityNormalizerTest extends UnitTestCase {
->method('getBundleEntityType')
->will($this->returnValue('test_bundle'));
$entity_type_storage_definition = $this->getmock('Drupal\Core\Field\FieldStorageDefinitionInterface');
$entity_type_storage_definition = $this->createMock('Drupal\Core\Field\FieldStorageDefinitionInterface');
$entity_type_storage_definition->expects($this->once())
->method('getMainPropertyName')
->will($this->returnValue('name'));
$entity_type_definition = $this->getMock('Drupal\Core\Field\FieldDefinitionInterface');
$entity_type_definition = $this->createMock('Drupal\Core\Field\FieldDefinitionInterface');
$entity_type_definition->expects($this->once())
->method('getFieldStorageDefinition')
->will($this->returnValue($entity_type_storage_definition));
@ -295,12 +295,12 @@ class EntityNormalizerTest extends UnitTestCase {
->with('test')
->will($this->returnValue($base_definitions));
$entity_query_mock = $this->getMock('Drupal\Core\Entity\Query\QueryInterface');
$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']));
$entity_type_storage = $this->getMock('Drupal\Core\Entity\EntityStorageInterface');
$entity_type_storage = $this->createMock('Drupal\Core\Entity\EntityStorageInterface');
$entity_type_storage->expects($this->once())
->method('getQuery')
->will($this->returnValue($entity_query_mock));
@ -325,7 +325,7 @@ class EntityNormalizerTest extends UnitTestCase {
'key_2' => 'value_2',
];
$entity_type = $this->getMock('Drupal\Core\Entity\EntityTypeInterface');
$entity_type = $this->createMock('Drupal\Core\Entity\EntityTypeInterface');
$entity_type->expects($this->once())
->method('entityClassImplements')
->with(FieldableEntityInterface::class)
@ -342,10 +342,10 @@ class EntityNormalizerTest extends UnitTestCase {
->with('test')
->will($this->returnValue($entity_type));
$key_1 = $this->getMock(FieldItemListInterface::class);
$key_2 = $this->getMock(FieldItemListInterface::class);
$key_1 = $this->createMock(FieldItemListInterface::class);
$key_2 = $this->createMock(FieldItemListInterface::class);
$entity = $this->getMock(FieldableEntityInterface::class);
$entity = $this->createMock(FieldableEntityInterface::class);
$entity->expects($this->at(0))
->method('get')
->with('key_1')
@ -355,7 +355,7 @@ class EntityNormalizerTest extends UnitTestCase {
->with('key_2')
->willReturn($key_2);
$storage = $this->getMock('Drupal\Core\Entity\EntityStorageInterface');
$storage = $this->createMock('Drupal\Core\Entity\EntityStorageInterface');
$storage->expects($this->once())
->method('create')
->with([])
@ -398,7 +398,7 @@ class EntityNormalizerTest extends UnitTestCase {
'key_2' => 'value_2',
];
$entity_type = $this->getMock('Drupal\Core\Entity\EntityTypeInterface');
$entity_type = $this->createMock('Drupal\Core\Entity\EntityTypeInterface');
$entity_type->expects($this->once())
->method('entityClassImplements')
->with(FieldableEntityInterface::class)
@ -412,11 +412,11 @@ class EntityNormalizerTest extends UnitTestCase {
->with('test')
->will($this->returnValue($entity_type));
$storage = $this->getMock('Drupal\Core\Entity\EntityStorageInterface');
$storage = $this->createMock('Drupal\Core\Entity\EntityStorageInterface');
$storage->expects($this->once())
->method('create')
->with($test_data)
->will($this->returnValue($this->getMock('Drupal\Core\Entity\EntityInterface')));
->will($this->returnValue($this->createMock('Drupal\Core\Entity\EntityInterface')));
$this->entityTypeManager->expects($this->once())
->method('getStorage')

View File

@ -45,8 +45,8 @@ class ListNormalizerTest extends UnitTestCase {
protected function setUp() {
// Mock the TypedDataManager to return a TypedDataInterface mock.
$this->typedData = $this->getMock('Drupal\Core\TypedData\TypedDataInterface');
$typed_data_manager = $this->getMock(TypedDataManagerInterface::class);
$this->typedData = $this->createMock('Drupal\Core\TypedData\TypedDataInterface');
$typed_data_manager = $this->createMock(TypedDataManagerInterface::class);
$typed_data_manager->expects($this->any())
->method('getPropertyInstance')
->will($this->returnValue($this->typedData));

View File

@ -37,7 +37,7 @@ class NullNormalizerTest extends UnitTestCase {
* @covers ::supportsNormalization
*/
public function testSupportsNormalization() {
$mock = $this->getMock('Drupal\Core\TypedData\TypedDataInterface');
$mock = $this->createMock('Drupal\Core\TypedData\TypedDataInterface');
$this->assertTrue($this->normalizer->supportsNormalization($mock));
// Also test that an object not implementing TypedDataInterface fails.
$this->assertFalse($this->normalizer->supportsNormalization(new \stdClass()));
@ -47,7 +47,7 @@ class NullNormalizerTest extends UnitTestCase {
* @covers ::normalize
*/
public function testNormalize() {
$mock = $this->getMock('Drupal\Core\TypedData\TypedDataInterface');
$mock = $this->createMock('Drupal\Core\TypedData\TypedDataInterface');
$this->assertNull($this->normalizer->normalize($mock));
}

View File

@ -27,7 +27,7 @@ class TypedDataNormalizerTest extends UnitTestCase {
protected function setUp() {
$this->normalizer = new TypedDataNormalizer();
$this->typedData = $this->getMock('Drupal\Core\TypedData\TypedDataInterface');
$this->typedData = $this->createMock('Drupal\Core\TypedData\TypedDataInterface');
}
/**

View File

@ -100,21 +100,21 @@ class PathBasedBreadcrumbBuilderTest extends UnitTestCase {
protected function setUp() {
parent::setUp();
$this->requestMatcher = $this->getMock('\Symfony\Component\Routing\Matcher\RequestMatcherInterface');
$this->requestMatcher = $this->createMock('\Symfony\Component\Routing\Matcher\RequestMatcherInterface');
$config_factory = $this->getConfigFactoryStub(['system.site' => ['front' => 'test_frontpage']]);
$this->pathProcessor = $this->getMock('\Drupal\Core\PathProcessor\InboundPathProcessorInterface');
$this->context = $this->getMock('\Drupal\Core\Routing\RequestContext');
$this->pathProcessor = $this->createMock('\Drupal\Core\PathProcessor\InboundPathProcessorInterface');
$this->context = $this->createMock('\Drupal\Core\Routing\RequestContext');
$this->accessManager = $this->getMock('\Drupal\Core\Access\AccessManagerInterface');
$this->titleResolver = $this->getMock('\Drupal\Core\Controller\TitleResolverInterface');
$this->currentUser = $this->getMock('Drupal\Core\Session\AccountInterface');
$this->accessManager = $this->createMock('\Drupal\Core\Access\AccessManagerInterface');
$this->titleResolver = $this->createMock('\Drupal\Core\Controller\TitleResolverInterface');
$this->currentUser = $this->createMock('Drupal\Core\Session\AccountInterface');
$this->currentPath = $this->getMockBuilder('Drupal\Core\Path\CurrentPathStack')
->disableOriginalConstructor()
->getMock();
$this->pathMatcher = $this->getMock(PathMatcherInterface::class);
$this->pathMatcher = $this->createMock(PathMatcherInterface::class);
$this->builder = new TestPathBasedBreadcrumbBuilder(
$this->context,
@ -149,7 +149,7 @@ class PathBasedBreadcrumbBuilderTest extends UnitTestCase {
->method('isFrontPage')
->willReturn(TRUE);
$breadcrumb = $this->builder->build($this->getMock('Drupal\Core\Routing\RouteMatchInterface'));
$breadcrumb = $this->builder->build($this->createMock('Drupal\Core\Routing\RouteMatchInterface'));
$this->assertEquals([], $breadcrumb->getLinks());
$this->assertEquals(['url.path.is_front', 'url.path.parent'], $breadcrumb->getCacheContexts());
$this->assertEquals([], $breadcrumb->getCacheTags());
@ -166,7 +166,7 @@ class PathBasedBreadcrumbBuilderTest extends UnitTestCase {
->method('getPathInfo')
->will($this->returnValue('/example'));
$breadcrumb = $this->builder->build($this->getMock('Drupal\Core\Routing\RouteMatchInterface'));
$breadcrumb = $this->builder->build($this->createMock('Drupal\Core\Routing\RouteMatchInterface'));
$this->assertEquals([0 => new Link('Home', new Url('<front>'))], $breadcrumb->getLinks());
$this->assertEquals(['url.path.is_front', 'url.path.parent'], $breadcrumb->getCacheContexts());
$this->assertEquals([], $breadcrumb->getCacheTags());
@ -201,7 +201,7 @@ class PathBasedBreadcrumbBuilderTest extends UnitTestCase {
$this->setupAccessManagerToAllow();
$breadcrumb = $this->builder->build($this->getMock('Drupal\Core\Routing\RouteMatchInterface'));
$breadcrumb = $this->builder->build($this->createMock('Drupal\Core\Routing\RouteMatchInterface'));
$this->assertEquals([0 => new Link('Home', new Url('<front>')), 1 => new Link('Example', new Url('example'))], $breadcrumb->getLinks());
$this->assertEquals([
'url.path.is_front',
@ -252,7 +252,7 @@ class PathBasedBreadcrumbBuilderTest extends UnitTestCase {
AccessResult::allowed()->cachePerPermissions(),
AccessResult::allowed()->addCacheContexts(['bar'])->addCacheTags(['example'])
);
$breadcrumb = $this->builder->build($this->getMock('Drupal\Core\Routing\RouteMatchInterface'));
$breadcrumb = $this->builder->build($this->createMock('Drupal\Core\Routing\RouteMatchInterface'));
$this->assertEquals([
new Link('Home', new Url('<front>')),
new Link('Example', new Url('example')),
@ -286,7 +286,7 @@ class PathBasedBreadcrumbBuilderTest extends UnitTestCase {
->method('matchRequest')
->will($this->throwException(new $exception_class($exception_argument)));
$breadcrumb = $this->builder->build($this->getMock('Drupal\Core\Routing\RouteMatchInterface'));
$breadcrumb = $this->builder->build($this->createMock('Drupal\Core\Routing\RouteMatchInterface'));
// No path matched, though at least the frontpage is displayed.
$this->assertEquals([0 => new Link('Home', new Url('<front>'))], $breadcrumb->getLinks());
@ -330,7 +330,7 @@ class PathBasedBreadcrumbBuilderTest extends UnitTestCase {
->method('matchRequest')
->will($this->returnValue([]));
$breadcrumb = $this->builder->build($this->getMock('Drupal\Core\Routing\RouteMatchInterface'));
$breadcrumb = $this->builder->build($this->createMock('Drupal\Core\Routing\RouteMatchInterface'));
// No path matched, though at least the frontpage is displayed.
$this->assertEquals([0 => new Link('Home', new Url('<front>'))], $breadcrumb->getLinks());
@ -345,7 +345,7 @@ class PathBasedBreadcrumbBuilderTest extends UnitTestCase {
* @covers ::applies
*/
public function testApplies() {
$this->assertTrue($this->builder->applies($this->getMock('Drupal\Core\Routing\RouteMatchInterface')));
$this->assertTrue($this->builder->applies($this->createMock('Drupal\Core\Routing\RouteMatchInterface')));
}
/**
@ -380,7 +380,7 @@ class PathBasedBreadcrumbBuilderTest extends UnitTestCase {
->with($this->anything(), $route_1)
->will($this->returnValue('Admin'));
$breadcrumb = $this->builder->build($this->getMock('Drupal\Core\Routing\RouteMatchInterface'));
$breadcrumb = $this->builder->build($this->createMock('Drupal\Core\Routing\RouteMatchInterface'));
$this->assertEquals([0 => new Link('Home', new Url('<front>')), 1 => new Link('Admin', new Url('user_page'))], $breadcrumb->getLinks());
$this->assertEquals([
'url.path.is_front',

View File

@ -32,11 +32,11 @@ class MenuLinkTreeTest extends UnitTestCase {
parent::setUp();
$this->menuLinkTree = new MenuLinkTree(
$this->getMock('\Drupal\Core\Menu\MenuTreeStorageInterface'),
$this->getMock('\Drupal\Core\Menu\MenuLinkManagerInterface'),
$this->getMock('\Drupal\Core\Routing\RouteProviderInterface'),
$this->getMock('\Drupal\Core\Menu\MenuActiveTrailInterface'),
$this->getMock('\Drupal\Core\Controller\ControllerResolverInterface')
$this->createMock('\Drupal\Core\Menu\MenuTreeStorageInterface'),
$this->createMock('\Drupal\Core\Menu\MenuLinkManagerInterface'),
$this->createMock('\Drupal\Core\Routing\RouteProviderInterface'),
$this->createMock('\Drupal\Core\Menu\MenuActiveTrailInterface'),
$this->createMock('\Drupal\Core\Controller\ControllerResolverInterface')
);
$cache_contexts_manager = $this->getMockBuilder('Drupal\Core\Cache\Context\CacheContextsManager')

View File

@ -29,7 +29,7 @@ class SystemLocalTasksTest extends LocalTaskIntegrationTestBase {
'system' => 'core/modules/system',
];
$this->themeHandler = $this->getMock('Drupal\Core\Extension\ThemeHandlerInterface');
$this->themeHandler = $this->createMock('Drupal\Core\Extension\ThemeHandlerInterface');
$theme = new Extension($this->root, 'theme', '/core/themes/bartik', 'bartik.info.yml');
$theme->status = 1;

View File

@ -73,7 +73,7 @@ class PermissionAccessCheckTest extends UnitTestCase {
if (!empty($message)) {
$access_result->setReason($message);
}
$user = $this->getMock('Drupal\Core\Session\AccountInterface');
$user = $this->createMock('Drupal\Core\Session\AccountInterface');
$user->expects($this->any())
->method('hasPermission')
->will($this->returnValueMap([

View File

@ -61,7 +61,7 @@ class PermissionHandlerTest extends UnitTestCase {
parent::setUp();
$this->stringTranslation = new TestTranslationManager();
$this->controllerResolver = $this->getMock('Drupal\Core\Controller\ControllerResolverInterface');
$this->controllerResolver = $this->createMock('Drupal\Core\Controller\ControllerResolverInterface');
}
/**
@ -94,7 +94,7 @@ class PermissionHandlerTest extends UnitTestCase {
$root = new vfsStreamDirectory('modules');
vfsStreamWrapper::setRoot($root);
$this->moduleHandler = $this->getMock('Drupal\Core\Extension\ModuleHandlerInterface');
$this->moduleHandler = $this->createMock('Drupal\Core\Extension\ModuleHandlerInterface');
$this->moduleHandler->expects($this->once())
->method('getModuleDirectories')
->willReturn([
@ -169,7 +169,7 @@ EOF
$root = new vfsStreamDirectory('modules');
vfsStreamWrapper::setRoot($root);
$this->moduleHandler = $this->getMock('Drupal\Core\Extension\ModuleHandlerInterface');
$this->moduleHandler = $this->createMock('Drupal\Core\Extension\ModuleHandlerInterface');
$this->moduleHandler->expects($this->once())
->method('getModuleDirectories')
->willReturn([
@ -224,7 +224,7 @@ EOF
$root = new vfsStreamDirectory('modules');
vfsStreamWrapper::setRoot($root);
$this->moduleHandler = $this->getMock('Drupal\Core\Extension\ModuleHandlerInterface');
$this->moduleHandler = $this->createMock('Drupal\Core\Extension\ModuleHandlerInterface');
$this->moduleHandler->expects($this->once())
->method('getModuleDirectories')
->willReturn([
@ -304,7 +304,7 @@ EOF
$root = new vfsStreamDirectory('modules');
vfsStreamWrapper::setRoot($root);
$this->moduleHandler = $this->getMock('Drupal\Core\Extension\ModuleHandlerInterface');
$this->moduleHandler = $this->createMock('Drupal\Core\Extension\ModuleHandlerInterface');
$this->moduleHandler->expects($this->once())
->method('getModuleDirectories')
->willReturn([

View File

@ -33,7 +33,7 @@ abstract class RoleUserTestBase extends UnitTestCase {
->getMockBuilder('Drupal\user\Entity\User')
->disableOriginalConstructor()
->getMock();
$this->userRoleEntityType = $this->getMock('Drupal\Core\Entity\EntityTypeInterface');
$this->userRoleEntityType = $this->createMock('Drupal\Core\Entity\EntityTypeInterface');
}
}

View File

@ -18,20 +18,20 @@ class ProtectedUserFieldConstraintValidatorTest extends UnitTestCase {
*/
protected function createValidator() {
// Setup mocks that don't need to change.
$unchanged_field = $this->getMock('Drupal\Core\Field\FieldItemListInterface');
$unchanged_field = $this->createMock('Drupal\Core\Field\FieldItemListInterface');
$unchanged_field->expects($this->any())
->method('getValue')
->willReturn('unchanged-value');
$unchanged_account = $this->getMock('Drupal\user\UserInterface');
$unchanged_account = $this->createMock('Drupal\user\UserInterface');
$unchanged_account->expects($this->any())
->method('get')
->willReturn($unchanged_field);
$user_storage = $this->getMock('Drupal\user\UserStorageInterface');
$user_storage = $this->createMock('Drupal\user\UserStorageInterface');
$user_storage->expects($this->any())
->method('loadUnchanged')
->willReturn($unchanged_account);
$current_user = $this->getMock('Drupal\Core\Session\AccountProxyInterface');
$current_user = $this->createMock('Drupal\Core\Session\AccountProxyInterface');
$current_user->expects($this->any())
->method('id')
->willReturn('current-user');
@ -48,7 +48,7 @@ class ProtectedUserFieldConstraintValidatorTest extends UnitTestCase {
// If a violation is expected, then the context's addViolation method will
// be called, otherwise it should not be called.
$context = $this->getMock(ExecutionContextInterface::class);
$context = $this->createMock(ExecutionContextInterface::class);
if ($expected_violation) {
$context->expects($this->once())
@ -75,8 +75,8 @@ class ProtectedUserFieldConstraintValidatorTest extends UnitTestCase {
$cases[] = [NULL, FALSE];
// Case 2: Empty user should be ignored.
$field_definition = $this->getMock('Drupal\Core\Field\FieldDefinitionInterface');
$items = $this->getMock('Drupal\Core\Field\FieldItemListInterface');
$field_definition = $this->createMock('Drupal\Core\Field\FieldDefinitionInterface');
$items = $this->createMock('Drupal\Core\Field\FieldItemListInterface');
$items->expects($this->once())
->method('getFieldDefinition')
->willReturn($field_definition);
@ -86,10 +86,10 @@ class ProtectedUserFieldConstraintValidatorTest extends UnitTestCase {
$cases[] = [$items, FALSE];
// Case 3: Account flagged to skip protected user should be ignored.
$field_definition = $this->getMock('Drupal\Core\Field\FieldDefinitionInterface');
$account = $this->getMock('Drupal\user\UserInterface');
$field_definition = $this->createMock('Drupal\Core\Field\FieldDefinitionInterface');
$account = $this->createMock('Drupal\user\UserInterface');
$account->_skipProtectedUserFieldConstraint = TRUE;
$items = $this->getMock('Drupal\Core\Field\FieldItemListInterface');
$items = $this->createMock('Drupal\Core\Field\FieldItemListInterface');
$items->expects($this->once())
->method('getFieldDefinition')
->willReturn($field_definition);
@ -99,12 +99,12 @@ class ProtectedUserFieldConstraintValidatorTest extends UnitTestCase {
$cases[] = [$items, FALSE];
// Case 4: New user should be ignored.
$field_definition = $this->getMock('Drupal\Core\Field\FieldDefinitionInterface');
$account = $this->getMock('Drupal\user\UserInterface');
$field_definition = $this->createMock('Drupal\Core\Field\FieldDefinitionInterface');
$account = $this->createMock('Drupal\user\UserInterface');
$account->expects($this->once())
->method('isNew')
->willReturn(TRUE);
$items = $this->getMock('Drupal\Core\Field\FieldItemListInterface');
$items = $this->createMock('Drupal\Core\Field\FieldItemListInterface');
$items->expects($this->once())
->method('getFieldDefinition')
->willReturn($field_definition);
@ -114,14 +114,14 @@ class ProtectedUserFieldConstraintValidatorTest extends UnitTestCase {
$cases[] = [$items, FALSE];
// Case 5: Mismatching user IDs should also be ignored.
$account = $this->getMock('Drupal\user\UserInterface');
$account = $this->createMock('Drupal\user\UserInterface');
$account->expects($this->once())
->method('isNew')
->willReturn(FALSE);
$account->expects($this->once())
->method('id')
->willReturn('not-current-user');
$items = $this->getMock('Drupal\Core\Field\FieldItemListInterface');
$items = $this->createMock('Drupal\Core\Field\FieldItemListInterface');
$items->expects($this->once())
->method('getFieldDefinition')
->willReturn($field_definition);
@ -131,11 +131,11 @@ class ProtectedUserFieldConstraintValidatorTest extends UnitTestCase {
$cases[] = [$items, FALSE];
// Case 6: Non-password fields that have not changed should be ignored.
$field_definition = $this->getMock('Drupal\Core\Field\FieldDefinitionInterface');
$field_definition = $this->createMock('Drupal\Core\Field\FieldDefinitionInterface');
$field_definition->expects($this->exactly(2))
->method('getName')
->willReturn('field_not_password');
$account = $this->getMock('Drupal\user\UserInterface');
$account = $this->createMock('Drupal\user\UserInterface');
$account->expects($this->once())
->method('isNew')
->willReturn(FALSE);
@ -144,7 +144,7 @@ class ProtectedUserFieldConstraintValidatorTest extends UnitTestCase {
->willReturn('current-user');
$account->expects($this->never())
->method('checkExistingPassword');
$items = $this->getMock('Drupal\Core\Field\FieldItemListInterface');
$items = $this->createMock('Drupal\Core\Field\FieldItemListInterface');
$items->expects($this->once())
->method('getFieldDefinition')
->willReturn($field_definition);
@ -157,11 +157,11 @@ class ProtectedUserFieldConstraintValidatorTest extends UnitTestCase {
$cases[] = [$items, FALSE];
// Case 7: Password field with no value set should be ignored.
$field_definition = $this->getMock('Drupal\Core\Field\FieldDefinitionInterface');
$field_definition = $this->createMock('Drupal\Core\Field\FieldDefinitionInterface');
$field_definition->expects($this->once())
->method('getName')
->willReturn('pass');
$account = $this->getMock('Drupal\user\UserInterface');
$account = $this->createMock('Drupal\user\UserInterface');
$account->expects($this->once())
->method('isNew')
->willReturn(FALSE);
@ -170,7 +170,7 @@ class ProtectedUserFieldConstraintValidatorTest extends UnitTestCase {
->willReturn('current-user');
$account->expects($this->never())
->method('checkExistingPassword');
$items = $this->getMock('Drupal\Core\Field\FieldItemListInterface');
$items = $this->createMock('Drupal\Core\Field\FieldItemListInterface');
$items->expects($this->once())
->method('getFieldDefinition')
->willReturn($field_definition);
@ -181,11 +181,11 @@ class ProtectedUserFieldConstraintValidatorTest extends UnitTestCase {
// Case 8: Non-password field changed, but user has passed provided current
// password.
$field_definition = $this->getMock('Drupal\Core\Field\FieldDefinitionInterface');
$field_definition = $this->createMock('Drupal\Core\Field\FieldDefinitionInterface');
$field_definition->expects($this->exactly(2))
->method('getName')
->willReturn('field_not_password');
$account = $this->getMock('Drupal\user\UserInterface');
$account = $this->createMock('Drupal\user\UserInterface');
$account->expects($this->once())
->method('isNew')
->willReturn(FALSE);
@ -195,7 +195,7 @@ class ProtectedUserFieldConstraintValidatorTest extends UnitTestCase {
$account->expects($this->once())
->method('checkExistingPassword')
->willReturn(TRUE);
$items = $this->getMock('Drupal\Core\Field\FieldItemListInterface');
$items = $this->createMock('Drupal\Core\Field\FieldItemListInterface');
$items->expects($this->once())
->method('getFieldDefinition')
->willReturn($field_definition);
@ -208,11 +208,11 @@ class ProtectedUserFieldConstraintValidatorTest extends UnitTestCase {
$cases[] = [$items, FALSE];
// Case 9: Password field changed, current password confirmed.
$field_definition = $this->getMock('Drupal\Core\Field\FieldDefinitionInterface');
$field_definition = $this->createMock('Drupal\Core\Field\FieldDefinitionInterface');
$field_definition->expects($this->exactly(2))
->method('getName')
->willReturn('pass');
$account = $this->getMock('Drupal\user\UserInterface');
$account = $this->createMock('Drupal\user\UserInterface');
$account->expects($this->once())
->method('isNew')
->willReturn(FALSE);
@ -222,7 +222,7 @@ class ProtectedUserFieldConstraintValidatorTest extends UnitTestCase {
$account->expects($this->once())
->method('checkExistingPassword')
->willReturn(TRUE);
$items = $this->getMock('Drupal\Core\Field\FieldItemListInterface');
$items = $this->createMock('Drupal\Core\Field\FieldItemListInterface');
$items->expects($this->once())
->method('getFieldDefinition')
->willReturn($field_definition);
@ -241,14 +241,14 @@ class ProtectedUserFieldConstraintValidatorTest extends UnitTestCase {
// The below calls should result in a violation.
// Case 10: Password field changed, current password not confirmed.
$field_definition = $this->getMock('Drupal\Core\Field\FieldDefinitionInterface');
$field_definition = $this->createMock('Drupal\Core\Field\FieldDefinitionInterface');
$field_definition->expects($this->exactly(2))
->method('getName')
->willReturn('pass');
$field_definition->expects($this->any())
->method('getLabel')
->willReturn('Password');
$account = $this->getMock('Drupal\user\UserInterface');
$account = $this->createMock('Drupal\user\UserInterface');
$account->expects($this->once())
->method('isNew')
->willReturn(FALSE);
@ -258,7 +258,7 @@ class ProtectedUserFieldConstraintValidatorTest extends UnitTestCase {
$account->expects($this->once())
->method('checkExistingPassword')
->willReturn(FALSE);
$items = $this->getMock('Drupal\Core\Field\FieldItemListInterface');
$items = $this->createMock('Drupal\Core\Field\FieldItemListInterface');
$items->expects($this->once())
->method('getFieldDefinition')
->willReturn($field_definition);
@ -275,14 +275,14 @@ class ProtectedUserFieldConstraintValidatorTest extends UnitTestCase {
$cases[] = [$items, TRUE, 'Password'];
// Case 11: Non-password field changed, current password not confirmed.
$field_definition = $this->getMock('Drupal\Core\Field\FieldDefinitionInterface');
$field_definition = $this->createMock('Drupal\Core\Field\FieldDefinitionInterface');
$field_definition->expects($this->exactly(2))
->method('getName')
->willReturn('field_not_password');
$field_definition->expects($this->any())
->method('getLabel')
->willReturn('Protected field');
$account = $this->getMock('Drupal\user\UserInterface');
$account = $this->createMock('Drupal\user\UserInterface');
$account->expects($this->once())
->method('isNew')
->willReturn(FALSE);
@ -292,7 +292,7 @@ class ProtectedUserFieldConstraintValidatorTest extends UnitTestCase {
$account->expects($this->once())
->method('checkExistingPassword')
->willReturn(FALSE);
$items = $this->getMock('Drupal\Core\Field\FieldItemListInterface');
$items = $this->createMock('Drupal\Core\Field\FieldItemListInterface');
$items->expects($this->once())
->method('getFieldDefinition')
->willReturn($field_definition);

View File

@ -30,20 +30,20 @@ class UserBulkFormTest extends UnitTestCase {
$actions = [];
for ($i = 1; $i <= 2; $i++) {
$action = $this->getMock('\Drupal\system\ActionConfigEntityInterface');
$action = $this->createMock('\Drupal\system\ActionConfigEntityInterface');
$action->expects($this->any())
->method('getType')
->will($this->returnValue('user'));
$actions[$i] = $action;
}
$action = $this->getMock('\Drupal\system\ActionConfigEntityInterface');
$action = $this->createMock('\Drupal\system\ActionConfigEntityInterface');
$action->expects($this->any())
->method('getType')
->will($this->returnValue('node'));
$actions[] = $action;
$entity_storage = $this->getMock('Drupal\Core\Entity\EntityStorageInterface');
$entity_storage = $this->createMock('Drupal\Core\Entity\EntityStorageInterface');
$entity_storage->expects($this->any())
->method('loadMultiple')
->will($this->returnValue($actions));
@ -56,9 +56,9 @@ class UserBulkFormTest extends UnitTestCase {
$entity_repository = $this->createMock(EntityRepositoryInterface::class);
$language_manager = $this->getMock('Drupal\Core\Language\LanguageManagerInterface');
$language_manager = $this->createMock('Drupal\Core\Language\LanguageManagerInterface');
$messenger = $this->getMock('Drupal\Core\Messenger\MessengerInterface');
$messenger = $this->createMock('Drupal\Core\Messenger\MessengerInterface');
$views_data = $this->getMockBuilder('Drupal\views\ViewsData')
->disableOriginalConstructor()
@ -72,7 +72,7 @@ class UserBulkFormTest extends UnitTestCase {
$container->set('string_translation', $this->getStringTranslationStub());
\Drupal::setContainer($container);
$storage = $this->getMock('Drupal\views\ViewEntityInterface');
$storage = $this->createMock('Drupal\views\ViewEntityInterface');
$storage->expects($this->any())
->method('get')
->with('base_table')

View File

@ -72,9 +72,9 @@ class PrivateTempStoreTest extends UnitTestCase {
protected function setUp() {
parent::setUp();
$this->keyValue = $this->getMock('Drupal\Core\KeyValueStore\KeyValueStoreExpirableInterface');
$this->lock = $this->getMock('Drupal\Core\Lock\LockBackendInterface');
$this->currentUser = $this->getMock('Drupal\Core\Session\AccountProxyInterface');
$this->keyValue = $this->createMock('Drupal\Core\KeyValueStore\KeyValueStoreExpirableInterface');
$this->lock = $this->createMock('Drupal\Core\Lock\LockBackendInterface');
$this->currentUser = $this->createMock('Drupal\Core\Session\AccountProxyInterface');
$this->currentUser->expects($this->any())
->method('id')
->willReturn(1);

View File

@ -72,8 +72,8 @@ class SharedTempStoreTest extends UnitTestCase {
protected function setUp() {
parent::setUp();
$this->keyValue = $this->getMock('Drupal\Core\KeyValueStore\KeyValueStoreExpirableInterface');
$this->lock = $this->getMock('Drupal\Core\Lock\LockBackendInterface');
$this->keyValue = $this->createMock('Drupal\Core\KeyValueStore\KeyValueStoreExpirableInterface');
$this->lock = $this->createMock('Drupal\Core\Lock\LockBackendInterface');
$this->requestStack = new RequestStack();
$request = Request::createFromGlobals();
$this->requestStack->push($request);

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