public function TwigExtensionTest::testActiveTheme in Drupal 8
Same name and namespace in other branches
- 9 core/tests/Drupal/Tests/Core/Template/TwigExtensionTest.php \Drupal\Tests\Core\Template\TwigExtensionTest::testActiveTheme()
- 10 core/tests/Drupal/Tests/Core/Template/TwigExtensionTest.php \Drupal\Tests\Core\Template\TwigExtensionTest::testActiveTheme()
Tests the active_theme function.
File
- core/
tests/ Drupal/ Tests/ Core/ Template/ TwigExtensionTest.php, line 129
Class
- TwigExtensionTest
- Tests the twig extension.
Namespace
Drupal\Tests\Core\TemplateCode
public function testActiveTheme() {
$active_theme = $this
->getMockBuilder('\\Drupal\\Core\\Theme\\ActiveTheme')
->disableOriginalConstructor()
->getMock();
$active_theme
->expects($this
->once())
->method('getName')
->willReturn('test_theme');
$this->themeManager
->expects($this
->once())
->method('getActiveTheme')
->willReturn($active_theme);
$loader = new StringLoader();
$twig = new \Twig_Environment($loader);
$twig
->addExtension($this->systemUnderTest);
$result = $twig
->render('{{ active_theme() }}');
$this
->assertEquals('test_theme', $result);
}