You are here

public function CourierManagerTest::testSkipQueueOff in Courier 8

Same name and namespace in other branches
  1. 2.x tests/src/Kernel/CourierManagerTest.php \Drupal\Tests\courier\Kernel\CourierManagerTest::testSkipQueueOff()

Test skip queue is off.

File

tests/src/Kernel/CourierManagerTest.php, line 44

Class

CourierManagerTest
Tests Courier manager.

Namespace

Drupal\Tests\courier\Kernel

Code

public function testSkipQueueOff() {
  $this
    ->config('courier.settings')
    ->set('skip_queue', FALSE)
    ->set('channel_preferences', [
    'user' => [
      'courier_test_message',
    ],
  ])
    ->save();
  $template_collection = TemplateCollection::create();
  $this->courierManager
    ->addTemplates($template_collection);
  $template_collection
    ->save();
  $template_collection
    ->getTemplate('courier_test_message')
    ->setMessage($this
    ->randomString())
    ->save();
  $identity = User::create([
    'uid' => 1,
    'name' => $this
      ->randomMachineName(),
    'mail' => 'user@email.tld',
  ]);
  $identity
    ->save();
  $this->courierManager
    ->sendMessage($template_collection, $identity);
  $this
    ->assertEquals(1, count(MessageQueueItem::loadMultiple()));
  $this
    ->assertEquals(0, count(\Drupal::state()
    ->get('courier_test_message.messages', [])));
}