You are here

public function SmsFrameworkDeliveryReportEntityTest::testReportRevisions in SMS Framework 8

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

Test saving of delivery report revisions.

File

tests/src/Kernel/SmsFrameworkDeliveryReportEntityTest.php, line 169

Class

SmsFrameworkDeliveryReportEntityTest
Tests the SMS Delivery report entity.

Namespace

Drupal\Tests\sms\Kernel

Code

public function testReportRevisions() {
  $sms_message = SmsMessage::create();
  $sms_message
    ->save();
  $time_queued = $this->container
    ->get('datetime.time')
    ->getRequestTime();
  $time_delivered = $time_queued + 3600;

  /** @var \Drupal\sms\Entity\SmsDeliveryReport $report */
  $report = $this
    ->createDeliveryReport()
    ->setSmsMessage($sms_message)
    ->setMessageId($this
    ->randomMachineName())
    ->setStatus(SmsMessageReportStatus::QUEUED)
    ->setRecipient('1234567890')
    ->setStatusMessage('Message queued')
    ->setStatusTime($time_queued);
  $report
    ->save();
  $report
    ->setStatus(SmsMessageReportStatus::DELIVERED)
    ->setStatusMessage('Message delivered')
    ->setStatusTime($time_delivered)
    ->save();
  $this
    ->assertEquals($time_queued, $report
    ->getTimeQueued());
  $this
    ->assertEquals($time_delivered, $report
    ->getTimeDelivered());
}