function TwigExtensionTest::testEscaping

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Core/Template/TwigExtensionTest.php \Drupal\Tests\Core\Template\TwigExtensionTest::testEscaping()
  2. 8.9.x core/tests/Drupal/Tests/Core/Template/TwigExtensionTest.php \Drupal\Tests\Core\Template\TwigExtensionTest::testEscaping()
  3. 11.x core/tests/Drupal/Tests/Core/Template/TwigExtensionTest.php \Drupal\Tests\Core\Template\TwigExtensionTest::testEscaping()

Tests the escaping.

@dataProvider providerTestEscaping

File

core/tests/Drupal/Tests/Core/Template/TwigExtensionTest.php, line 99

Class

TwigExtensionTest
Tests the twig extension.

Namespace

Drupal\Tests\Core\Template

Code

public function testEscaping($template, $expected) : void {
    $loader = new FilesystemLoader();
    $twig = new Environment($loader, [
        'debug' => TRUE,
        'cache' => FALSE,
        'autoescape' => 'html',
        'optimizations' => 0,
    ]);
    $twig->addExtension($this->systemUnderTest);
    $name = '__string_template_test__';
    $nodes = $twig->parse($twig->tokenize(new Source($template, $name)));
    $this->assertSame($expected, $nodes->getNode('body')
        ->getNode('0')
        ->getNode('expr') instanceof FilterExpression);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.