function UserPasswordResetTest::assertValidPasswordReset

Same name and namespace in other branches
  1. 9 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. 11.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.

3 calls to UserPasswordResetTest::assertValidPasswordReset()
UserPasswordResetTest::testUserPasswordReset in core/modules/user/tests/src/Functional/UserPasswordResetTest.php
Tests password reset functionality.
UserPasswordResetTest::testUserResetPasswordUserFloodControl in core/modules/user/tests/src/Functional/UserPasswordResetTest.php
Tests password reset flood control for one user.
UserPasswordResetTest::testUserResetPasswordUserFloodControlIsCleared in core/modules/user/tests/src/Functional/UserPasswordResetTest.php
Tests user password reset flood control is cleared on successful reset.

File

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

Class

UserPasswordResetTest
Ensure that password reset methods work as expected.

Namespace

Drupal\Tests\user\Functional

Code

public function assertValidPasswordReset($name) {
    // Make sure the error text is not displayed and email sent.
    $this->assertNoText(t('Sorry, @name is not recognized as a username or an e-mail address.', [
        '@name' => $name,
    ]), 'Validation error message shown when trying to request password for invalid account.');
    $this->assertMail('to', $this->account
        ->getEmail(), 'Password e-mail sent to user.');
    $subject = t('Replacement login information for @username at @site', [
        '@username' => $this->account
            ->getAccountName(),
        '@site' => \Drupal::config('system.site')->get('name'),
    ]);
    $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.