You are here

public function CourierMessageQueueManagerTest::testSendMessage in Courier 2.x

Same name and namespace in other branches
  1. 8 tests/src/Kernel/CourierMessageQueueManagerTest.php \Drupal\Tests\courier\Kernel\CourierMessageQueueManagerTest::testSendMessage()

Test message queue send.

File

tests/src/Kernel/CourierMessageQueueManagerTest.php, line 48

Class

CourierMessageQueueManagerTest
Tests message queue manager.

Namespace

Drupal\Tests\courier\Kernel

Code

public function testSendMessage() {
  $identity = User::create([
    'uid' => 1,
    'name' => $this
      ->randomMachineName(),
  ]);
  $message = TestMessage::create()
    ->setMessage($this
    ->randomString());
  $mqi = MessageQueueItem::create()
    ->setIdentity($identity)
    ->addMessage($message);
  $result = $this->messageQueue
    ->sendMessage($mqi);
  $this
    ->assertTrue($message === $result);
  $this
    ->assertEquals(1, count(\Drupal::state()
    ->get('courier_test_message.messages', [])));
}