You are here

public function SmsFrameworkMessageTestTrait::testRecipientAdd in SMS Framework 8

Same name and namespace in other branches
  1. 2.x tests/src/Functional/SmsFrameworkMessageTestTrait.php \Drupal\Tests\sms\Functional\SmsFrameworkMessageTestTrait::testRecipientAdd()
  2. 2.1.x tests/src/Functional/SmsFrameworkMessageTestTrait.php \Drupal\Tests\sms\Functional\SmsFrameworkMessageTestTrait::testRecipientAdd()

Tests adding recipients to SMS messages.

@covers ::addRecipient

File

tests/src/Functional/SmsFrameworkMessageTestTrait.php, line 81

Class

SmsFrameworkMessageTestTrait
SMS Message object test trait.

Namespace

Drupal\Tests\sms\Functional

Code

public function testRecipientAdd() {
  $recipient1 = '123123123';
  $recipient2 = '456456456';
  $sms_message1 = $this
    ->createSmsMessage();
  $sms_message1
    ->addRecipient($recipient1)
    ->addRecipient($recipient2);
  $this
    ->assertEquals([
    $recipient1,
    $recipient2,
  ], $sms_message1
    ->getRecipients());

  // Check duplicate recipients are not added.
  $sms_message2 = $this
    ->createSmsMessage();
  $sms_message2
    ->addRecipients([
    $recipient1,
    $recipient1,
    $recipient1,
    $recipient2,
  ]);
  $this
    ->assertEquals([
    $recipient1,
    $recipient2,
  ], $sms_message2
    ->getRecipients());
}