You are here

public function TwigLoaderTest::testTwigLoaderAddition in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/system/tests/src/Functional/Theme/TwigLoaderTest.php \Drupal\Tests\system\Functional\Theme\TwigLoaderTest::testTwigLoaderAddition()
  2. 9 core/modules/system/tests/src/Functional/Theme/TwigLoaderTest.php \Drupal\Tests\system\Functional\Theme\TwigLoaderTest::testTwigLoaderAddition()

Tests adding an additional twig loader to the loader chain.

File

core/modules/system/tests/src/Functional/Theme/TwigLoaderTest.php, line 29

Class

TwigLoaderTest
Tests adding Twig loaders.

Namespace

Drupal\Tests\system\Functional\Theme

Code

public function testTwigLoaderAddition() {
  $environment = \Drupal::service('twig');
  $template = $environment
    ->load('kittens');
  $this
    ->assertEquals('kittens', $template
    ->render([]), 'Passing "kittens" to the custom Twig loader returns "kittens".');
  $template = $environment
    ->load('meow');
  $this
    ->assertEquals('cats', $template
    ->render([]), 'Passing something other than "kittens" to the custom Twig loader returns "cats".');
}