Mercurial > hg > cmmr2012-drupal-site
annotate core/modules/user/src/Tests/UserResetEmailTestTrait.php @ 5:12f9dff5fda9 tip
Update to Drupal core 8.7.1
author | Chris Cannam |
---|---|
date | Thu, 09 May 2019 15:34:47 +0100 |
parents | a9cd425dd02b |
children |
rev | line source |
---|---|
Chris@0 | 1 <?php |
Chris@0 | 2 |
Chris@0 | 3 namespace Drupal\user\Tests; |
Chris@0 | 4 |
Chris@4 | 5 @trigger_error(__NAMESPACE__ . '\UserResetEmailTestTrait is deprecated and scheduled for removal before Drupal 9.0.0. Add the method to the test class instead, see https://www.drupal.org/node/2999766', E_USER_DEPRECATED); |
Chris@4 | 6 |
Chris@0 | 7 use Drupal\Core\Test\AssertMailTrait; |
Chris@0 | 8 |
Chris@0 | 9 /** |
Chris@0 | 10 * Helper function for logging in from reset password email. |
Chris@4 | 11 * |
Chris@4 | 12 * @deprecated Scheduled for removal before Drupal 9.0.0. |
Chris@4 | 13 * Add the method to the test class instead. |
Chris@4 | 14 * |
Chris@4 | 15 * @see https://www.drupal.org/node/2999766 |
Chris@0 | 16 */ |
Chris@0 | 17 trait UserResetEmailTestTrait { |
Chris@0 | 18 |
Chris@0 | 19 use AssertMailTrait { |
Chris@0 | 20 getMails as drupalGetMails; |
Chris@0 | 21 } |
Chris@0 | 22 |
Chris@0 | 23 /** |
Chris@0 | 24 * Login from reset password email. |
Chris@0 | 25 */ |
Chris@0 | 26 protected function loginFromResetEmail() { |
Chris@0 | 27 $_emails = $this->drupalGetMails(); |
Chris@0 | 28 $email = end($_emails); |
Chris@0 | 29 $urls = []; |
Chris@0 | 30 preg_match('#.+user/reset/.+#', $email['body'], $urls); |
Chris@0 | 31 $resetURL = $urls[0]; |
Chris@0 | 32 $this->drupalGet($resetURL); |
Chris@0 | 33 $this->drupalPostForm(NULL, NULL, 'Log in'); |
Chris@0 | 34 } |
Chris@0 | 35 |
Chris@0 | 36 } |