You are here

public function TwigSandboxTest::testEntityDangerousMethods in Drupal 8

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

Tests that dangerous methods cannot be called in entity objects.

@dataProvider getTwigEntityDangerousMethods

File

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

Class

TwigSandboxTest
Tests the twig sandbox policy.

Namespace

Drupal\Tests\Core\Template

Code

public function testEntityDangerousMethods($template) {
  $entity = $this
    ->createMock('Drupal\\Core\\Entity\\EntityInterface');
  $this
    ->expectException(\Twig_Sandbox_SecurityError::class);
  $this->twig
    ->render($template, [
    'entity' => $entity,
  ]);
}