You are here

public function CourierSystemTest::testNonOverride in Courier 2.x

Same name and namespace in other branches
  1. 8 courier_system/tests/src/Kernel/CourierSystemTest.php \Drupal\Tests\courier_system\Kernel\CourierSystemTest::testNonOverride()

Test courier system override is off.

File

courier_system/tests/src/Kernel/CourierSystemTest.php, line 68

Class

CourierSystemTest
Tests Courier system.

Namespace

Drupal\Tests\courier_system\Kernel

Code

public function testNonOverride() {
  foreach ($this->mailIds as $id) {
    $this
      ->config('user.settings')
      ->set('notify.' . $id, TRUE)
      ->save();
    $default_body = $this
      ->randomMachineName();

    // Override the user.module template.
    $this
      ->config('user.mail')
      ->set($id . '.body', $default_body)
      ->save();

    // Turn off Courier override.
    $this
      ->config('courier_system.settings')
      ->set('override.user_' . $id, FALSE)
      ->save();
    $body = $this
      ->randomMachineName();
    $this
      ->createGlobalTemplateCollection('courier_system.user_' . $id, $body);

    // Simulate.
    _user_mail_notify($id, $this
      ->createUser());
    $this->cron
      ->run();

    // Email depth is two emails since some triggers will send email for user
    // and admin.
    $this
      ->assertMailString('body', $default_body, 2, 'Body found in non override for ' . $id);
  }
}