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