1 user.test | UserValidateCurrentPassCustomForm::testUserValidateCurrentPassCustomForm() |
Tests that user_validate_current_pass can be reused on a custom form.
File
- core/
modules/ user/ tests/ user.test, line 2801 - Tests for user.module.
Class
- UserValidateCurrentPassCustomForm
- Tests user_validate_current_pass on a custom form.
Code
function testUserValidateCurrentPassCustomForm() {
$this->backdropLogin($this->adminUser);
// Check that filling out a single password field does not validate.
$edit = array();
$edit['password_confirm[pass1]'] = '';
$edit['password_confirm[pass2]'] = $this->randomName();
$this->backdropPost('user_form_test_current_password/' . $this->accessUser->uid, $edit, t('Test'));
$this->assertText(t("The specified passwords do not match."), 'Typing mismatched passwords displays an error message.');
$edit['password_confirm[pass1]'] = $new_pass = $this->randomName();
$edit['password_confirm[pass2]'] = '';
$this->backdropPost('user_form_test_current_password/' . $this->accessUser->uid, $edit, t('Test'));
$this->assertText(t("The specified passwords do not match."), 'Typing mismatched passwords displays an error message.');
// Submit the custom form with the admin user using the access user's password.
$edit = array();
$edit['user_form_test_field'] = $this->accessUser->name;
$edit['current_pass'] = $this->accessUser->pass_raw;
$edit['password_confirm[pass1]'] = $new_pass;
$edit['password_confirm[pass2]'] = $new_pass;
$this->backdropPost('user_form_test_current_password/' . $this->accessUser->uid, $edit, t('Test'));
$this->assertText(t('The password has been validated and the form submitted successfully.'));
}