// Create a new user and authenticate.
$account =
$this->
drupalCreateUser([]);
$password =
$account->passRaw;
$this->
drupalLogin($account);
$this->
drupalLogout();
// Load the stored user. The password hash shouldn't need a rehash.
$user_storage =
$this->container->
get('entity_type.manager'
)->
getStorage('user'
);
$account = User::
load($account->
id());
// Check that the stored password doesn't need rehash.
$this->
assertFalse($password_hasher->
needsRehash($account->
getPassword()));
// The current hashing cost is set to 10 in the container. Increase cost by
// one, by enabling a module containing the necessary container changes.
\Drupal::
service('module_installer'
)->
install(['user_custom_pass_hash_params_test'
]);
$this->
resetAll();
// Reload the hashing service after container changes.
$password_hasher =
$this->container->
get('password'
);
// Check that the stored password does need rehash.
$this->
assertTrue($password_hasher->
needsRehash($account->
getPassword()));