function PageTitleTest::testTitleTags
Same name in other branches
- 8.9.x core/modules/system/tests/src/Functional/System/PageTitleTest.php \Drupal\Tests\system\Functional\System\PageTitleTest::testTitleTags()
- 10 core/modules/system/tests/src/Functional/System/PageTitleTest.php \Drupal\Tests\system\Functional\System\PageTitleTest::testTitleTags()
- 11.x core/modules/system/tests/src/Functional/System/PageTitleTest.php \Drupal\Tests\system\Functional\System\PageTitleTest::testTitleTags()
Tests the handling of HTML in node titles.
File
-
core/
modules/ system/ tests/ src/ Functional/ System/ PageTitleTest.php, line 55
Class
- PageTitleTest
- Tests HTML output escaping of page title, site name, and slogan.
Namespace
Drupal\Tests\system\Functional\SystemCode
public function testTitleTags() {
$title = "string with <em>HTML</em>";
// Generate node content.
$edit = [
'title[0][value]' => '!SimpleTest! ' . $title . $this->randomMachineName(20),
'body[0][value]' => '!SimpleTest! test body' . $this->randomMachineName(200),
];
// Create the node with HTML in the title.
$this->drupalGet('node/add/page');
$this->submitForm($edit, 'Save');
// Make sure tags in the node title are converted.
$node = $this->drupalGetNodeByTitle($edit['title[0][value]']);
$this->assertNotNull($node, 'Node created and found in database');
$this->assertSession()
->responseContains(Html::escape($edit['title[0][value]']));
$this->drupalGet("node/" . $node->id());
$this->assertSession()
->responseContains(Html::escape($edit['title[0][value]']));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.