function ViewsEscapingTest::testViewsViewFieldsEscaping

Same name in other branches
  1. 9 core/modules/views/tests/src/Functional/ViewsEscapingTest.php \Drupal\Tests\views\Functional\ViewsEscapingTest::testViewsViewFieldsEscaping()
  2. 8.9.x core/modules/views/tests/src/Functional/ViewsEscapingTest.php \Drupal\Tests\views\Functional\ViewsEscapingTest::testViewsViewFieldsEscaping()
  3. 11.x core/modules/views/tests/src/Functional/ViewsEscapingTest.php \Drupal\Tests\views\Functional\ViewsEscapingTest::testViewsViewFieldsEscaping()

Tests for incorrectly escaped markup in the views-view-fields.html.twig.

File

core/modules/views/tests/src/Functional/ViewsEscapingTest.php, line 49

Class

ViewsEscapingTest
Tests output of Views.

Namespace

Drupal\Tests\views\Functional

Code

public function testViewsViewFieldsEscaping() : void {
    // Test with system theme using theme function.
    $this->drupalGet('test_page_display_200');
    // Assert that there are no escaped '<'s characters.
    $this->assertSession()
        ->assertNoEscaped('<');
    // Install theme to test with template system.
    \Drupal::service('theme_installer')->install([
        'views_test_theme',
    ]);
    // Make base theme default then test for hook invocations.
    $this->config('system.theme')
        ->set('default', 'views_test_theme')
        ->save();
    $this->assertEquals('views_test_theme', $this->config('system.theme')
        ->get('default'));
    $this->drupalGet('test_page_display_200');
    // Assert that we are using the correct template.
    $this->assertSession()
        ->pageTextContains('force');
    // Assert that there are no escaped '<'s characters.
    $this->assertSession()
        ->assertNoEscaped('<');
}

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