You are here

public function RedirectTest::testRedirectImmediatelyAfterOneTimeLogin in Login Destination 8.2

Same name and namespace in other branches
  1. 8 tests/src/Functional/RedirectTest.php \Drupal\Tests\login_destination\Functional\RedirectTest::testRedirectImmediatelyAfterOneTimeLogin()

Tests redirecting immediately after one-time login.

File

tests/src/Functional/RedirectTest.php, line 262

Class

RedirectTest
Tests redirects.

Namespace

Drupal\Tests\login_destination\Functional

Code

public function testRedirectImmediatelyAfterOneTimeLogin() {
  $this
    ->config('login_destination.settings')
    ->set('immediate_redirect', TRUE)
    ->save();
  $this
    ->createLoginDestinationToNode1([
    LoginDestination::TRIGGER_ONE_TIME_LOGIN,
  ]);

  // Generate password reset URL.
  $url = user_pass_reset_url($this->account);

  // And use the one-time login link.
  $this
    ->drupalPostForm($url, NULL, 'Log in');

  // Assert that the redirect happened immediately.
  $this
    ->assertSession()
    ->statusCodeEquals(200);
  $this
    ->assertSession()
    ->addressEquals('/node/1');
}