function UserResetEmailTestTrait::loginFromResetEmail

Login from reset password email.

File

core/modules/user/src/Tests/UserResetEmailTestTrait.php, line 26

Class

UserResetEmailTestTrait
Helper function for logging in from reset password email.

Namespace

Drupal\user\Tests

Code

protected function loginFromResetEmail() {
    $_emails = $this->drupalGetMails();
    $email = end($_emails);
    $urls = [];
    preg_match('#.+user/reset/.+#', $email['body'], $urls);
    $resetURL = $urls[0];
    $this->drupalGet($resetURL);
    $this->drupalPostForm(NULL, NULL, 'Log in');
}

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