annotate core/modules/user/src/Tests/UserResetEmailTestTrait.php @ 19:fa3358dc1485 tip

Add ndrum files
author Chris Cannam
date Wed, 28 Aug 2019 13:14:47 +0100
parents 129ea1e6d783
children
rev   line source
Chris@0 1 <?php
Chris@0 2
Chris@0 3 namespace Drupal\user\Tests;
Chris@0 4
Chris@17 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@17 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@17 11 *
Chris@17 12 * @deprecated Scheduled for removal before Drupal 9.0.0.
Chris@17 13 * Add the method to the test class instead.
Chris@17 14 *
Chris@17 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 }