You are here

public function SmsFrameworkQueueTest::testQueueIncoming in SMS Framework 8

Same name and namespace in other branches
  1. 2.x tests/src/Kernel/SmsFrameworkQueueTest.php \Drupal\Tests\sms\Kernel\SmsFrameworkQueueTest::testQueueIncoming()
  2. 2.1.x tests/src/Kernel/SmsFrameworkQueueTest.php \Drupal\Tests\sms\Kernel\SmsFrameworkQueueTest::testQueueIncoming()

Test message is queued and received on cron run.

File

tests/src/Kernel/SmsFrameworkQueueTest.php, line 88

Class

SmsFrameworkQueueTest
Tests behaviour of SMS Framework message queue.

Namespace

Drupal\Tests\sms\Kernel

Code

public function testQueueIncoming() {
  $sms_message = $this
    ->createSmsMessage()
    ->setDirection(Direction::INCOMING)
    ->addRecipients($this
    ->randomPhoneNumbers())
    ->setGateway($this->gateway);
  $sms_message
    ->setResult($this
    ->createMessageResult($sms_message));
  $this->smsProvider
    ->queue($sms_message);
  $this
    ->assertEquals(0, count($this
    ->getTestMessages($this->gateway)), 'Message not received yet.');
  $this->cronService
    ->run();
  $this
    ->assertEquals($sms_message
    ->getMessage(), sms_test_gateway_get_incoming()['message'], 'Message was received.');
}