public function ControllerBaseTest::testGetConfig in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/tests/Drupal/Tests/Core/Controller/ControllerBaseTest.php \Drupal\Tests\Core\Controller\ControllerBaseTest::testGetConfig()
Tests the config method.
File
- core/
tests/ Drupal/ Tests/ Core/ Controller/ ControllerBaseTest.php, line 33 - Contains \Drupal\Tests\Core\Controller\ControllerBaseTest.
Class
- ControllerBaseTest
- Tests that the base controller class.
Namespace
Drupal\Tests\Core\ControllerCode
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'));
}