function UserLoginTest::resetUserPassword
Same name in other branches
- 10 core/modules/user/tests/src/Functional/UserLoginTest.php \Drupal\Tests\user\Functional\UserLoginTest::resetUserPassword()
- 11.x core/modules/user/tests/src/Functional/UserLoginTest.php \Drupal\Tests\user\Functional\UserLoginTest::resetUserPassword()
Reset user password.
Parameters
object $user: A user object.
2 calls to UserLoginTest::resetUserPassword()
- UserLoginTest::testGlobalLoginFloodControl in core/
modules/ user/ tests/ src/ Functional/ UserLoginTest.php - Tests the global login flood control.
- UserLoginTest::testPerUserLoginFloodControl in core/
modules/ user/ tests/ src/ Functional/ UserLoginTest.php - Tests the per-user login flood control.
File
-
core/
modules/ user/ tests/ src/ Functional/ UserLoginTest.php, line 328
Class
- UserLoginTest
- Ensure that login works as expected.
Namespace
Drupal\Tests\user\FunctionalCode
public function resetUserPassword($user) {
$this->drupalGet('user/password');
$edit['name'] = $user->getDisplayName();
$this->submitForm($edit, 'Submit');
$_emails = $this->drupalGetMails();
$email = end($_emails);
$urls = [];
preg_match('#.+user/reset/.+#', $email['body'], $urls);
$resetURL = $urls[0];
$this->drupalGet($resetURL);
$this->submitForm([], 'Log in');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.