summaryrefslogtreecommitdiff
path: root/modules/user/user.test
diff options
context:
space:
mode:
Diffstat (limited to 'modules/user/user.test')
-rw-r--r--modules/user/user.test45
1 files changed, 45 insertions, 0 deletions
diff --git a/modules/user/user.test b/modules/user/user.test
index e66ab5e2c..a49a89b5c 100644
--- a/modules/user/user.test
+++ b/modules/user/user.test
@@ -2069,3 +2069,48 @@ class UserAuthmapAssignmentTestCase extends DrupalWebTestCase {
}
}
}
+
+/**
+ * Tests user_validate_current_pass on a custom form.
+ */
+class UserValidateCurrentPassCustomForm extends DrupalWebTestCase {
+
+ public static function getInfo() {
+ return array(
+ 'name' => 'User validate current pass custom form',
+ 'description' => 'Test that user_validate_current_pass is usable on a custom form.',
+ 'group' => 'User',
+ );
+ }
+
+ /**
+ * User with permission to view content.
+ */
+ protected $accessUser;
+
+ /**
+ * User permission to administer users.
+ */
+ protected $adminUser;
+
+ function setUp() {
+ parent::setUp('user_form_test');
+ // Create two users
+ $this->accessUser = $this->drupalCreateUser(array('access content'));
+ $this->adminUser = $this->drupalCreateUser(array('administer users'));
+ }
+
+ /**
+ * Tests that user_validate_current_pass can be reused on a custom form.
+ */
+ function testUserValidateCurrentPassCustomForm() {
+ $this->drupalLogin($this->adminUser);
+
+ // 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;
+ $this->drupalPost('user_form_test_current_password/' . $this->accessUser->uid, $edit, t('Test'));
+ $this->assertText(t('The password has been validated and the form submitted successfully.'));
+ }
+}