Error message

You are browsing documentation for drupal 7.x, which is not supported anymore. Read the updated version of this page for drupal 11.x (the latest version).

function UserEditedOwnAccountTestCase::testUserEditedOwnAccount

File

modules/user/user.test, line 2532

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.