function PageTitleTest::testTitleTags in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/system/src/Tests/System/PageTitleTest.php \Drupal\system\Tests\System\PageTitleTest::testTitleTags()
Tests the handling of HTML in node titles.
File
- core/
modules/ system/ src/ Tests/ System/ PageTitleTest.php, line 48 - Contains \Drupal\system\Tests\System\PageTitleTest.
Class
- PageTitleTest
- Tests HTML output escaping of page title, site name, and slogan.
Namespace
Drupal\system\Tests\SystemCode
function testTitleTags() {
$title = "string with <em>HTML</em>";
// Generate node content.
$edit = array(
'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.');
}