function UserEditedOwnAccountTestCase::testUserEditedOwnAccount

You are here

7 user.test UserEditedOwnAccountTestCase::testUserEditedOwnAccount()

File

modules/user/user.test, line 1949
Tests for user.module.

Class

UserEditedOwnAccountTestCase

Code

function testUserEditedOwnAccount() {
  // Change account setting 'Who can register accounts?' to Administrators
  // only.
  variable_set('user_register', USER_REGISTER_ADMINISTRATORS_ONLY);

  // Create a new user account and log in.
  $account = $this->drupalCreateUser(array('change own username'));
  $this->drupalLogin($account);

  // Change own username.
  $edit = array();
  $edit['name'] = $this->randomName();
  $this->drupalPost('user/' . $account->uid . '/edit', $edit, t('Save'));

  // Log out.
  $this->drupalLogout();

  // Set the new name on the user account and attempt to log back in.
  $account->name = $edit['name'];
  $this->drupalLogin($account);
}