You are here

public function SmsFrameworkQueueTest::testRetentionPersist in SMS Framework 8

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

Test retention is set to keep messages after transmission.

Tests \Drupal\sms\Plugin\QueueWorker\SmsProcessor.

File

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

Class

SmsFrameworkQueueTest
Tests behaviour of SMS Framework message queue.

Namespace

Drupal\Tests\sms\Kernel

Code

public function testRetentionPersist() {
  $this->gateway
    ->setRetentionDuration(Direction::OUTGOING, 9999)
    ->save();
  $sms_message = $this
    ->createSmsMessage();
  $this->smsProvider
    ->queue($sms_message);
  $this->cronService
    ->run();
  $sms_messages = SmsMessage::loadMultiple();
  $sms_message_new = reset($sms_messages);
  $this
    ->assertEquals(1, count($this
    ->getTestMessages($this->gateway)), 'One message was sent.');
  $this
    ->assertEquals(1, count($sms_messages), 'There are SMS entities in storage.');
  $this
    ->assertEquals(REQUEST_TIME, $sms_message_new
    ->getProcessedTime());
  $this
    ->assertEquals(FALSE, $sms_message_new
    ->isQueued());
}