You are here

trait SmsFrameworkDeliveryReportTestTrait in SMS Framework 8

Same name and namespace in other branches
  1. 2.x tests/src/Functional/SmsFrameworkDeliveryReportTestTrait.php \Drupal\Tests\sms\Functional\SmsFrameworkDeliveryReportTestTrait
  2. 2.1.x tests/src/Functional/SmsFrameworkDeliveryReportTestTrait.php \Drupal\Tests\sms\Functional\SmsFrameworkDeliveryReportTestTrait

Provides common tests for SmsDeliveryReport object and entity classes.

Hierarchy

2 files declare their use of SmsFrameworkDeliveryReportTestTrait
SmsFrameworkDeliveryReportEntityTest.php in tests/src/Kernel/SmsFrameworkDeliveryReportEntityTest.php
SmsFrameworkDeliveryReportUnitTest.php in tests/src/Unit/Message/SmsFrameworkDeliveryReportUnitTest.php

File

tests/src/Functional/SmsFrameworkDeliveryReportTestTrait.php, line 10

Namespace

Drupal\Tests\sms\Functional
View source
trait SmsFrameworkDeliveryReportTestTrait {

  /**
   * Tests message ID.
   *
   * @covers ::getMessageId
   * @covers ::setMessageId
   */
  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());
  }

  /**
   * Tests recipient.
   *
   * @covers ::getRecipient
   * @covers ::setRecipient
   */
  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());
  }

  /**
   * Tests status.
   *
   * @covers ::getStatus
   * @covers ::setStatus
   */
  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());
  }

  /**
   * Tests status message.
   *
   * @covers ::getStatusMessage
   * @covers ::setStatusMessage
   */
  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());
  }

  /**
   * Tests status time.
   *
   * @covers ::getStatusTime
   * @covers ::setStatusTime
   */
  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());
  }

  /**
   * Tests time queued.
   *
   * @covers ::getTimeQueued
   * @covers ::setTimeQueued
   */
  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());
  }

  /**
   * Tests time delivered.
   *
   * @covers ::getTimeDelivered
   * @covers ::setTimeDelivered
   */
  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());
  }

  /**
   * Creates an SMS delivery report for testing.
   *
   * @return \Drupal\sms\Message\SmsDeliveryReportInterface
   *   A delivery report for testing.
   */
  protected abstract function createDeliveryReport();

}

Members

Namesort descending Modifiers Type Description Overrides
SmsFrameworkDeliveryReportTestTrait::createDeliveryReport abstract protected function Creates an SMS delivery report for testing. 2
SmsFrameworkDeliveryReportTestTrait::testMessageId public function Tests message ID.
SmsFrameworkDeliveryReportTestTrait::testRecipient public function Tests recipient.
SmsFrameworkDeliveryReportTestTrait::testStatus public function Tests status.
SmsFrameworkDeliveryReportTestTrait::testStatusMessage public function Tests status message.
SmsFrameworkDeliveryReportTestTrait::testStatusTime public function Tests status time.
SmsFrameworkDeliveryReportTestTrait::testTimeDelivered public function Tests time delivered.
SmsFrameworkDeliveryReportTestTrait::testTimeQueued public function Tests time queued.