You are here

public function MessageDigestTest::testInvalidEntityId in Message Digest 8

Tests sending with an entity_type and no ID.

File

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

Class

MessageDigestTest
Kernel tests for Message Digest.

Namespace

Drupal\Tests\message_digest\Kernel

Code

public function testInvalidEntityId() {
  $configuration = [
    'entity_type' => 'foo',
  ];
  $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 (foo) and entity_id (). These either both need to be empty, or have values.');
  $this->notifierSender
    ->send($message, $configuration, $digest_notifier
    ->getPluginId());
}