function TwigExtensionTest::testRenderStrategies
Same name in other branches
- 11.x core/modules/system/tests/src/Functional/Theme/TwigExtensionTest.php \Drupal\Tests\system\Functional\Theme\TwigExtensionTest::testRenderStrategies()
Test if Drupal html strategy is done and the fallback to Twig itself works.
File
-
core/
modules/ system/ tests/ src/ Functional/ Theme/ TwigExtensionTest.php, line 132
Class
- TwigExtensionTest
- Tests Twig extensions.
Namespace
Drupal\Tests\system\Functional\ThemeCode
public function testRenderStrategies() : void {
/** @var \Drupal\Core\Template\TwigExtension $extension */
$extension = \Drupal::service('twig.extension');
/** @var \Drupal\Core\Template\TwigEnvironment $twig */
$twig = \Drupal::service('twig');
$this->assertSame('test&', $extension->escapeFilter($twig, 'test&'), 'TwigExtension::escapeFilter() renders escaped & when strategy is html (default).');
$this->assertSame('test\\u0026', $extension->escapeFilter($twig, 'test&', 'js'), 'TwigExtension::escapeFilter() renders escaped & when strategy is js.');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.