You are here

public function MessageDigestTest::testInvalidEntityType in Message Digest 8

Tests sending with an entity_id and no type.

File

tests/src/Kernel/MessageDigestTest.php, line 260

Class

MessageDigestTest
Kernel tests for Message Digest.

Namespace

Drupal\Tests\message_digest\Kernel

Code

public function testInvalidEntityType() {
  $configuration = [
    'entity_id' => 42,
  ];
  $template = $this
    ->createMessageTemplate('foo', 'Foo', 'Foo, foo', []);
  $message = Message::create([
    'template' => $template
      ->id(),
  ]);
  $digest_notifier = $this->notifierManager
    ->createInstance('message_digest:weekly', $configuration, $message);
  $this
    ->expectException(InvalidDigestGroupingException::class);
  $this
    ->expectExceptionMessage('Tried to create a message digest without both entity_type () and entity_id (42). These either both need to be empty, or have values.');
  $this->notifierSender
    ->send($message, $configuration, $digest_notifier
    ->getPluginId());
}