Mercurial > hg > isophonics-drupal-site
diff core/modules/user/src/Tests/UserResetEmailTestTrait.php @ 0:4c8ae668cc8c
Initial import (non-working)
author | Chris Cannam |
---|---|
date | Wed, 29 Nov 2017 16:09:58 +0000 |
parents | |
children | 129ea1e6d783 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/core/modules/user/src/Tests/UserResetEmailTestTrait.php Wed Nov 29 16:09:58 2017 +0000 @@ -0,0 +1,29 @@ +<?php + +namespace Drupal\user\Tests; + +use Drupal\Core\Test\AssertMailTrait; + +/** + * Helper function for logging in from reset password email. + */ +trait UserResetEmailTestTrait { + + use AssertMailTrait { + getMails as drupalGetMails; + } + + /** + * Login from reset password email. + */ + 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'); + } + +}