function FieldSelfTokensTest::testSelfTokenEscaping

Same name in other branches
  1. 11.x core/modules/views/tests/src/Kernel/Handler/FieldSelfTokensTest.php \Drupal\Tests\views\Kernel\Handler\FieldSelfTokensTest::testSelfTokenEscaping()

File

core/modules/views/tests/src/Kernel/Handler/FieldSelfTokensTest.php, line 52

Class

FieldSelfTokensTest
Tests token escaping in the EntityField handler.

Namespace

Drupal\Tests\views\Kernel\Handler

Code

public function testSelfTokenEscaping() : void {
    $view = Views::getView('test_field_self_tokens');
    $view->initHandlers();
    $this->executeView($view);
    $row = $view->result[0];
    $title_field = $view->field['title'];
    $title_field->options['alter']['text'] = '<p>{{ title__value }}</p>';
    $title_field->options['alter']['alter_text'] = TRUE;
    $output = \Drupal::service('renderer')->executeInRenderContext(new RenderContext(), function () use ($title_field, $row) {
        return $title_field->theme($row);
    });
    $this->assertSame('<p>Questions &amp; Answers</p>', (string) $output);
}

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