trait UserResetEmailTestTrait in Drupal 8
Helper function for logging in from reset password email.
Hierarchy
- trait \Drupal\user\Tests\UserResetEmailTestTrait uses AssertMailTrait
Deprecated
in drupal:8.?.? and is removed from drupal:9.0.0. Add the method to the test class instead.
See also
https://www.drupal.org/node/2999766
File
- core/
modules/ user/ src/ Tests/ UserResetEmailTestTrait.php, line 17
Namespace
Drupal\user\TestsView source
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');
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
AssertMailTrait:: |
protected | function | Asserts that the most recently sent email message has the given value. | |
AssertMailTrait:: |
protected | function | Asserts that the most recently sent email message has the pattern in it. | |
AssertMailTrait:: |
protected | function | Asserts that the most recently sent email message has the string in it. | |
AssertMailTrait:: |
protected | function | Gets an array containing all emails sent during this test case. Aliased as: drupalGetMails | |
AssertMailTrait:: |
protected | function | Outputs to verbose the most recent $count emails sent. | |
UserResetEmailTestTrait:: |
protected | function | Login from reset password email. |