Index: modules/user/user.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/user/user.test,v
retrieving revision 1.22
diff -u -p -r1.22 user.test
--- modules/user/user.test	25 Nov 2008 13:14:29 -0000	1.22
+++ modules/user/user.test	15 Jan 2009 13:38:29 -0000
@@ -509,6 +509,81 @@ class UserAdminTestCase extends DrupalWe
   }
 }
 
+class UserEditTestCase extends DrupalWebTestCase {
+  function getInfo() {
+    return array(
+      'name' => t('User edit'),
+      'description' => t('Test editing a user (with malicious values and without).'),
+      'group' => t('User')
+    );
+  }
+
+  function setUp() {
+    parent::setUp();
+  }
+
+  /**
+   * Edits a user.
+   */
+  function testUserEdit() {
+    $this->user = $this->drupalCreateUser(array());
+    $user = $this->user;
+    $this->drupalLogin($user);
+    
+    // Edit a user correctly.
+    $edit = array(
+      'mail' => $user->mail,
+      'pass[pass1]' => $user->pass_raw,
+      'pass[pass2]' => $user->pass_raw,
+    );
+    $this->DrupalPost('user/' . $user->uid . '/edit', $edit, 'Save');
+    
+    // Check if there where no errors.
+    $this->assertText(t('The changes have been saved.'), t('Successful save message displayed.'));
+    $this->assertNoRaw('<div class="messages error">', t('No error message displayed.'));
+    
+    // Edit a user using a wrong password.
+    $edit = array(
+      'mail' => $user->mail,
+      'pass[pass1]' => $user->pass_raw,
+      'pass[pass2]' => $this->randomName(8),
+    );
+    $this->DrupalPost('user/' . $user->uid . '/edit', $edit, 'Save');
+    
+    // Check if it gives an error because we used a wrong password.
+    $this->assertNoText(t('The changes have been saved.'), t('No successful save message displayed.'));
+    $this->assertRaw(t('The specified passwords do not match.'), t('Error message displayed.'));
+    
+    // Edit a user using a wrong email.
+    $edit = array(
+      'mail' => 'wrong-email.example.com',
+      'pass[pass1]' => $user->pass_raw,
+      'pass[pass2]' => $user->pass_raw,
+    );
+    $this->DrupalPost('user/' . $user->uid . '/edit', $edit, 'Save');
+    
+    // Check if it gives an error because we used a wrong email.
+    $this->assertNoText(t('The changes have been saved.'), t('No successful save message displayed.'));
+    $this->assertRaw(t('The e-mail address %mail is not valid.', array('%mail' => 'wrong-email.example.com')), t('Error message displayed.'));
+    
+    // Edit a user with rights to edit his/her username.
+    $this->user = $this->drupalCreateUser(array('change own username'));
+    $user = $this->user;
+    $this->drupalLogin($user);
+    
+    $edit = array(
+      'name' => $user->name,
+      'mail' => $user->mail,
+      'pass[pass1]' => $user->pass_raw,
+      'pass[pass2]' => $user->pass_raw,
+    );
+    $this->DrupalPost('user/' . $user->uid . '/edit', $edit, 'Save');
+    
+    // Check if there where no errors.
+    $this->assertText(t('The changes have been saved.'), t('Successful save message displayed.'));
+  }
+}
+
 /**
  * Tests for user-configurable time zones.
  */
@@ -671,4 +746,4 @@ class UserBlocksUnitTests extends Drupal
       ->execute();
     $this->assertEqual(db_query("SELECT COUNT(*) FROM {sessions} WHERE uid = :uid AND sid = :sid AND timestamp = :timestamp", array(':uid' => $fields['uid'], ':sid' => $fields['sid'], ':timestamp' => $fields['timestamp']))->fetchField(), 1, t('Session record inserted.'));
   }
-}
+}
\ No newline at end of file
