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
c1bc9101
Commit
c1bc9101
authored
Nov 27, 2014
by
Alex Pott
Browse files
Issue
#2355543
by ebeyrent, lhangea: TokenTest Language mock is not accurate
parent
82584e69
Changes
1
Hide whitespace changes
Inline
Side-by-side
core/tests/Drupal/Tests/Core/Utility/TokenTest.php
View file @
c1bc9101
...
...
@@ -38,6 +38,13 @@ class TokenTest extends UnitTestCase {
*/
protected
$moduleHandler
;
/**
* The language interface used for testing.
*
* @var \Drupal\Core\Language\LanguageInterface|\PHPUnit_Framework_MockObject_MockObject
*/
protected
$language
;
/**
* The token service under test.
*
...
...
@@ -55,6 +62,8 @@ protected function setUp() {
$this
->
moduleHandler
=
$this
->
getMock
(
'\Drupal\Core\Extension\ModuleHandlerInterface'
);
$this
->
language
=
$this
->
getMock
(
'\Drupal\Core\Language\LanguageInterface'
);
$this
->
token
=
new
Token
(
$this
->
moduleHandler
,
$this
->
cache
,
$this
->
languageManager
);
}
...
...
@@ -70,15 +79,14 @@ public function testGetInfo() {
),
);
$values
=
array
(
'id'
=>
$this
->
randomMachineName
());
$language
=
$this
->
getMockBuilder
(
'\Drupal\Core\Language\Language'
)
->
setConstructorArgs
(
array
(
$values
))
->
getMock
();
$this
->
language
->
expects
(
$this
->
atLeastOnce
())
->
method
(
'getId'
)
->
will
(
$this
->
returnValue
(
$this
->
randomMachineName
()));
$this
->
languageManager
->
expects
(
$this
->
once
())
->
method
(
'getCurrentLanguage'
)
->
with
(
LanguageInterface
::
TYPE_CONTENT
)
->
will
(
$this
->
returnValue
(
$language
));
->
will
(
$this
->
returnValue
(
$
this
->
language
));
// The persistent cache must only be hit once, after which the info is
// cached statically.
...
...
@@ -86,7 +94,7 @@ public function testGetInfo() {
->
method
(
'get'
);
$this
->
cache
->
expects
(
$this
->
once
())
->
method
(
'set'
)
->
with
(
'token_info:'
.
$language
->
getId
(),
$token_info
);
->
with
(
'token_info:'
.
$
this
->
language
->
getId
(),
$token_info
);
$this
->
moduleHandler
->
expects
(
$this
->
once
())
->
method
(
'invokeAll'
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment