public function SmsFrameworkDeliveryReportEntityTest::testMultipleReportRevisions in SMS Framework 2.1.x
Same name and namespace in other branches
- 8 tests/src/Kernel/SmsFrameworkDeliveryReportEntityTest.php \Drupal\Tests\sms\Kernel\SmsFrameworkDeliveryReportEntityTest::testMultipleReportRevisions()
- 2.x tests/src/Kernel/SmsFrameworkDeliveryReportEntityTest.php \Drupal\Tests\sms\Kernel\SmsFrameworkDeliveryReportEntityTest::testMultipleReportRevisions()
Tests the multiple revisioning of delivery reports.
@covers ::getRevisionAtStatus
File
- tests/
src/ Kernel/ SmsFrameworkDeliveryReportEntityTest.php, line 204
Class
- SmsFrameworkDeliveryReportEntityTest
- Tests the SMS Delivery report entity.
Namespace
Drupal\Tests\sms\KernelCode
public function testMultipleReportRevisions() {
$sms_message = SmsMessage::create();
$sms_message
->save();
$request_time = $this->container
->get('datetime.time')
->getRequestTime();
$status_times = [
'queued' => $request_time,
'pending' => $request_time + 1800,
'delivered' => $request_time + 3600,
];
/** @var \Drupal\sms\Entity\SmsDeliveryReport $report */
$report = $this
->createDeliveryReport()
->setSmsMessage($sms_message);
foreach ($status_times as $status => $time) {
$report
->setStatus($status)
->setStatusMessage('Status ' . $status)
->setStatusTime($time)
->save();
}
$this
->assertEquals($status_times['queued'], $report
->getRevisionAtStatus('queued')
->getStatusTime());
$this
->assertEquals($status_times['pending'], $report
->getRevisionAtStatus('pending')
->getStatusTime());
$this
->assertEquals($status_times['delivered'], $report
->getRevisionAtStatus('delivered')
->getStatusTime());
// Create another revision with different status time.
$report
->setStatus('queued')
->setStatusTime(1234567890)
->save();
// Verify that the latest revision is always returned.
$this
->assertEquals(1234567890, $report
->getRevisionAtStatus('queued')
->getStatusTime());
$this
->assertEquals($status_times['pending'], $report
->getRevisionAtStatus('pending')
->getStatusTime());
$this
->assertEquals($status_times['delivered'], $report
->getRevisionAtStatus('delivered')
->getStatusTime());
}