You are here

function UserEditedOwnAccountTestCase::testUserEditedOwnAccount in Drupal 7

File

modules/user/user.test, line 2380
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);
}