function PageTitleTest::testTitleTags
Same name in other branches
- 9 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->drupalPostForm('node/add/page', $edit, t('Save'));
$node = $this->drupalGetNodeByTitle($edit['title[0][value]']);
$this->assertNotNull($node, 'Node created and found in database');
$this->assertText(Html::escape($edit['title[0][value]']), 'Check to make sure tags in the node title are converted.');
$this->drupalGet("node/" . $node->id());
$this->assertText(Html::escape($edit['title[0][value]']), 'Check to make sure tags in the node title are converted.');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.