public function HtmlTitleTest::testNodeConfirmationMessage in HTML Title 8
Test the node confirmation message.
File
- tests/
src/ Functional/ HtmlTitleTest.php, line 269
Class
- HtmlTitleTest
- Tests the HTML Title module.
Namespace
Drupal\Tests\html_title\FunctionalCode
public function testNodeConfirmationMessage() {
// Test that node confirmation messages renders the allowed HTML-tags.
$this
->drupalGet('node/add');
$this
->submitForm([
'title[0][value]' => 'Test <sup>sup</sup>-tag',
], 'Save');
$this
->assertSession()
->elementContains('css', 'div[data-drupal-messages]', 'Test <sup>sup</sup>-tag');
// Nodes without HTML should still work.
$this
->drupalGet('node/add');
$this
->submitForm([
'title[0][value]' => 'Test node',
], 'Save');
$this
->assertSession()
->elementTextContains('css', 'div[data-drupal-messages]', 'Test node');
// HTML-tags that are not allowed should be filtered out of the message.
$this
->drupalGet('node/add');
$this
->submitForm([
'title[0][value]' => 'Test <p>p</p>-tag',
], 'Save');
$this
->assertSession()
->elementTextContains('css', 'div[data-drupal-messages]', 'Test p-tag');
// When this setting is TRUE, this will add extra messages on the node
// confirmation. This can be used to check that only the node confirmation
// message is altered.
$this->state
->set('html_title_test.set_node_confirmation_messages', TRUE);
// Test that only the node confirmation message is replaced and other
// messages still work.
$this
->drupalGet('node/add');
$this
->submitForm([
'title[0][value]' => 'Test <sub>sub</sub>-tag',
], 'Save');
$this
->assertSession()
->elementContains('css', 'div[data-drupal-messages]', 'Test <sub>sub</sub>-tag');
$this
->assertSession()
->elementContains('css', 'div[data-drupal-messages]', 'Test status message');
$this
->assertSession()
->elementTextContains('css', 'div[data-drupal-messages]', 'Test status message with <p>HTML</p>');
$this
->assertSession()
->elementContains('css', 'div[data-drupal-messages]', 'Test error message');
}