function TwigSandboxTest::testTwigMethodAttributeAllowed

Tests that method with TwigAllowed attribute is allowed.

File

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

Class

TwigSandboxTest
Tests the twig sandbox policy.

Namespace

Drupal\Tests\Core\Template

Code

public function testTwigMethodAttributeAllowed() : void {
  $object = new AttributeAllowTestClass();
  $result = $this->twig
    ->render('{{ object.allowed() }}', [
    'object' => $object,
  ]);
  $this->assertTrue((bool) $result, 'TwigAllowed attribute allows method to be called.');
}

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