You are here

public function TwigSandboxTest::testExtendedClass in Drupal 9

Same name and namespace in other branches
  1. 8 core/tests/Drupal/Tests/Core/Template/TwigSandboxTest.php \Drupal\Tests\Core\Template\TwigSandboxTest::testExtendedClass()
  2. 10 core/tests/Drupal/Tests/Core/Template/TwigSandboxTest.php \Drupal\Tests\Core\Template\TwigSandboxTest::testExtendedClass()

Tests that white listed classes can be extended.

File

core/tests/Drupal/Tests/Core/Template/TwigSandboxTest.php, line 74
Contains \Drupal\Tests\Core\Template\TwigSandboxTest.

Class

TwigSandboxTest
Tests the twig sandbox policy.

Namespace

Drupal\Tests\Core\Template

Code

public function testExtendedClass() {
  $this
    ->assertEquals(' class="kitten"', $this->twig
    ->render('{{ attribute.addClass("kitten") }}', [
    'attribute' => new TestAttribute(),
  ]));
}