You are here

public function MessageDigestUiTest::testNotificationsDefault in Message Digest 8

Test that notifiers are not altered for users that are not using digests.

File

message_digest_ui/tests/src/Kernel/MessageDigestUiTest.php, line 58

Class

MessageDigestUiTest
Basic tests for the Message Digest UI module.

Namespace

Drupal\Tests\message_digest_ui\Kernel

Code

public function testNotificationsDefault() {
  $this
    ->assertEmpty($this->users[2]->message_digest->value);

  // Subscribe user 2 to node 1.
  $flag = $this->flagService
    ->getFlagById('subscribe_node');
  $this->flagService
    ->flag($flag, $this->nodes[1], $this->users[2]);

  // Check default 'immediate' is working.
  $message = Message::create([
    'template' => $this->messageTemplate
      ->id(),
  ]);
  $uids = $this->messageSubscribers
    ->getSubscribers($this->nodes[1], $message);

  // Assert subscribers data.
  $expected_uids = [
    $this->users[2]
      ->id() => new DeliveryCandidate([
      'subscribe_node',
    ], [
      'email',
    ], $this->users[2]
      ->id()),
  ];
  $this
    ->assertEquals($expected_uids, $uids, 'All expected subscribers were fetched.');
}