You are here

public function TwigNamespaceTest::testTwigNamespaces in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/system/tests/src/Kernel/Theme/TwigNamespaceTest.php \Drupal\Tests\system\Kernel\Theme\TwigNamespaceTest::testTwigNamespaces()
  2. 10 core/modules/system/tests/src/Kernel/Theme/TwigNamespaceTest.php \Drupal\Tests\system\Kernel\Theme\TwigNamespaceTest::testTwigNamespaces()

Tests template extension and includes using namespaces.

File

core/modules/system/tests/src/Kernel/Theme/TwigNamespaceTest.php, line 59

Class

TwigNamespaceTest
Tests Twig namespaces.

Namespace

Drupal\Tests\system\Kernel\Theme

Code

public function testTwigNamespaces() {

  // Test twig @extends and @include in template files.
  $test = [
    '#theme' => 'twig_namespace_test',
  ];
  $this
    ->setRawContent(\Drupal::service('renderer')
    ->renderRoot($test));
  $this
    ->assertText('This line is from twig_namespace_a/templates/test.html.twig');
  $this
    ->assertText('This line is from twig_namespace_b/templates/test.html.twig');
}