function UserLoginTestCase::resetUserPassword

Resets the user password and logs the user in.

Parameters

object $user: The account to reset the password for.

2 calls to UserLoginTestCase::resetUserPassword()
UserLoginTestCase::testGlobalLoginFloodControl in modules/user/user.test
Test the global login flood control.
UserLoginTestCase::testPerUserLoginFloodControl in modules/user/user.test
Test the per-user login flood control.

File

modules/user/user.test, line 504

Class

UserLoginTestCase
Functional tests for user logins, including rate limiting of login attempts.

Code

protected function resetUserPassword($user) {
  $this->drupalGet('user/password');
  $edit['name'] = $user->name;
  $this->drupalPost(NULL, $edit, 'E-mail new password');
  $emails = $this->drupalGetMails();
  $email = end($emails);
  $urls = array();
  preg_match('#.+user/reset/.+#', $email['body'], $urls);
  $resetURL = $urls[0];
  $this->drupalGet($resetURL);
  $this->drupalPost(NULL, NULL, 'Log in');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.