You are here

public function MessageTokenTest::testTokens in Message 8

Test token replacement in a message template.

File

tests/src/Kernel/MessageTokenTest.php, line 59

Class

MessageTokenTest
Test the Message and tokens integration.

Namespace

Drupal\Tests\message\Kernel

Code

public function testTokens() {
  $message_template = $this
    ->createMessageTemplate('dummy_message', 'Dummy message', '', [
    '[message:author:name]',
  ]);
  $message = Message::create([
    'template' => $message_template
      ->id(),
  ])
    ->setOwnerId($this->user
    ->id());
  $message
    ->save();
  $this
    ->assertEquals('<p>' . Html::escape($this->user
    ->label()) . '</p>', (string) $message, 'The message rendered the author name.');
}