You are here

public function ViewsHooksTest::testViewsPreRenderViewsFormViewsForm in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/views/src/Tests/ViewsHooksTest.php \Drupal\views\Tests\ViewsHooksTest::testViewsPreRenderViewsFormViewsForm()

Tests how hook_views_form_substitutions() makes substitutions.

See also

views_test_data_views_form_substitutions()

views_pre_render_views_form_views_form()

File

core/modules/views/src/Tests/ViewsHooksTest.php, line 107
Contains \Drupal\views\Tests\ViewsHooksTest.

Class

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

Namespace

Drupal\views\Tests

Code

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