You are here

public function SmsFrameworkDeliveryReportEntityTest::testSaveReportWithoutParent in SMS Framework 8

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

Tests saving a delivery report without a parent SMS message.

@covers ::save @covers ::preSave

File

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

Class

SmsFrameworkDeliveryReportEntityTest
Tests the SMS Delivery report entity.

Namespace

Drupal\Tests\sms\Kernel

Code

public function testSaveReportWithoutParent() {
  $this
    ->setExpectedException(EntityStorageException::class, 'No parent SMS message specified for SMS delivery report');

  /** @var \Drupal\sms\Entity\SmsMessageResult $result */
  $result = $this
    ->createDeliveryReport()
    ->setMessageId($this
    ->randomMachineName())
    ->setStatus(SmsMessageReportStatus::DELIVERED)
    ->setRecipient('1234567890')
    ->setStatusMessage('Message delivered')
    ->setStatusTime($this->container
    ->get('datetime.time')
    ->getRequestTime());
  $result
    ->save();
}