You are here

public function SmsFrameworkPhoneNumberVerifyForm::testVerifyPathSettings in SMS Framework 8

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

Test changing verification path.

File

tests/src/Functional/SmsFrameworkPhoneNumberVerifyForm.php, line 98

Class

SmsFrameworkPhoneNumberVerifyForm
Tests phone numbers verification code form.

Namespace

Drupal\Tests\sms\Functional

Code

public function testVerifyPathSettings() {
  $account = $this
    ->drupalCreateUser([
    'sms verify phone number',
    'administer smsframework',
  ]);
  $this
    ->drupalLogin($account);

  // Hard code path, don't use Url::fromRoute.
  $this
    ->drupalGet('/verify');
  $this
    ->assertResponse(200, 'Default phone number verification route exists at /verify');
  $path_verify = '/' . $this
    ->randomMachineName() . '/' . $this
    ->randomMachineName();
  $edit = [
    'pages[verify]' => $path_verify,
  ];
  $this
    ->drupalPostForm(Url::fromRoute('sms.settings'), $edit, 'Save configuration');

  // Ensure the route cache is rebuilt by getting the verify route.
  $this
    ->drupalGet($path_verify);
  $this
    ->assertResponse(200, 'Phone number verification route changed to ' . $path_verify);
  $this
    ->drupalGet('/verify');
  $this
    ->assertResponse(404, 'Previous route path was invalidated.');
}