SmsFrameworkDeliveryReportTestTrait.php in SMS Framework 2.x
File
tests/src/Functional/SmsFrameworkDeliveryReportTestTrait.php
View source
<?php
declare (strict_types=1);
namespace Drupal\Tests\sms\Functional;
use Drupal\sms\Message\SmsDeliveryReportInterface;
trait SmsFrameworkDeliveryReportTestTrait {
public function testMessageId() {
$report = $this
->createDeliveryReport();
$this
->assertEquals('', $report
->getMessageId(), 'Default value is empty string');
$message_id = $this
->getRandomGenerator()
->string();
$return = $report
->setMessageId($message_id);
$this
->assertTrue($return instanceof SmsDeliveryReportInterface);
$this
->assertEquals($message_id, $report
->getMessageId());
}
public function testRecipient() {
$report = $this
->createDeliveryReport();
$this
->assertEquals('', $report
->getRecipient(), 'Default value is empty string');
$recipient = $this
->getRandomGenerator()
->string();
$return = $report
->setRecipient($recipient);
$this
->assertTrue($return instanceof SmsDeliveryReportInterface);
$this
->assertEquals($recipient, $report
->getRecipient());
}
public function testStatus() {
$report = $this
->createDeliveryReport();
$this
->assertNull($report
->getStatus(), 'Default value is NULL');
$status = $this
->getRandomGenerator()
->string();
$return = $report
->setStatus($status);
$this
->assertTrue($return instanceof SmsDeliveryReportInterface);
$this
->assertEquals($status, $report
->getStatus());
}
public function testStatusMessage() {
$report = $this
->createDeliveryReport();
$this
->assertEquals('', $report
->getStatusMessage(), 'Default value is empty string');
$status_message = $this
->getRandomGenerator()
->string();
$return = $report
->setStatusMessage($status_message);
$this
->assertTrue($return instanceof SmsDeliveryReportInterface);
$this
->assertEquals($status_message, $report
->getStatusMessage());
}
public function testStatusTime() {
$report = $this
->createDeliveryReport();
$this
->assertNull($report
->getStatusTime(), 'Default value is NULL');
$time = 123123123;
$return = $report
->setStatusTime($time);
$this
->assertTrue($return instanceof SmsDeliveryReportInterface);
$this
->assertEquals($time, $report
->getStatusTime());
}
public function testTimeQueued() {
$report = $this
->createDeliveryReport();
$this
->assertNull($report
->getTimeQueued(), 'Default value is NULL');
$time = 123123123;
$return = $report
->setTimeQueued($time);
$this
->assertTrue($return instanceof SmsDeliveryReportInterface);
$this
->assertEquals($time, $report
->getTimeQueued());
}
public function testTimeDelivered() {
$report = $this
->createDeliveryReport();
$this
->assertNull($report
->getTimeDelivered(), 'Default value is NULL');
$time = 123123123;
$return = $report
->setTimeDelivered($time);
$this
->assertTrue($return instanceof SmsDeliveryReportInterface);
$this
->assertEquals($time, $report
->getTimeDelivered());
}
protected abstract function createDeliveryReport();
}