You are here

public function TwigExtensionTest::testActiveThemePath in Drupal 10

Same name and namespace in other branches
  1. 8 core/tests/Drupal/Tests/Core/Template/TwigExtensionTest.php \Drupal\Tests\Core\Template\TwigExtensionTest::testActiveThemePath()
  2. 9 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\Template

Code

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);
}