function UserPasswordResetTest::assertValidPasswordReset

Same name and namespace in other branches
  1. 11.x core/modules/user/tests/src/Functional/UserPasswordResetTest.php \Drupal\Tests\user\Functional\UserPasswordResetTest::assertValidPasswordReset()
  2. 10 core/modules/user/tests/src/Functional/UserPasswordResetTest.php \Drupal\Tests\user\Functional\UserPasswordResetTest::assertValidPasswordReset()
  3. 8.9.x core/modules/user/tests/src/Functional/UserPasswordResetTest.php \Drupal\Tests\user\Functional\UserPasswordResetTest::assertValidPasswordReset()

Helper function to make assertions about a valid password reset.

@internal

File

core/modules/user/tests/src/Functional/UserPasswordResetTest.php, line 497

Class

UserPasswordResetTest
Ensure that password reset methods work as expected.

Namespace

Drupal\Tests\user\Functional

Code

public function assertValidPasswordReset(string $name) : void {
  $this->assertSession()
    ->pageTextContains("If {$name} is a valid account, an email will be sent with instructions to reset your password.");
  $this->assertMail('to', $this->account
    ->getEmail(), 'Password e-mail sent to user.');
  $subject = 'Replacement login information for ' . $this->account
    ->getAccountName() . ' at Drupal';
  $this->assertMail('subject', $subject, 'Password reset e-mail subject is correct.');
}

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