You are here

public function UserPasswordResetTest::assertNoValidPasswordReset in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/user/tests/src/Functional/UserPasswordResetTest.php \Drupal\Tests\user\Functional\UserPasswordResetTest::assertNoValidPasswordReset()

Helper function to make assertions about an invalid password reset.

Parameters

string $name:

2 calls to UserPasswordResetTest::assertNoValidPasswordReset()
UserPasswordResetTest::testUserPasswordReset in core/modules/user/tests/src/Functional/UserPasswordResetTest.php
Tests password reset functionality.
UserPasswordResetTest::testUserResetPasswordIpFloodControl in core/modules/user/tests/src/Functional/UserPasswordResetTest.php
Tests password reset flood control for one IP.

File

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

Class

UserPasswordResetTest
Ensure that password reset methods work as expected.

Namespace

Drupal\Tests\user\Functional

Code

public function assertNoValidPasswordReset($name) {

  // This message is the same as the valid reset for privacy reasons.
  $this
    ->assertSession()
    ->pageTextContains("If {$name} is a valid account, an email will be sent with instructions to reset your password.");

  // The difference is that no email is sent.
  $this
    ->assertCount(0, $this
    ->drupalGetMails([
    'id' => 'user_password_reset',
  ]), 'No e-mail was sent when requesting a password for an invalid account.');
}