function ViewsHooksTest::testViewsFormMainFormPreRender

Same name in other branches
  1. 9 core/modules/views/tests/src/Kernel/ViewsHooksTest.php \Drupal\Tests\views\Kernel\ViewsHooksTest::testViewsFormMainFormPreRender()
  2. 10 core/modules/views/tests/src/Kernel/ViewsHooksTest.php \Drupal\Tests\views\Kernel\ViewsHooksTest::testViewsFormMainFormPreRender()
  3. 11.x core/modules/views/tests/src/Kernel/ViewsHooksTest.php \Drupal\Tests\views\Kernel\ViewsHooksTest::testViewsFormMainFormPreRender()

Tests how hook_views_form_substitutions() makes substitutions.

See also

views_test_data_views_form_substitutions()

\Drupal\views\Form\ViewsFormMainForm::preRenderViewsForm()

File

core/modules/views/tests/src/Kernel/ViewsHooksTest.php, line 104

Class

ViewsHooksTest
Tests that views hooks are registered when defined in $module.views.inc.

Namespace

Drupal\Tests\views\Kernel

Code

public function testViewsFormMainFormPreRender() {
    $element = [
        'output' => [
            '#plain_text' => '<!--will-be-escaped--><!--will-be-not-escaped-->',
        ],
        '#substitutions' => [
            '#value' => [],
        ],
    ];
    $element = \Drupal::service('renderer')->executeInRenderContext(new RenderContext(), function () use ($element) {
        return ViewsFormMainForm::preRenderViewsForm($element);
    });
    $this->setRawContent((string) $element['output']['#markup']);
    $this->assertEscaped('<em>escaped</em>');
    $this->assertRaw('<em>unescaped</em>');
}

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