public function TwigExtensionTest::testEscaping in Drupal 10
Same name and namespace in other branches
- 8 core/tests/Drupal/Tests/Core/Template/TwigExtensionTest.php \Drupal\Tests\Core\Template\TwigExtensionTest::testEscaping()
- 9 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 91
Class
- TwigExtensionTest
- Tests the twig extension.
Namespace
Drupal\Tests\Core\TemplateCode
public function testEscaping($template, $expected) {
$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);
}