You are here

function UserNotificationEmailTest::testNotificationEmailsCanBeDisabled in Private Message 8

Test that notification emails can be disabled globally.

File

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

Class

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

Namespace

Drupal\Tests\private_message\Kernel

Code

function testNotificationEmailsCanBeDisabled() {
  $settings = \Drupal::configFactory()
    ->getEditable('private_message.settings');
  $settings
    ->set('enable_email_notifications', FALSE);
  $settings
    ->save(TRUE);
  $this
    ->assertFalse($settings
    ->get('enable_email_notifications'));
  $user1 = $this
    ->createUser();
  $user2 = $this
    ->createUser();
  $message = $this
    ->createMessage();
  $this->threadManager
    ->saveThread($message, [
    $user1,
    $user2,
  ]);
  $this
    ->assertCount(0, $this
    ->getMails());
}