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 {
14 public function testUserEditedOwnAccount() {
15 // Change account setting 'Who can register accounts?' to Administrators
17 $this->config('user.settings')->set('register', USER_REGISTER_ADMINISTRATORS_ONLY)->save();
19 // Create a new user account and log in.
20 $account = $this->drupalCreateUser(['change own username']);
21 $this->drupalLogin($account);
23 // Change own username.
25 $edit['name'] = $this->randomMachineName();
26 $this->drupalPostForm('user/' . $account->id() . '/edit', $edit, t('Save'));
29 $this->drupalLogout();
31 // Set the new name on the user account and attempt to log back in.
32 $account->name = $edit['name'];
33 $this->drupalLogin($account);