public function SmsFrameworkPhoneNumberTest::testPhoneNumberVerificationMessage in SMS Framework 2.x
Same name and namespace in other branches
- 8 tests/src/Functional/SmsFrameworkPhoneNumberTest.php \Drupal\Tests\sms\Functional\SmsFrameworkPhoneNumberTest::testPhoneNumberVerificationMessage()
- 2.1.x tests/src/Functional/SmsFrameworkPhoneNumberTest.php \Drupal\Tests\sms\Functional\SmsFrameworkPhoneNumberTest::testPhoneNumberVerificationMessage()
Ensure phone number verification SMS sent.
See also
File
- tests/
src/ Functional/ SmsFrameworkPhoneNumberTest.php, line 57
Class
- SmsFrameworkPhoneNumberTest
- General phone number verification tests.
Namespace
Drupal\Tests\sms\FunctionalCode
public function testPhoneNumberVerificationMessage() {
$test_gateway = $this
->createMemoryGateway([
'skip_queue' => TRUE,
]);
$this
->setFallbackGateway($test_gateway);
$phone_numbers = [
'+123123123',
];
$phone_number_settings = $this
->createPhoneNumberSettings('entity_test', 'entity_test');
$this
->createEntityWithPhoneNumber($phone_number_settings, $phone_numbers);
$sms_message = $this
->getLastTestMessage($test_gateway);
$this
->assertTrue($sms_message instanceof SmsMessageInterface, 'SMS verification message sent.');
$this
->assertEqual($sms_message
->getRecipients(), $phone_numbers, 'Sent to correct phone number.');
$phone_verification = $this
->getLastVerification();
$data['sms_verification_code'] = $phone_verification
->getCode();
$message = \Drupal::token()
->replace($phone_number_settings
->getVerificationMessage(), $data);
$this
->assertEqual($sms_message
->getMessage(), $message, 'Sent correct message.');
}