You are here

public function ViewsHooksTest::testViewsFormMainFormPreRender in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/views/tests/src/Kernel/ViewsHooksTest.php \Drupal\Tests\views\Kernel\ViewsHooksTest::testViewsFormMainFormPreRender()
  2. 9 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>');
}