Chris@0: 'twig_raw_test',
Chris@0: '#script' => '',
Chris@0: ];
Chris@0: $rendered = \Drupal::service('renderer')->renderRoot($test);
Chris@0: $this->setRawContent($rendered);
Chris@0: $this->assertRaw('');
Chris@0: }
Chris@0:
Chris@0: /**
Chris@0: * Tests autoescaping of unsafe content.
Chris@0: *
Chris@0: * This is one of the most important tests in Drupal itself in terms of
Chris@0: * security.
Chris@0: */
Chris@0: public function testAutoescape() {
Chris@0: $script = '';
Chris@0: $build = [
Chris@0: '#theme' => 'twig_autoescape_test',
Chris@0: '#script' => $script,
Chris@0: ];
Chris@0: $rendered = \Drupal::service('renderer')->renderRoot($build);
Chris@0: $this->setRawContent($rendered);
Chris@0: $this->assertEscaped($script);
Chris@0: }
Chris@0:
Chris@0: }