You are here

public function TwigWhiteListTest::testWhiteListChaining in Drupal 10

Same name and namespace in other branches
  1. 8 core/tests/Drupal/KernelTests/Core/Theme/TwigWhiteListTest.php \Drupal\KernelTests\Core\Theme\TwigWhiteListTest::testWhiteListChaining()
  2. 9 core/tests/Drupal/KernelTests/Core/Theme/TwigWhiteListTest.php \Drupal\KernelTests\Core\Theme\TwigWhiteListTest::testWhiteListChaining()

Tests white-listing of methods doesn't interfere with chaining.

File

core/tests/Drupal/KernelTests/Core/Theme/TwigWhiteListTest.php, line 123

Class

TwigWhiteListTest
Tests white-listing of entity properties.

Namespace

Drupal\KernelTests\Core\Theme

Code

public function testWhiteListChaining() {

  /** @var \Drupal\Core\Template\TwigEnvironment $environment */
  $environment = \Drupal::service('twig');
  $node = Node::create([
    'type' => 'page',
    'title' => 'Some node mmk',
    'status' => 1,
    'field_term' => $this->term
      ->id(),
  ]);
  $node
    ->save();
  $template = $environment
    ->load($this
    ->getThemePath('test_theme') . '/templates/node.html.twig');
  $markup = $template
    ->render([
    'node' => $node,
  ]);
  $this
    ->setRawContent($markup);
  $this
    ->assertText('Sometimes people are just jerks');
}