diff -u b/core/modules/user/tests/src/Functional/UserLoginTest.php b/core/modules/user/tests/src/Functional/UserLoginTest.php --- b/core/modules/user/tests/src/Functional/UserLoginTest.php +++ b/core/modules/user/tests/src/Functional/UserLoginTest.php @@ -5,6 +5,7 @@ use Drupal\Core\Url; use Drupal\Tests\BrowserTestBase; use Drupal\user\Entity\User; +use Drupal\user\UserInterface; /** * Ensure that login works as expected. @@ -120,10 +121,10 @@ * Tests user password is re-hashed upon login after changing $count_log2. */ public function testPasswordRehashOnLogin() { - // Determine default log2 for phpass hashing algorithm + // Determine default log2 for phpass hashing algorithm. $default_count_log2 = 16; - // Retrieve instance of password hashing algorithm + // Retrieve instance of password hashing algorithm. $password_hasher = $this->container->get('password'); // Create a new user and authenticate. @@ -176,8 +177,18 @@ /** * Helper to test log in with a maximum length password. + * + * @param \Drupal\user\UserInterface $account + * An object containing the user account. + * @param string $current_password + * The current password associated with the user. + * @param int $length + * The length of the password. + * + * @return string + * The new password associated with the user. */ - public function doPasswordLengthLogin($account, $current_password, $length) { + public function doPasswordLengthLogin(UserInterface $account, string $current_password, int $length) { $new_password = \Drupal::service('password_generator')->generate($length); $uid = $account->id(); $edit = [ @@ -189,16 +200,17 @@ // Change the password. $this->drupalGet("user/$uid/edit"); - $this->drupalPostForm(NULL, $edit, 'Save'); - $this->assertSession()->responseContains('The changes have been saved.'); + $this->submitForm($edit, 'Save'); + $this->assertSession()->pageTextContains('The changes have been saved.'); $this->drupalLogout(); // Login with new password. + $this->drupalGet('user/login'); $edit = [ 'name' => $account->getAccountName(), 'pass' => $new_password, ]; - $this->drupalPostForm('user/login', $edit, 'Log in'); + $this->submitForm($edit, 'Log in'); return $new_password; }