<?php/**
* @file
* Definition of Drupal\user\Tests\UserEditedOwnAccountTest.
*/namespaceDrupal\user\Tests;
useDrupal\simpletest\WebTestBase;
/*
* Test that a user, having editing their own account, can still log in.
*/class UserEditedOwnAccountTestextends WebTestBase {
public static functiongetInfo() {
returnarray(
'name' => 'User edited own account',
'description' => 'Test user edited own account can still log in.',
'group' => 'User',
);
}
functiontestUserEditedOwnAccount() {
// Change account setting 'Who can register accounts?' to Administrators
// only.config('user.settings')
->set('register', USER_REGISTER_ADMINISTRATORS_ONLY)
->save();
// 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);
}
}