protected function UserProtectWebTestBase::assertUserCanChangePass in User protect 7
Asserts that a account's password can be changed.
Parameters
object $account: The account to change the password for.
string $message: (optional) The message to assert.
File
- tests/
UserProtectWebTestBase.test, line 335 - Contains \UserProtectWebTestBase.
Class
- UserProtectWebTestBase
- Base class for User protect web tests.
Code
protected function assertUserCanChangePass($account, $message = NULL) {
if (!is_null($message)) {
$message = "The user's password can be changed.";
}
$new_pass = $this
->randomName();
$edit = array(
'current_pass' => $account->pass_raw,
'pass[pass1]' => $new_pass,
'pass[pass2]' => $new_pass,
);
$this
->drupalPost('user/' . $account->uid . '/edit', $edit, t('Save'));
// Assert the password changed.
$account = user_load($account->uid, TRUE);
$account->pass_raw = $new_pass;
$this
->drupalLogout();
$this
->drupalLogin($account);
}