public function PageTitleTest::testTitleTags in Drupal 10
Same name and namespace in other branches
- 8 core/modules/system/tests/src/Functional/System/PageTitleTest.php \Drupal\Tests\system\Functional\System\PageTitleTest::testTitleTags()
- 9 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]' => '!Test! ' . $title . $this
->randomMachineName(20),
'body[0][value]' => '!Test! 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]']));
}