3 namespace Drupal\Tests\user\Functional;
5 use Drupal\Tests\BrowserTestBase;
8 * Tests user edited own account can still log in.
12 class UserEditedOwnAccountTest extends BrowserTestBase {
19 public static $modules = ['user_form_test'];
21 public function testUserEditedOwnAccount() {
22 // Change account setting 'Who can register accounts?' to Administrators
24 $this->config('user.settings')->set('register', USER_REGISTER_ADMINISTRATORS_ONLY)->save();
26 // Create a new user account and log in.
27 $account = $this->drupalCreateUser(['change own username']);
28 $this->drupalLogin($account);
30 // Change own username.
32 $edit['name'] = $this->randomMachineName();
33 $this->drupalPostForm('user/' . $account->id() . '/edit', $edit, t('Save'));
36 $this->drupalLogout();
38 // Set the new name on the user account and attempt to log back in.
39 $account->name = $edit['name'];
40 $this->drupalLogin($account);