Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
drupal
Commits
91fe1d2f
Unverified
Commit
91fe1d2f
authored
May 31, 2019
by
Alex Pott
Browse files
Issue
#2929133
by voleger, alexpott, Lendude: Replace all usages of getMock()
parent
2bb3bba5
Changes
266
Hide whitespace changes
Inline
Side-by-side
core/modules/aggregator/tests/src/Unit/Plugin/AggregatorPluginSettingsBaseTest.php
View file @
91fe1d2f
...
...
@@ -83,11 +83,10 @@ public function testSettingsForm() {
'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
)
...
...
core/modules/ban/tests/src/Unit/BanMiddlewareTest.php
View file @
91fe1d2f
...
...
@@ -41,8 +41,8 @@ class BanMiddlewareTest extends UnitTestCase {
protected
function
setUp
()
{
parent
::
setUp
();
$this
->
kernel
=
$this
->
get
Mock
(
'Symfony\Component\HttpKernel\HttpKernelInterface'
);
$this
->
banManager
=
$this
->
get
Mock
(
'Drupal\ban\BanIpManagerInterface'
);
$this
->
kernel
=
$this
->
create
Mock
(
'Symfony\Component\HttpKernel\HttpKernelInterface'
);
$this
->
banManager
=
$this
->
create
Mock
(
'Drupal\ban\BanIpManagerInterface'
);
$this
->
banMiddleware
=
new
BanMiddleware
(
$this
->
kernel
,
$this
->
banManager
);
}
...
...
core/modules/block/tests/src/Unit/BlockConfigEntityUnitTest.php
View file @
91fe1d2f
...
...
@@ -63,18 +63,18 @@ class BlockConfigEntityUnitTest extends UnitTestCase {
protected
function
setUp
()
{
$this
->
entityTypeId
=
$this
->
randomMachineName
();
$this
->
entityType
=
$this
->
get
Mock
(
'\Drupal\Core\Entity\EntityTypeInterface'
);
$this
->
entityType
=
$this
->
create
Mock
(
'\Drupal\Core\Entity\EntityTypeInterface'
);
$this
->
entityType
->
expects
(
$this
->
any
())
->
method
(
'getProvider'
)
->
will
(
$this
->
returnValue
(
'block'
));
$this
->
entityTypeManager
=
$this
->
get
Mock
(
EntityTypeManagerInterface
::
class
);
$this
->
entityTypeManager
=
$this
->
create
Mock
(
EntityTypeManagerInterface
::
class
);
$this
->
entityTypeManager
->
expects
(
$this
->
any
())
->
method
(
'getDefinition'
)
->
with
(
$this
->
entityTypeId
)
->
will
(
$this
->
returnValue
(
$this
->
entityType
));
$this
->
uuid
=
$this
->
get
Mock
(
'\Drupal\Component\Uuid\UuidInterface'
);
$this
->
uuid
=
$this
->
create
Mock
(
'\Drupal\Component\Uuid\UuidInterface'
);
$this
->
moduleHandler
=
$this
->
prophesize
(
ModuleHandlerInterface
::
class
);
$this
->
themeHandler
=
$this
->
prophesize
(
ThemeHandlerInterface
::
class
);
...
...
core/modules/block/tests/src/Unit/BlockFormTest.php
View file @
91fe1d2f
...
...
@@ -70,13 +70,13 @@ class BlockFormTest extends UnitTestCase {
protected
function
setUp
()
{
parent
::
setUp
();
$this
->
conditionManager
=
$this
->
get
Mock
(
'Drupal\Core\Executable\ExecutableManagerInterface'
);
$this
->
language
=
$this
->
get
Mock
(
'Drupal\Core\Language\LanguageManagerInterface'
);
$this
->
contextRepository
=
$this
->
get
Mock
(
'Drupal\Core\Plugin\Context\ContextRepositoryInterface'
);
$this
->
conditionManager
=
$this
->
create
Mock
(
'Drupal\Core\Executable\ExecutableManagerInterface'
);
$this
->
language
=
$this
->
create
Mock
(
'Drupal\Core\Language\LanguageManagerInterface'
);
$this
->
contextRepository
=
$this
->
create
Mock
(
'Drupal\Core\Plugin\Context\ContextRepositoryInterface'
);
$this
->
entityTypeManager
=
$this
->
get
Mock
(
'Drupal\Core\Entity\EntityTypeManagerInterface'
);
$this
->
storage
=
$this
->
get
Mock
(
'Drupal\Core\Config\Entity\ConfigEntityStorageInterface'
);
$this
->
themeHandler
=
$this
->
get
Mock
(
'Drupal\Core\Extension\ThemeHandlerInterface'
);
$this
->
entityTypeManager
=
$this
->
create
Mock
(
'Drupal\Core\Entity\EntityTypeManagerInterface'
);
$this
->
storage
=
$this
->
create
Mock
(
'Drupal\Core\Config\Entity\ConfigEntityStorageInterface'
);
$this
->
themeHandler
=
$this
->
create
Mock
(
'Drupal\Core\Extension\ThemeHandlerInterface'
);
$this
->
entityTypeManager
->
expects
(
$this
->
any
())
->
method
(
'getStorage'
)
->
will
(
$this
->
returnValue
(
$this
->
storage
));
...
...
@@ -123,7 +123,7 @@ public function testGetUniqueMachineName() {
$blocks
[
'other_test_1'
]
=
$this
->
getBlockMockWithMachineName
(
'other_test'
);
$blocks
[
'other_test_2'
]
=
$this
->
getBlockMockWithMachineName
(
'other_test'
);
$query
=
$this
->
get
Mock
(
'Drupal\Core\Entity\Query\QueryInterface'
);
$query
=
$this
->
create
Mock
(
'Drupal\Core\Entity\Query\QueryInterface'
);
$query
->
expects
(
$this
->
exactly
(
5
))
->
method
(
'condition'
)
->
will
(
$this
->
returnValue
(
$query
));
...
...
core/modules/block/tests/src/Unit/BlockRepositoryTest.php
View file @
91fe1d2f
...
...
@@ -60,13 +60,13 @@ protected function setUp() {
'bottom'
,
]);
$theme_manager
=
$this
->
get
Mock
(
'Drupal\Core\Theme\ThemeManagerInterface'
);
$theme_manager
=
$this
->
create
Mock
(
'Drupal\Core\Theme\ThemeManagerInterface'
);
$theme_manager
->
expects
(
$this
->
atLeastOnce
())
->
method
(
'getActiveTheme'
)
->
will
(
$this
->
returnValue
(
$active_theme
));
$this
->
contextHandler
=
$this
->
get
Mock
(
'Drupal\Core\Plugin\Context\ContextHandlerInterface'
);
$this
->
blockStorage
=
$this
->
get
Mock
(
'Drupal\Core\Entity\EntityStorageInterface'
);
$this
->
contextHandler
=
$this
->
create
Mock
(
'Drupal\Core\Plugin\Context\ContextHandlerInterface'
);
$this
->
blockStorage
=
$this
->
create
Mock
(
'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 @@ protected function setUp() {
public
function
testGetVisibleBlocksPerRegion
(
array
$blocks_config
,
array
$expected_blocks
)
{
$blocks
=
[];
foreach
(
$blocks_config
as
$block_id
=>
$block_config
)
{
$block
=
$this
->
get
Mock
(
'Drupal\block\BlockInterface'
);
$block
=
$this
->
create
Mock
(
'Drupal\block\BlockInterface'
);
$block
->
expects
(
$this
->
once
())
->
method
(
'access'
)
->
will
(
$this
->
returnValue
(
$block_config
[
0
]));
...
...
@@ -155,7 +155,7 @@ public function providerBlocksConfig() {
* @covers ::getVisibleBlocksPerRegion
*/
public
function
testGetVisibleBlocksPerRegionWithContext
()
{
$block
=
$this
->
get
Mock
(
'Drupal\block\BlockInterface'
);
$block
=
$this
->
create
Mock
(
'Drupal\block\BlockInterface'
);
$block
->
expects
(
$this
->
once
())
->
method
(
'access'
)
->
willReturn
(
AccessResult
::
allowed
()
->
addCacheTags
([
'config:block.block.block_id'
]));
...
...
core/modules/block/tests/src/Unit/CategoryAutocompleteTest.php
View file @
91fe1d2f
...
...
@@ -21,7 +21,7 @@ class CategoryAutocompleteTest extends UnitTestCase {
protected
$autocompleteController
;
protected
function
setUp
()
{
$block_manager
=
$this
->
get
Mock
(
'Drupal\Core\Block\BlockManagerInterface'
);
$block_manager
=
$this
->
create
Mock
(
'Drupal\Core\Block\BlockManagerInterface'
);
$block_manager
->
expects
(
$this
->
any
())
->
method
(
'getCategories'
)
->
will
(
$this
->
returnValue
([
'Comment'
,
'Node'
,
'None & Such'
,
'User'
]));
...
...
core/modules/block/tests/src/Unit/Menu/BlockLocalTasksTest.php
View file @
91fe1d2f
...
...
@@ -40,7 +40,7 @@ protected function setUp() {
'name'
=>
'test_c'
,
],
];
$theme_handler
=
$this
->
get
Mock
(
'Drupal\Core\Extension\ThemeHandlerInterface'
);
$theme_handler
=
$this
->
create
Mock
(
'Drupal\Core\Extension\ThemeHandlerInterface'
);
$theme_handler
->
expects
(
$this
->
any
())
->
method
(
'listInfo'
)
->
will
(
$this
->
returnValue
(
$themes
));
...
...
core/modules/block/tests/src/Unit/Plugin/DisplayVariant/BlockPageVariantTest.php
View file @
91fe1d2f
...
...
@@ -57,8 +57,8 @@ public function setUpDisplayVariant($configuration = [], $definition = []) {
->
willReturn
(
TRUE
);
\
Drupal
::
setContainer
(
$container
);
$this
->
blockRepository
=
$this
->
get
Mock
(
'Drupal\block\BlockRepositoryInterface'
);
$this
->
blockViewBuilder
=
$this
->
get
Mock
(
'Drupal\Core\Entity\EntityViewBuilderInterface'
);
$this
->
blockRepository
=
$this
->
create
Mock
(
'Drupal\block\BlockRepositoryInterface'
);
$this
->
blockViewBuilder
=
$this
->
create
Mock
(
'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 @@ public function testBuild(array $blocks_config, $visible_block_count, array $exp
$display_variant
->
setMainContent
([
'#markup'
=>
'Hello kittens!'
]);
$blocks
=
[
'top'
=>
[],
'center'
=>
[],
'bottom'
=>
[]];
$block_plugin
=
$this
->
get
Mock
(
'Drupal\Core\Block\BlockPluginInterface'
);
$main_content_block_plugin
=
$this
->
get
Mock
(
'Drupal\Core\Block\MainContentBlockPluginInterface'
);
$messages_block_plugin
=
$this
->
get
Mock
(
'Drupal\Core\Block\MessagesBlockPluginInterface'
);
$title_block_plugin
=
$this
->
get
Mock
(
'Drupal\Core\Block\TitleBlockPluginInterface'
);
$block_plugin
=
$this
->
create
Mock
(
'Drupal\Core\Block\BlockPluginInterface'
);
$main_content_block_plugin
=
$this
->
create
Mock
(
'Drupal\Core\Block\MainContentBlockPluginInterface'
);
$messages_block_plugin
=
$this
->
create
Mock
(
'Drupal\Core\Block\MessagesBlockPluginInterface'
);
$title_block_plugin
=
$this
->
create
Mock
(
'Drupal\Core\Block\TitleBlockPluginInterface'
);
foreach
(
$blocks_config
as
$block_id
=>
$block_config
)
{
$block
=
$this
->
get
Mock
(
'Drupal\block\BlockInterface'
);
$block
=
$this
->
create
Mock
(
'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
)));
...
...
core/modules/block_content/tests/src/Unit/Menu/BlockContentLocalTasksTest.php
View file @
91fe1d2f
...
...
@@ -39,7 +39,7 @@ protected function setUp() {
'name'
=>
'test_c'
,
],
];
$theme_handler
=
$this
->
get
Mock
(
'Drupal\Core\Extension\ThemeHandlerInterface'
);
$theme_handler
=
$this
->
create
Mock
(
'Drupal\Core\Extension\ThemeHandlerInterface'
);
$theme_handler
->
expects
(
$this
->
any
())
->
method
(
'listInfo'
)
->
will
(
$this
->
returnValue
(
$themes
));
...
...
core/modules/book/tests/src/Unit/BookManagerTest.php
View file @
91fe1d2f
...
...
@@ -61,8 +61,8 @@ protected function setUp() {
$this
->
entityTypeManager
=
$this
->
createMock
(
EntityTypeManagerInterface
::
class
);
$this
->
translation
=
$this
->
getStringTranslationStub
();
$this
->
configFactory
=
$this
->
getConfigFactoryStub
([]);
$this
->
bookOutlineStorage
=
$this
->
get
Mock
(
'Drupal\book\BookOutlineStorageInterface'
);
$this
->
renderer
=
$this
->
get
Mock
(
'\Drupal\Core\Render\RendererInterface'
);
$this
->
bookOutlineStorage
=
$this
->
create
Mock
(
'Drupal\book\BookOutlineStorageInterface'
);
$this
->
renderer
=
$this
->
create
Mock
(
'\Drupal\Core\Render\RendererInterface'
);
$this
->
bookManager
=
new
BookManager
(
$this
->
entityTypeManager
,
$this
->
translation
,
$this
->
configFactory
,
$this
->
bookOutlineStorage
,
$this
->
renderer
);
}
...
...
core/modules/breakpoint/tests/src/Unit/BreakpointTest.php
View file @
91fe1d2f
...
...
@@ -45,7 +45,7 @@ class BreakpointTest extends UnitTestCase {
protected
function
setUp
()
{
parent
::
setUp
();
$this
->
stringTranslation
=
$this
->
get
Mock
(
'Drupal\Core\StringTranslation\TranslationInterface'
);
$this
->
stringTranslation
=
$this
->
create
Mock
(
'Drupal\Core\StringTranslation\TranslationInterface'
);
}
/**
...
...
core/modules/comment/tests/src/Unit/CommentLinkBuilderTest.php
View file @
91fe1d2f
...
...
@@ -69,11 +69,11 @@ class CommentLinkBuilderTest extends UnitTestCase {
* Prepares mocks for the test.
*/
protected
function
setUp
()
{
$this
->
commentManager
=
$this
->
get
Mock
(
'\Drupal\comment\CommentManagerInterface'
);
$this
->
commentManager
=
$this
->
create
Mock
(
'\Drupal\comment\CommentManagerInterface'
);
$this
->
stringTranslation
=
$this
->
getStringTranslationStub
();
$this
->
entityTypeManager
=
$this
->
createMock
(
EntityTypeManagerInterface
::
class
);
$this
->
moduleHandler
=
$this
->
get
Mock
(
'\Drupal\Core\Extension\ModuleHandlerInterface'
);
$this
->
currentUser
=
$this
->
get
Mock
(
'\Drupal\Core\Session\AccountProxyInterface'
);
$this
->
moduleHandler
=
$this
->
create
Mock
(
'\Drupal\Core\Extension\ModuleHandlerInterface'
);
$this
->
currentUser
=
$this
->
create
Mock
(
'\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 @@ public function getLinkCombinations() {
* Mock node for testing.
*/
protected
function
getMockNode
(
$has_field
,
$comment_status
,
$form_location
,
$comment_count
)
{
$node
=
$this
->
get
Mock
(
'\Drupal\node\NodeInterface'
);
$node
=
$this
->
create
Mock
(
'\Drupal\node\NodeInterface'
);
$node
->
expects
(
$this
->
any
())
->
method
(
'hasField'
)
->
willReturn
(
$has_field
);
...
...
@@ -287,7 +287,7 @@ protected function getMockNode($has_field, $comment_status, $form_location, $com
->
with
(
'comment'
)
->
willReturn
(
$field_item
);
$field_definition
=
$this
->
get
Mock
(
'\Drupal\Core\Field\FieldDefinitionInterface'
);
$field_definition
=
$this
->
create
Mock
(
'\Drupal\Core\Field\FieldDefinitionInterface'
);
$field_definition
->
expects
(
$this
->
any
())
->
method
(
'getSetting'
)
->
with
(
'form_location'
)
...
...
core/modules/comment/tests/src/Unit/CommentManagerTest.php
View file @
91fe1d2f
...
...
@@ -23,7 +23,7 @@ class CommentManagerTest extends UnitTestCase {
*/
public
function
testGetFields
()
{
// Set up a content entity type.
$entity_type
=
$this
->
get
Mock
(
'Drupal\Core\Entity\ContentEntityTypeInterface'
);
$entity_type
=
$this
->
create
Mock
(
'Drupal\Core\Entity\ContentEntityTypeInterface'
);
$entity_type
->
expects
(
$this
->
any
())
->
method
(
'getClass'
)
->
will
(
$this
->
returnValue
(
'Node'
));
...
...
@@ -51,9 +51,9 @@ public function testGetFields() {
$comment_manager
=
new
CommentManager
(
$entity_type_manager
,
$this
->
get
Mock
(
'Drupal\Core\Config\ConfigFactoryInterface'
),
$this
->
get
Mock
(
'Drupal\Core\StringTranslation\TranslationInterface'
),
$this
->
get
Mock
(
'Drupal\Core\Extension\ModuleHandlerInterface'
),
$this
->
create
Mock
(
'Drupal\Core\Config\ConfigFactoryInterface'
),
$this
->
create
Mock
(
'Drupal\Core\StringTranslation\TranslationInterface'
),
$this
->
create
Mock
(
'Drupal\Core\Extension\ModuleHandlerInterface'
),
$this
->
createMock
(
AccountInterface
::
class
),
$entity_field_manager
,
$this
->
prophesize
(
EntityDisplayRepositoryInterface
::
class
)
->
reveal
()
...
...
core/modules/comment/tests/src/Unit/CommentStatisticsUnitTest.php
View file @
91fe1d2f
...
...
@@ -83,7 +83,7 @@ protected function setUp() {
->
method
(
'select'
)
->
will
(
$this
->
returnValue
(
$this
->
select
));
$this
->
commentStatistics
=
new
CommentStatistics
(
$this
->
database
,
$this
->
get
Mock
(
'Drupal\Core\Session\AccountInterface'
),
$this
->
createMock
(
EntityTypeManagerInterface
::
class
),
$this
->
get
Mock
(
'Drupal\Core\State\StateInterface'
),
$this
->
database
);
$this
->
commentStatistics
=
new
CommentStatistics
(
$this
->
database
,
$this
->
create
Mock
(
'Drupal\Core\Session\AccountInterface'
),
$this
->
createMock
(
EntityTypeManagerInterface
::
class
),
$this
->
create
Mock
(
'Drupal\Core\State\StateInterface'
),
$this
->
database
);
}
/**
...
...
core/modules/comment/tests/src/Unit/Entity/CommentLockTest.php
View file @
91fe1d2f
...
...
@@ -19,15 +19,15 @@ class CommentLockTest extends UnitTestCase {
*/
public
function
testLocks
()
{
$container
=
new
ContainerBuilder
();
$container
->
set
(
'module_handler'
,
$this
->
get
Mock
(
'Drupal\Core\Extension\ModuleHandlerInterface'
));
$container
->
set
(
'current_user'
,
$this
->
get
Mock
(
'Drupal\Core\Session\AccountInterface'
));
$container
->
set
(
'cache.test'
,
$this
->
get
Mock
(
'Drupal\Core\Cache\CacheBackendInterface'
));
$container
->
set
(
'comment.statistics'
,
$this
->
get
Mock
(
'Drupal\comment\CommentStatisticsInterface'
));
$container
->
set
(
'module_handler'
,
$this
->
create
Mock
(
'Drupal\Core\Extension\ModuleHandlerInterface'
));
$container
->
set
(
'current_user'
,
$this
->
create
Mock
(
'Drupal\Core\Session\AccountInterface'
));
$container
->
set
(
'cache.test'
,
$this
->
create
Mock
(
'Drupal\Core\Cache\CacheBackendInterface'
));
$container
->
set
(
'comment.statistics'
,
$this
->
create
Mock
(
'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
->
get
Mock
(
'Drupal\Core\Lock\LockBackendInterface'
);
$lock
=
$this
->
create
Mock
(
'Drupal\Core\Lock\LockBackendInterface'
);
$cid
=
2
;
$lock_name
=
"comment:
$cid
:.00/"
;
$lock
->
expects
(
$this
->
at
(
0
))
...
...
@@ -41,7 +41,7 @@ public function testLocks() {
->
method
(
$this
->
anything
());
$container
->
set
(
'lock'
,
$lock
);
$cache_tag_invalidator
=
$this
->
get
Mock
(
'Drupal\Core\Cache\CacheTagsInvalidator'
);
$cache_tag_invalidator
=
$this
->
create
Mock
(
'Drupal\Core\Cache\CacheTagsInvalidator'
);
$container
->
set
(
'cache_tags.invalidator'
,
$cache_tag_invalidator
);
\
Drupal
::
setContainer
(
$container
);
...
...
@@ -69,7 +69,7 @@ public function testLocks() {
->
method
(
'getThread'
)
->
will
(
$this
->
returnValue
(
''
));
$anon_user
=
$this
->
get
Mock
(
'Drupal\Core\Session\AccountInterface'
);
$anon_user
=
$this
->
create
Mock
(
'Drupal\Core\Session\AccountInterface'
);
$anon_user
->
expects
(
$this
->
any
())
->
method
(
'isAnonymous'
)
->
will
(
$this
->
returnValue
(
TRUE
));
...
...
@@ -77,7 +77,7 @@ public function testLocks() {
->
method
(
'getOwner'
)
->
will
(
$this
->
returnValue
(
$anon_user
));
$parent_entity
=
$this
->
get
Mock
(
'\Drupal\Core\Entity\ContentEntityInterface'
);
$parent_entity
=
$this
->
create
Mock
(
'\Drupal\Core\Entity\ContentEntityInterface'
);
$parent_entity
->
expects
(
$this
->
atLeastOnce
())
->
method
(
'getCacheTagsToInvalidate'
)
->
willReturn
([
'node:1'
]);
...
...
@@ -85,11 +85,11 @@ public function testLocks() {
->
method
(
'getCommentedEntity'
)
->
willReturn
(
$parent_entity
);
$entity_type
=
$this
->
get
Mock
(
'\Drupal\Core\Entity\EntityTypeInterface'
);
$entity_type
=
$this
->
create
Mock
(
'\Drupal\Core\Entity\EntityTypeInterface'
);
$comment
->
expects
(
$this
->
any
())
->
method
(
'getEntityType'
)
->
will
(
$this
->
returnValue
(
$entity_type
));
$storage
=
$this
->
get
Mock
(
'Drupal\comment\CommentStorageInterface'
);
$storage
=
$this
->
create
Mock
(
'Drupal\comment\CommentStorageInterface'
);
// preSave() should acquire the lock. (This is what's really being tested.)
$comment
->
preSave
(
$storage
);
...
...
core/modules/comment/tests/src/Unit/Plugin/views/field/CommentBulkFormTest.php
View file @
91fe1d2f
...
...
@@ -30,20 +30,20 @@ public function testConstructor() {
$actions
=
[];
for
(
$i
=
1
;
$i
<=
2
;
$i
++
)
{
$action
=
$this
->
get
Mock
(
'\Drupal\system\ActionConfigEntityInterface'
);
$action
=
$this
->
create
Mock
(
'\Drupal\system\ActionConfigEntityInterface'
);
$action
->
expects
(
$this
->
any
())
->
method
(
'getType'
)
->
will
(
$this
->
returnValue
(
'comment'
));
$actions
[
$i
]
=
$action
;
}
$action
=
$this
->
get
Mock
(
'\Drupal\system\ActionConfigEntityInterface'
);
$action
=
$this
->
create
Mock
(
'\Drupal\system\ActionConfigEntityInterface'
);
$action
->
expects
(
$this
->
any
())
->
method
(
'getType'
)
->
will
(
$this
->
returnValue
(
'user'
));
$actions
[]
=
$action
;
$entity_storage
=
$this
->
get
Mock
(
'Drupal\Core\Entity\EntityStorageInterface'
);
$entity_storage
=
$this
->
create
Mock
(
'Drupal\Core\Entity\EntityStorageInterface'
);
$entity_storage
->
expects
(
$this
->
any
())
->
method
(
'loadMultiple'
)
->
will
(
$this
->
returnValue
(
$actions
));
...
...
@@ -56,9 +56,9 @@ public function testConstructor() {
$entity_repository
=
$this
->
createMock
(
EntityRepositoryInterface
::
class
);
$language_manager
=
$this
->
get
Mock
(
'Drupal\Core\Language\LanguageManagerInterface'
);
$language_manager
=
$this
->
create
Mock
(
'Drupal\Core\Language\LanguageManagerInterface'
);
$messenger
=
$this
->
get
Mock
(
'Drupal\Core\Messenger\MessengerInterface'
);
$messenger
=
$this
->
create
Mock
(
'Drupal\Core\Messenger\MessengerInterface'
);
$views_data
=
$this
->
getMockBuilder
(
'Drupal\views\ViewsData'
)
->
disableOriginalConstructor
()
...
...
@@ -72,7 +72,7 @@ public function testConstructor() {
$container
->
set
(
'string_translation'
,
$this
->
getStringTranslationStub
());
\
Drupal
::
setContainer
(
$container
);
$storage
=
$this
->
get
Mock
(
'Drupal\views\ViewEntityInterface'
);
$storage
=
$this
->
create
Mock
(
'Drupal\views\ViewEntityInterface'
);
$storage
->
expects
(
$this
->
any
())
->
method
(
'get'
)
->
with
(
'base_table'
)
...
...
core/modules/config_translation/tests/src/Unit/ConfigEntityMapperTest.php
View file @
91fe1d2f
...
...
@@ -57,11 +57,11 @@ class ConfigEntityMapperTest extends UnitTestCase {
protected
$eventDispatcher
;
protected
function
setUp
()
{
$this
->
entityTypeManager
=
$this
->
get
Mock
(
'Drupal\Core\Entity\EntityTypeManagerInterface'
);
$this
->
entityTypeManager
=
$this
->
create
Mock
(
'Drupal\Core\Entity\EntityTypeManagerInterface'
);
$this
->
entity
=
$this
->
get
Mock
(
'Drupal\Core\Config\Entity\ConfigEntityInterface'
);
$this
->
entity
=
$this
->
create
Mock
(
'Drupal\Core\Config\Entity\ConfigEntityInterface'
);
$this
->
routeProvider
=
$this
->
get
Mock
(
'Drupal\Core\Routing\RouteProviderInterface'
);
$this
->
routeProvider
=
$this
->
create
Mock
(
'Drupal\Core\Routing\RouteProviderInterface'
);
$this
->
routeProvider
->
expects
(
$this
->
any
())
...
...
@@ -78,15 +78,15 @@ protected function setUp() {
'route_name'
=>
'config_translation.item.overview.entity.configurable_language.edit_form'
,
];
$typed_config_manager
=
$this
->
get
Mock
(
'Drupal\Core\Config\TypedConfigManagerInterface'
);
$typed_config_manager
=
$this
->
create
Mock
(
'Drupal\Core\Config\TypedConfigManagerInterface'
);
$locale_config_manager
=
$this
->
getMockBuilder
(
'Drupal\locale\LocaleConfigManager'
)
->
disableOriginalConstructor
()
->
getMock
();
$this
->
languageManager
=
$this
->
get
Mock
(
'Drupal\Core\Language\LanguageManagerInterface'
);
$this
->
languageManager
=
$this
->
create
Mock
(
'Drupal\Core\Language\LanguageManagerInterface'
);
$this
->
eventDispatcher
=
$this
->
get
Mock
(
'Symfony\Component\EventDispatcher\EventDispatcherInterface'
);
$this
->
eventDispatcher
=
$this
->
create
Mock
(
'Symfony\Component\EventDispatcher\EventDispatcherInterface'
);
$this
->
configEntityMapper
=
new
ConfigEntityMapper
(
'configurable_language'
,
...
...
@@ -94,7 +94,7 @@ protected function setUp() {
$this
->
getConfigFactoryStub
(),
$typed_config_manager
,
$locale_config_manager
,
$this
->
get
Mock
(
'Drupal\config_translation\ConfigMapperManagerInterface'
),
$this
->
create
Mock
(
'Drupal\config_translation\ConfigMapperManagerInterface'
),
$this
->
routeProvider
,
$this
->
getStringTranslationStub
(),
$this
->
entityTypeManager
,
...
...
@@ -113,7 +113,7 @@ public function testEntityGetterAndSetter() {
->
with
()
->
will
(
$this
->
returnValue
(
'entity_id'
));
$entity_type
=
$this
->
get
Mock
(
'Drupal\Core\Config\Entity\ConfigEntityTypeInterface'
);
$entity_type
=
$this
->
create
Mock
(
'Drupal\Core\Config\Entity\ConfigEntityTypeInterface'
);
$entity_type
->
expects
(
$this
->
any
())
->
method
(
'getConfigPrefix'
)
...
...
@@ -146,7 +146,7 @@ public function testEntityGetterAndSetter() {
* Tests ConfigEntityMapper::getOverviewRouteParameters().
*/
public
function
testGetOverviewRouteParameters
()
{
$entity_type
=
$this
->
get
Mock
(
'Drupal\Core\Config\Entity\ConfigEntityTypeInterface'
);
$entity_type
=
$this
->
create
Mock
(
'Drupal\Core\Config\Entity\ConfigEntityTypeInterface'
);
$this
->
entityTypeManager
->
expects
(
$this
->
once
())
->
method
(
'getDefinition'
)
...
...
@@ -177,7 +177,7 @@ public function testGetType() {
* Tests ConfigEntityMapper::getTypeName().
*/
public
function
testGetTypeName
()
{
$entity_type
=
$this
->
get
Mock
(
'Drupal\Core\Config\Entity\ConfigEntityTypeInterface'
);
$entity_type
=
$this
->
create
Mock
(
'Drupal\Core\Config\Entity\ConfigEntityTypeInterface'
);
$entity_type
->
expects
(
$this
->
once
())
->
method
(
'getLabel'
)
->
will
(
$this
->
returnValue
(
'test'
));
...
...
@@ -195,7 +195,7 @@ public function testGetTypeName() {
* Tests ConfigEntityMapper::getTypeLabel().
*/
public
function
testGetTypeLabel
()
{
$entity_type
=
$this
->
get
Mock
(
'Drupal\Core\Config\Entity\ConfigEntityTypeInterface'
);
$entity_type
=
$this
->
create
Mock
(
'Drupal\Core\Config\Entity\ConfigEntityTypeInterface'
);
$entity_type
->
expects
(
$this
->
once
())
->
method
(
'getLabel'
)
->
will
(
$this
->
returnValue
(
'test'
));
...
...
core/modules/config_translation/tests/src/Unit/ConfigFieldMapperTest.php
View file @
91fe1d2f
...
...
@@ -46,8 +46,8 @@ class ConfigFieldMapperTest extends UnitTestCase {
* {@inheritdoc}
*/
protected
function
setUp
()
{
$this
->
entityTypeManager
=
$this
->
get
Mock
(
'Drupal\Core\Entity\EntityTypeManagerInterface'
);
$this
->
entity
=
$this
->
get
Mock
(
'Drupal\field\FieldConfigInterface'
);
$this
->
entityTypeManager
=
$this
->
create
Mock
(
'Drupal\Core\Entity\EntityTypeManagerInterface'
);
$this
->
entity
=
$this
->
create
Mock
(
'Drupal\field\FieldConfigInterface'
);
$definition
=
[
'class'
=>
'\Drupal\config_translation\ConfigFieldMapper'
,
...
...
@@ -61,19 +61,19 @@ protected function setUp() {
->
disableOriginalConstructor
()
->
getMock
();
$this
->
eventDispatcher
=
$this
->
get
Mock
(
'Symfony\Component\EventDispatcher\EventDispatcherInterface'
);
$this
->
eventDispatcher
=
$this
->
create
Mock
(
'Symfony\Component\EventDispatcher\EventDispatcherInterface'
);
$this
->
configFieldMapper
=
new
ConfigFieldMapper
(
'node_fields'
,
$definition
,
$this
->
getConfigFactoryStub
(),
$this
->
get
Mock
(
'Drupal\Core\Config\TypedConfigManagerInterface'
),
$this
->
create
Mock
(
'Drupal\Core\Config\TypedConfigManagerInterface'
),
$locale_config_manager
,
$this
->
get
Mock
(
'Drupal\config_translation\ConfigMapperManagerInterface'
),
$this
->
get
Mock
(
'Drupal\Core\Routing\RouteProviderInterface'
),
$this
->
create
Mock
(
'Drupal\config_translation\ConfigMapperManagerInterface'
),
$this
->
create
Mock
(
'Drupal\Core\Routing\RouteProviderInterface'
),
$this
->
getStringTranslationStub
(),
$this
->
entityTypeManager
,
$this
->
get
Mock
(
'Drupal\Core\Language\LanguageManagerInterface'
),
$this
->
create
Mock
(
'Drupal\Core\Language\LanguageManagerInterface'
),
$this
->
eventDispatcher
);
}
...
...
@@ -84,7 +84,7 @@ protected function setUp() {
* @covers ::setEntity
*/
public
function
testSetEntity
()
{
$entity_type
=
$this
->
get
Mock
(
'Drupal\Core\Config\Entity\ConfigEntityTypeInterface'
);
$entity_type
=
$this
->
create
Mock
(
'Drupal\Core\Config\Entity\ConfigEntityTypeInterface'
);
$entity_type
->
expects
(
$this
->
any
())
->
method
(
'getConfigPrefix'
)
...
...
@@ -95,7 +95,7 @@ public function testSetEntity() {
->
method
(
'getDefinition'
)
->
will
(
$this
->
returnValue
(
$entity_type
));
$field_storage
=
$this
->
get
Mock
(
'Drupal\field\FieldStorageConfigInterface'
);
$field_storage
=
$this
->
create
Mock
(
'Drupal\field\FieldStorageConfigInterface'
);
$field_storage
->
expects
(
$this
->
any
())
->
method
(
'id'
)
...
...
core/modules/config_translation/tests/src/Unit/ConfigMapperManagerTest.php
View file @
91fe1d2f
...
...
@@ -32,7 +32,7 @@ class ConfigMapperManagerTest extends UnitTestCase {
protected
function
setUp
()
{
$language
=
new
Language
([
'id'
=>
'en'
]);
$language_manager
=
$this
->
get
Mock
(
'Drupal\Core\Language\LanguageManagerInterface'
);
$language_manager
=
$this
->
create
Mock
(
'Drupal\Core\Language\LanguageManagerInterface'
);
$language_manager
->
expects
(
$this
->
once
())
->
method
(
'getCurrentLanguage'
)
->
with
(
LanguageInterface
::
TYPE_INTERFACE
)
...
...
@@ -41,11 +41,11 @@ protected function setUp() {
$this
->
typedConfigManager
=
$this
->
getMockBuilder
(
'Drupal\Core\Config\TypedConfigManagerInterface'
)
->
getMock
();
$module_handler
=
$this
->
get
Mock
(
'Drupal\Core\Extension\ModuleHandlerInterface'
);
$theme_handler
=
$this
->
get
Mock
(
'Drupal\Core\Extension\ThemeHandlerInterface'
);
$module_handler
=
$this
->
create
Mock
(
'Drupal\Core\Extension\ModuleHandlerInterface'
);
$theme_handler
=
$this
->
create
Mock
(
'Drupal\Core\Extension\ThemeHandlerInterface'
);
$this
->
configMapperManager
=
new
ConfigMapperManager
(
$this
->
get
Mock
(
'Drupal\Core\Cache\CacheBackendInterface'
),
$this
->
create
Mock
(
'Drupal\Core\Cache\CacheBackendInterface'
),
$language_manager
,
$module_handler
,
$this
->
typedConfigManager
,
...
...
@@ -148,7 +148,7 @@ public function providerTestHasTranslatable() {
*/
protected
function
getElement
(
array
$definition
)
{
$data_definition
=
new
DataDefinition
(
$definition
);
$element
=
$this
->
get
Mock
(
'Drupal\Core\TypedData\TypedDataInterface'
);
$element
=
$this
->
create
Mock
(
'Drupal\Core\TypedData\TypedDataInterface'
);
$element
->
expects
(
$this
->
any
())
->
method
(
'getDataDefinition'
)
->
will
(
$this
->
returnValue
(
$data_definition
));
...
...
core/modules/config_translation/tests/src/Unit/ConfigNamesMapperTest.php
View file @
91fe1d2f
...
...
@@ -96,7 +96,7 @@ class ConfigNamesMapperTest extends UnitTestCase {
protected
$eventDispatcher
;
protected
function
setUp
()
{
$this
->
routeProvider
=
$this
->
get
Mock
(
'Drupal\Core\Routing\RouteProviderInterface'
);
$this
->
routeProvider
=
$this
->
create
Mock
(
'Drupal\Core\Routing\RouteProviderInterface'
);
$this
->
pluginDefinition
=
[
'class'
=>
'\Drupal\config_translation\ConfigNamesMapper'
,
...
...
@@ -106,15 +106,15 @@ protected function setUp() {
'weight'
=>
42
,
];
$this
->
typedConfigManager
=
$this
->
get
Mock
(
'Drupal\Core\Config\TypedConfigManagerInterface'
);
$this
->
typedConfigManager
=
$this
->
create
Mock
(
'Drupal\Core\Config\TypedConfigManagerInterface'
);
$this
->
localeConfigManager
=
$this
->
getMockBuilder
(
'Drupal\locale\LocaleConfigManager'
)
->
disableOriginalConstructor
()
->
getMock
();
$this
->
configMapperManager
=
$this
->
get
Mock
(
'Drupal\config_translation\ConfigMapperManagerInterface'
);
$this
->
configMapperManager
=
$this
->
create
Mock
(
'Drupal\config_translation\ConfigMapperManagerInterface'
);
$this
->
urlGenerator
=
$this
->
get
Mock
(
'Drupal\Core\Routing\UrlGeneratorInterface'
);
$this
->
urlGenerator
=
$this
->
create
Mock
(
'Drupal\Core\Routing\UrlGeneratorInterface'
);
$container
=
new
ContainerBuilder
();
$container
->
set
(
'url_generator'
,
$this
->
urlGenerator
);
\
Drupal
::
setContainer
(
$container
);
...
...
@@ -127,9 +127,9 @@ protected function setUp() {
->
with
(
'system.site_information_settings'
)
->
will
(
$this
->
returnValue
(
$this
->
baseRoute
));
$this
->
languageManager
=
$this
->
get
Mock
(
'Drupal\Core\Language\LanguageManagerInterface'
);
$this
->
languageManager
=
$this
->
create
Mock
(
'Drupal\Core\Language\LanguageManagerInterface'
);
$this
->
eventDispatcher
=
$this
->
get
Mock
(
'Symfony\Component\EventDispatcher\EventDispatcherInterface'
);