You are here

public function UserNotificationEmailTest::testAUserCanDisableEmailNotifications in Private Message 8

Test that users who have disabled notifications do not get an email.

File

tests/src/Kernel/UserNotificationEmailTest.php, line 116

Class

UserNotificationEmailTest
Tests notification emails when a new private message is created.

Namespace

Drupal\Tests\private_message\Kernel

Code

public function testAUserCanDisableEmailNotifications() {
  $owner = $this
    ->createUser();
  $member1 = $this
    ->createUser([
    'mail' => 'member1@example.com',
  ]);
  $member2 = $this
    ->createUser([
    'mail' => 'member2@example.com',
  ]);
  \Drupal::currentUser()
    ->setAccount($owner);
  $this
    ->disableNotificationsForUser($member2);
  $message = $this
    ->createMessage([
    'owner' => $owner,
  ]);
  $this->threadManager
    ->saveThread($message, [
    $owner,
    $member1,
    $member2,
  ]);
  $this
    ->assertCount(1, $this
    ->getMails());
}