function UserPasswordResetTest::testUserResetPasswordTextboxFilled
Same name in other branches
- 8.9.x core/modules/user/tests/src/Functional/UserPasswordResetTest.php \Drupal\Tests\user\Functional\UserPasswordResetTest::testUserResetPasswordTextboxFilled()
Prefill the text box on incorrect login via link to password reset page.
File
-
core/
modules/ user/ tests/ src/ Functional/ UserPasswordResetTest.php, line 376
Class
- UserPasswordResetTest
- Ensure that password reset methods work as expected.
Namespace
Drupal\Tests\user\FunctionalCode
public function testUserResetPasswordTextboxFilled() {
$this->drupalGet('user/login');
$edit = [
'name' => $this->randomMachineName(),
'pass' => $this->randomMachineName(),
];
$this->drupalGet('user/login');
$this->submitForm($edit, 'Log in');
$this->assertSession()
->pageTextContains("Unrecognized username or password. Forgot your password?");
$this->assertSession()
->linkExists("Forgot your password?");
$this->assertSession()
->linkByHrefExists(Url::fromRoute('user.pass', [], [
'query' => [
'name' => $edit['name'],
],
])->toString());
unset($edit['pass']);
$this->drupalGet('user/password', [
'query' => [
'name' => $edit['name'],
],
]);
$this->assertSession()
->fieldValueEquals('name', $edit['name']);
// Ensure the name field value is not cached.
$this->drupalGet('user/password');
$this->assertSession()
->fieldValueNotEquals('name', $edit['name']);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.