You are here

public function SmsFrameworkProviderTest::testQueueOut in SMS Framework 8

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

Test sending standard SMS object queue out.

File

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

Class

SmsFrameworkProviderTest
Tests SMS Framework provider service.

Namespace

Drupal\Tests\sms\Kernel

Code

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