You are here

public function SmsFrameworkPhoneNumberProviderTest::testSendMessageVerified in SMS Framework 2.x

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

Tests SMS message sent to entities with verified phone number.

@covers ::sendMessage

File

tests/src/Kernel/SmsFrameworkPhoneNumberProviderTest.php, line 209

Class

SmsFrameworkPhoneNumberProviderTest
Tests Phone Number Provider.

Namespace

Drupal\Tests\sms\Kernel

Code

public function testSendMessageVerified() {
  $phone_numbers = [
    '+123123123',
  ];
  $entity = $this
    ->createEntityWithPhoneNumber($this->phoneNumberSettings, $phone_numbers);
  $this
    ->resetTestMessages();
  $this
    ->verifyPhoneNumber($entity, $phone_numbers[0]);
  $sms_message = new SmsMessage();
  $sms_message
    ->setSenderNumber('+999888777')
    ->setMessage($this
    ->randomString());
  $this->phoneNumberProvider
    ->sendMessage($entity, $sms_message);
  $this
    ->assertEquals(1, count($this
    ->getTestMessages($this->gateway)));
}