public function RedirectTest::testNoRedirectAfterOneTimeLoginAndSettingPassword in Login Destination 8.2
Same name and namespace in other branches
- 8 tests/src/Functional/RedirectTest.php \Drupal\Tests\login_destination\Functional\RedirectTest::testNoRedirectAfterOneTimeLoginAndSettingPassword()
Tests no redirect after one-time login without compatible destination rule.
When there are login destination rules, but none of them has a trigger on an one-time login configured, no redirect caused by a login destination rule should happen after one-time login and setting password.
File
- tests/
src/ Functional/ RedirectTest.php, line 229
Class
- RedirectTest
- Tests redirects.
Namespace
Drupal\Tests\login_destination\FunctionalCode
public function testNoRedirectAfterOneTimeLoginAndSettingPassword() {
$this
->createLoginDestinationToNode1([
LoginDestination::TRIGGER_LOGIN,
LoginDestination::TRIGGER_REGISTRATION,
LoginDestination::TRIGGER_LOGOUT,
]);
// Generate password reset URL.
$url = user_pass_reset_url($this->account);
// And use the one-time login link.
$this
->drupalPostForm($url, NULL, 'Log in');
$this
->assertSession()
->pageTextContains('You have just used your one-time login link. It is no longer necessary to use this link to log in. Please change your password.');
$this
->assertSession()
->titleEquals(strtr('@name | @site', [
'@name' => $this->account
->getAccountName(),
'@site' => $this
->config('system.site')
->get('name'),
]));
// Set a new password.
$password = user_password();
$edit = [
'pass[pass1]' => $password,
'pass[pass2]' => $password,
];
$this
->drupalPostForm(NULL, $edit, 'Save');
$this
->assertSession()
->pageTextContains('The changes have been saved.');
// Ensure that no login destination redirect happened.
$this
->assertSession()
->addressEquals('/user/2/edit');
}