Chris@0: config('user.settings')->set('register', UserInterface::REGISTER_ADMINISTRATORS_ONLY)->save(); Chris@0: Chris@0: // Create a new user account and log in. Chris@0: $account = $this->drupalCreateUser(['change own username']); Chris@0: $this->drupalLogin($account); Chris@0: Chris@0: // Change own username. Chris@0: $edit = []; Chris@0: $edit['name'] = $this->randomMachineName(); Chris@0: $this->drupalPostForm('user/' . $account->id() . '/edit', $edit, t('Save')); Chris@0: Chris@0: // Log out. Chris@0: $this->drupalLogout(); Chris@0: Chris@0: // Set the new name on the user account and attempt to log back in. Chris@0: $account->name = $edit['name']; Chris@0: $this->drupalLogin($account); Chris@0: } Chris@0: Chris@0: }