public function UserPasswordResetTest::testUserResetPasswordTextboxFilled in Drupal 10
Same name and namespace in other branches
- 8 core/modules/user/tests/src/Functional/UserPasswordResetTest.php \Drupal\Tests\user\Functional\UserPasswordResetTest::testUserResetPasswordTextboxFilled()
- 9 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 371
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']);
}