You are here

public function SmsFrameworkMessageEntityTest::testConvertToEntityFromEntitySmsMessage in SMS Framework 8

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

Ensure there is no data loss if an entity is passed to the converter.

File

tests/src/Kernel/SmsFrameworkMessageEntityTest.php, line 281

Class

SmsFrameworkMessageEntityTest
Tests SMS message entity.

Namespace

Drupal\Tests\sms\Kernel

Code

public function testConvertToEntityFromEntitySmsMessage() {
  $recipient = EntityTest::create()
    ->setName($this
    ->randomMachineName());
  $recipient
    ->save();
  $original = SmsMessage::create();
  $original
    ->setMessage($this
    ->randomMachineName());

  // Use a method not common with standard SMS message class.
  $original
    ->setRecipientEntity($recipient);
  $sms_message = SmsMessage::convertFromSmsMessage($original);
  $this
    ->assertEquals($original
    ->getMessage(), $sms_message
    ->getMessage());
  $this
    ->assertEquals($original
    ->getRecipientEntity(), $sms_message
    ->getRecipientEntity());
}