function TwigSandboxTest::testTwigMethodAttributeNotAllowed

Tests that method without TwigAllowed attribute is not allowed.

File

core/tests/Drupal/Tests/Core/Template/TwigSandboxTest.php, line 172

Class

TwigSandboxTest
Tests the twig sandbox policy.

Namespace

Drupal\Tests\Core\Template

Code

public function testTwigMethodAttributeNotAllowed() : void {
  $object = new AttributeAllowTestClass();
  $this->expectException(SecurityError::class);
  $this->twig
    ->render('{{ object.notAllowed() }}', [
    'object' => $object,
  ]);
}

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