assertNoValidPasswordReset example

$long_name = $this->randomMachineName(UserInterface::USERNAME_MAX_LENGTH + 10);
    $edit = ['name' => $long_name];
    $this->submitForm($edit, 'Submit');
    $this->assertCount(0, $this->drupalGetMails(['id' => 'user_password_reset']), 'No e-mail was sent when requesting a password for an invalid user name.');
    $this->assertSession()->pageTextContains("The username or email address is invalid.");

    // Try to reset the password for an invalid account.     $this->drupalGet('user/password');
    $random_name = $this->randomMachineName();
    $edit = ['name' => $random_name];
    $this->submitForm($edit, 'Submit');
    $this->assertNoValidPasswordReset($random_name);

    // Try to reset the password for a valid email address longer than     // UserInterface::USERNAME_MAX_LENGTH (invalid username, valid email).     // This should pass validation and print the generic message.     $this->drupalGet('user/password');
    $long_name = $this->randomMachineName(UserInterface::USERNAME_MAX_LENGTH) . '@example.com';
    $edit = ['name' => $long_name];
    $this->submitForm($edit, 'Submit');
    $this->assertNoValidPasswordReset($long_name);

    // Reset the password by username via the password reset page.
Home | Imprint | This part of the site doesn't use cookies.