You are here

public function CourierSystemTest::testOverride 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::testOverride()

Test courier system override is on.

File

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

Class

CourierSystemTest
Tests Courier system.

Namespace

Drupal\Tests\courier_system\Kernel

Code

public function testOverride() {
  foreach ($this->mailIds as $id) {

    // Turn on the email.
    $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 on Courier override.
    $this
      ->config('courier_system.settings')
      ->set('override.user_' . $id, TRUE)
      ->save();
    $body = $this
      ->randomMachineName();
    $this
      ->createGlobalTemplateCollection('courier_system.user_' . $id, $body);

    // Simulate.
    _user_mail_notify($id, $this
      ->createUser());
    $this->cron
      ->run();
    $this
      ->assertMailString('body', $body, 2, 'Body found in override for ' . $id);
  }
}