MessageTextHandlerTest.php in Message 8
File
tests/src/Functional/MessageTextHandlerTest.php
View source
<?php
namespace Drupal\Tests\message\Functional;
use Drupal\message\Entity\Message;
class MessageTextHandlerTest extends MessageTestBase {
protected $account;
public static $modules = [
'filter_test',
'message_test',
];
public function setUp() {
parent::setUp();
$this->account = $this
->drupalCreateUser([
'overview messages',
]);
}
public function testTextHandler() {
$text = [
[
'value' => 'Dummy text message',
'format' => 'filtered_html',
],
];
$this
->createMessageTemplate('dummy_message', 'Dummy message', '', $text);
Message::create([
'template' => 'dummy_message',
])
->save();
$this
->drupalLogin($this->account);
$this
->drupalGet('admin/content/messages');
$this
->assertText('Dummy text message');
$this
->drupalGet('message-test');
$this
->assertText('Dummy text message');
}
public function testHtmlTextHandler() {
$text = [
[
'value' => htmlspecialchars('<p> Some HTML text</p>'),
'format' => 'full_html',
],
];
$this
->createMessageTemplate('html_dummy_message', 'HTML Dummy message', '', $text);
Message::create([
'template' => 'html_dummy_message',
])
->save();
$this
->drupalLogin($this->account);
$this
->drupalGet('admin/content/message');
$this
->assertText(htmlspecialchars('<p> Some HTML text</p>'));
}
}