You are here

public function SmsFrameworkMessageEntityTest::testSenderNameWithSenderEntity in SMS Framework 8

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

Test sender name is correct when sender name or sender entity is set.

File

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

Class

SmsFrameworkMessageEntityTest
Tests SMS message entity.

Namespace

Drupal\Tests\sms\Kernel

Code

public function testSenderNameWithSenderEntity() {
  $sender_name = $this
    ->randomMachineName();
  $sender = EntityTest::create()
    ->setName($this
    ->randomMachineName());
  $sender
    ->save();
  $sms_message1 = $this
    ->createSmsMessage();
  $sms_message1
    ->setSender($sender_name);
  $sms_message1
    ->setSenderEntity($sender);
  $this
    ->assertEquals($sender_name, $sms_message1
    ->getSender());
  $sms_message2 = $this
    ->createSmsMessage();
  $sms_message2
    ->setSenderEntity($sender);
  $this
    ->assertEquals($sender
    ->label(), $sms_message2
    ->getSender());
}