Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
D
drupal
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Custom Issue Tracker
Custom Issue Tracker
Labels
Merge Requests
220
Merge Requests
220
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
project
drupal
Commits
a40399f2
Commit
a40399f2
authored
Sep 15, 2013
by
alexpott
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue
#2089195
by dawehner: Fixed ControllerBase::config does not work as expected.
parent
9be3ce88
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
69 additions
and
2 deletions
+69
-2
core/lib/Drupal/Core/Controller/ControllerBase.php
core/lib/Drupal/Core/Controller/ControllerBase.php
+2
-2
core/tests/Drupal/Tests/Core/Controller/ControllerBaseTest.php
...tests/Drupal/Tests/Core/Controller/ControllerBaseTest.php
+67
-0
No files found.
core/lib/Drupal/Core/Controller/ControllerBase.php
View file @
a40399f2
...
...
@@ -138,9 +138,9 @@ protected function cache($bin = 'cache') {
*/
protected
function
config
(
$name
)
{
if
(
!
$this
->
configFactory
)
{
$this
->
configFactory
=
$this
->
container
()
->
get
(
'config.factory'
)
->
get
(
$name
)
;
$this
->
configFactory
=
$this
->
container
()
->
get
(
'config.factory'
);
}
return
$this
->
configFactory
;
return
$this
->
configFactory
->
get
(
$name
)
;
}
/**
...
...
core/tests/Drupal/Tests/Core/Controller/ControllerBaseTest.php
0 → 100644
View file @
a40399f2
<?php
/**
* @file
* Contains \Drupal\Tests\Core\Controller\ControllerBaseTest.
*/
namespace
Drupal\Tests\Core\Controller
;
use
Drupal\Tests\UnitTestCase
;
/**
* Tests that the base controller class.
*/
class
ControllerBaseTest
extends
UnitTestCase
{
/**
* The tested controller base class.
*
* @var \Drupal\Core\Controller\ControllerBase|\PHPUnit_Framework_MockObject_MockObject
*/
protected
$controllerBase
;
public
static
function
getInfo
()
{
return
array
(
'name'
=>
'Controller Base tests'
,
'description'
=>
'Tests that the base controller class.'
,
'group'
=>
'Routing'
,
);
}
protected
function
setUp
()
{
$this
->
controllerBase
=
$this
->
getMockForAbstractClass
(
'Drupal\Core\Controller\ControllerBase'
);
}
/**
* Tests the config method.
*/
public
function
testGetConfig
()
{
$config_factory
=
$this
->
getConfigFactoryStub
(
array
(
'config_name'
=>
array
(
'key'
=>
'value'
,
),
'config_name2'
=>
array
(
'key2'
=>
'value2'
,
),
));
$container
=
$this
->
getMock
(
'Symfony\Component\DependencyInjection\ContainerInterface'
);
$container
->
expects
(
$this
->
once
())
->
method
(
'get'
)
->
with
(
'config.factory'
)
->
will
(
$this
->
returnValue
(
$config_factory
));
\
Drupal
::
setContainer
(
$container
);
$config_method
=
new
\
ReflectionMethod
(
'Drupal\Core\Controller\ControllerBase'
,
'config'
);
$config_method
->
setAccessible
(
TRUE
);
// Call config twice to ensure that the container is just called once.
$config
=
$config_method
->
invoke
(
$this
->
controllerBase
,
'config_name'
);
$this
->
assertEquals
(
'value'
,
$config
->
get
(
'key'
));
$config
=
$config_method
->
invoke
(
$this
->
controllerBase
,
'config_name2'
);
$this
->
assertEquals
(
'value2'
,
$config
->
get
(
'key2'
));
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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