You are here

public function SmsFrameworkProviderTest::testQueueIn in SMS Framework 8

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

Test sending standard SMS object queue in.

File

tests/src/Kernel/SmsFrameworkProviderTest.php, line 266

Class

SmsFrameworkProviderTest
Tests SMS Framework provider service.

Namespace

Drupal\Tests\sms\Kernel

Code

public function testQueueIn() {
  $sms_message = new StandardSmsMessage();
  $sms_message
    ->addRecipients($this
    ->randomPhoneNumbers())
    ->setMessage($this
    ->randomString())
    ->setDirection(Direction::INCOMING)
    ->setGateway($this->gateway);
  $sms_message
    ->setResult($this
    ->createMessageResult($sms_message));
  $sms_messages = $this->smsStorage
    ->loadByProperties([
    'direction' => Direction::INCOMING,
  ]);
  $this
    ->assertEquals(0, count($sms_messages), 'There is zero SMS message in the incoming queue.');
  $this->smsProvider
    ->queue($sms_message);
  $sms_messages = $this->smsStorage
    ->loadByProperties([
    'direction' => Direction::INCOMING,
  ]);
  $this
    ->assertEquals(1, count($sms_messages), 'There is one SMS message in the incoming queue.');
  $sms_message_loaded = reset($sms_messages);
  $this
    ->assertEquals(Direction::INCOMING, $sms_message_loaded
    ->getDirection());
}