function TwigRawTest::testAutoescapeRaw

Same name in other branches
  1. 9 core/modules/system/tests/src/Kernel/Theme/TwigRawTest.php \Drupal\Tests\system\Kernel\Theme\TwigRawTest::testAutoescapeRaw()
  2. 8.9.x core/modules/system/tests/src/Kernel/Theme/TwigRawTest.php \Drupal\Tests\system\Kernel\Theme\TwigRawTest::testAutoescapeRaw()
  3. 10 core/modules/system/tests/src/Kernel/Theme/TwigRawTest.php \Drupal\Tests\system\Kernel\Theme\TwigRawTest::testAutoescapeRaw()

Tests the raw filter inside an autoescape tag.

File

core/modules/system/tests/src/Kernel/Theme/TwigRawTest.php, line 24

Class

TwigRawTest
Tests Twig 'raw' filter.

Namespace

Drupal\Tests\system\Kernel\Theme

Code

public function testAutoescapeRaw() : void {
    $test = [
        '#theme' => 'twig_raw_test',
        '#script' => '<script>alert("This alert is real because I will put it through the raw filter!");</script>',
    ];
    $rendered = \Drupal::service('renderer')->renderRoot($test);
    $this->setRawContent($rendered);
    $this->assertRaw('<script>alert("This alert is real because I will put it through the raw filter!");</script>');
}

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