function UserEditedOwnAccountTestCase::testUserEditedOwnAccount

File

modules/user/user.test, line 2426

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);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.