public function TwigExtensionTest::testEscaping in Drupal 8
Same name and namespace in other branches
- 9 core/tests/Drupal/Tests/Core/Template/TwigExtensionTest.php \Drupal\Tests\Core\Template\TwigExtensionTest::testEscaping()
- 10 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 77
Class
- TwigExtensionTest
- Tests the twig extension.
Namespace
Drupal\Tests\Core\TemplateCode
public function testEscaping($template, $expected) {
$loader = new \Twig_Loader_Filesystem();
$twig = new \Twig_Environment($loader, [
'debug' => TRUE,
'cache' => FALSE,
'autoescape' => 'html',
'optimizations' => 0,
]);
$twig
->addExtension($this->systemUnderTest);
$name = '__string_template_test__';
$nodes = $twig
->parse($twig
->tokenize(new \Twig_Source($template, $name)));
$this
->assertSame($expected, $nodes
->getNode('body')
->getNode(0)
->getNode('expr') instanceof \Twig_Node_Expression_Filter);
}