public function SmsFrameworkDeliveryReportEntityTest::testSaveAndRetrieveReport in SMS Framework 2.1.x
Same name and namespace in other branches
- 8 tests/src/Kernel/SmsFrameworkDeliveryReportEntityTest.php \Drupal\Tests\sms\Kernel\SmsFrameworkDeliveryReportEntityTest::testSaveAndRetrieveReport()
- 2.x tests/src/Kernel/SmsFrameworkDeliveryReportEntityTest.php \Drupal\Tests\sms\Kernel\SmsFrameworkDeliveryReportEntityTest::testSaveAndRetrieveReport()
Tests saving and retrieval of a complete entity.
@covers ::save
File
- tests/
src/ Kernel/ SmsFrameworkDeliveryReportEntityTest.php, line 121
Class
- SmsFrameworkDeliveryReportEntityTest
- Tests the SMS Delivery report entity.
Namespace
Drupal\Tests\sms\KernelCode
public function testSaveAndRetrieveReport() {
/** @var \Drupal\sms\Entity\SmsDeliveryReport $report */
$report = $this
->createDeliveryReport()
->setMessageId($this
->randomMachineName())
->setStatus(SmsMessageReportStatus::DELIVERED)
->setRecipient('1234567890')
->setStatusMessage('Message delivered')
->setStatusTime($this->container
->get('datetime.time')
->getRequestTime());
$sms_message = SmsMessage::create();
$sms_message
->save();
$report
->setSmsMessage($sms_message)
->save();
$storage = $this->container
->get('entity_type.manager')
->getStorage('sms_report');
$saved = $storage
->loadByProperties([
'recipient' => '1234567890',
]);
$this
->assertEquals(1, count($saved));
$saved = reset($saved);
$this
->assertEquals($report
->getRecipient(), $saved
->getRecipient());
$this
->assertEquals($report
->getMessageId(), $saved
->getMessageId());
$this
->assertEquals($report
->getStatus(), $saved
->getStatus());
$this
->assertEquals($report
->getStatusMessage(), $saved
->getStatusMessage());
$this
->assertEquals($report
->getStatusTime(), $saved
->getStatusTime());
$this
->assertEquals($report
->uuid(), $saved
->uuid());
}