You are here

public function SmsFrameworkTokenTest::testSmsMessageTokens in SMS Framework 8

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

Tests 'sms-message' tokens.

File

tests/src/Kernel/SmsFrameworkTokenTest.php, line 68

Class

SmsFrameworkTokenTest
Tests SMS Framework tokens.

Namespace

Drupal\Tests\sms\Kernel

Code

public function testSmsMessageTokens() {
  $phone_numbers = [
    '+123123123',
    '+456456456',
  ];
  $message = $this
    ->randomString();
  $sms_message = new SmsMessage();
  $sms_message
    ->setSenderNumber('+999888777')
    ->setMessage($message)
    ->addRecipients($phone_numbers);
  $data['sms-message'] = $sms_message;
  $this
    ->assertEquals($phone_numbers[0], $this->tokenService
    ->replace('[sms-message:phone-number]', $data));
  $this
    ->assertEquals(Html::escape($message), $this->tokenService
    ->replace('[sms-message:message]', $data));
}