You are here

public function MessageCreateTest::testMessageCreateDefaultValues in Message 8

Tests if message create sets the default uid to currently logged in user.

File

tests/src/Functional/MessageCreateTest.php, line 34

Class

MessageCreateTest
Tests message creation and default values.

Namespace

Drupal\Tests\message\Functional

Code

public function testMessageCreateDefaultValues() {

  // Login our user to create message.
  $this
    ->drupalLogin($this->user);
  $template = 'dummy_message';

  // Create message to be rendered without setting owner.
  $message_template = $this
    ->createMessageTemplate($template, 'Dummy message', '', [
    '[message:author:name]',
  ]);
  $message = Message::create([
    'template' => $message_template
      ->id(),
  ]);
  $message
    ->save();

  /* @var Message $message */
  $this
    ->assertEqual($this->user
    ->id(), $message
    ->getOwnerId(), 'The default value for uid was set correctly.');
}