function PreviewTest::testPreviewTitle
Same name in other branches
- 10 core/modules/views_ui/tests/src/Functional/PreviewTest.php \Drupal\Tests\views_ui\Functional\PreviewTest::testPreviewTitle()
- 11.x core/modules/views_ui/tests/src/Functional/PreviewTest.php \Drupal\Tests\views_ui\Functional\PreviewTest::testPreviewTitle()
Tests HTML is filtered from the view title when previewing.
File
-
core/
modules/ views_ui/ tests/ src/ Functional/ PreviewTest.php, line 183
Class
- PreviewTest
- Tests the UI preview functionality.
Namespace
Drupal\Tests\views_ui\FunctionalCode
public function testPreviewTitle() {
// Update the view and change title with html tags.
\Drupal::configFactory()->getEditable('views.view.test_preview')
->set('display.default.display_options.title', '<strong>Test preview title</strong>')
->save();
$this->drupalGet('admin/structure/views/view/test_preview/edit');
$this->assertSession()
->statusCodeEquals(200);
$this->submitForm([], 'Update preview');
$this->assertSession()
->pageTextContains('Test preview title');
// Ensure allowed HTML tags are still displayed.
$this->assertCount(2, $this->xpath('//div[@id="views-live-preview"]//strong[text()=:text]', [
':text' => 'Test preview title',
]));
// Ensure other tags are filtered.
\Drupal::configFactory()->getEditable('views.view.test_preview')
->set('display.default.display_options.title', '<b>Test preview title</b>')
->save();
$this->submitForm([], 'Update preview');
$this->assertCount(0, $this->xpath('//div[@id="views-live-preview"]//b[text()=:text]', [
':text' => 'Test preview title',
]));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.