You are here

public function SmsFrameworkPhoneNumberVerificationTest::testNewPhoneVerification in SMS Framework 2.1.x

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

Tests creating new verification for an entity.

@covers ::newPhoneVerification

File

tests/src/Kernel/SmsFrameworkPhoneNumberVerificationTest.php, line 250

Class

SmsFrameworkPhoneNumberVerificationTest
Tests Phone Number Provider.

Namespace

Drupal\Tests\sms\Kernel

Code

public function testNewPhoneVerification() {
  $phone_number = '+123123123';
  $entity = $this
    ->createEntityWithPhoneNumber($this->phoneNumberSettings);
  $return = $this->phoneNumberVerificationProvider
    ->newPhoneVerification($entity, $phone_number);
  $this
    ->assertTrue($return instanceof PhoneNumberVerificationInterface);

  // Catch the phone verification message.
  $sent_messages = $this
    ->getTestMessages($this->gateway);
  $this
    ->assertEquals(1, count($sent_messages));
  $verification_message = reset($sent_messages);
  $this
    ->assertTrue($verification_message
    ->getOption('_is_verification_message'));
  $verification = $this
    ->getLastVerification();
  $this
    ->assertEquals($entity
    ->id(), $verification
    ->getEntity()
    ->id());
  $this
    ->assertEquals($phone_number, $verification
    ->getPhoneNumber());
}