Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / web / core / modules / user / tests / src / Functional / UserEditedOwnAccountTest.php
1 <?php
2
3 namespace Drupal\Tests\user\Functional;
4
5 use Drupal\Tests\BrowserTestBase;
6
7 /**
8  * Tests user edited own account can still log in.
9  *
10  * @group user
11  */
12 class UserEditedOwnAccountTest extends BrowserTestBase {
13
14   public function testUserEditedOwnAccount() {
15     // Change account setting 'Who can register accounts?' to Administrators
16     // only.
17     $this->config('user.settings')->set('register', USER_REGISTER_ADMINISTRATORS_ONLY)->save();
18
19     // Create a new user account and log in.
20     $account = $this->drupalCreateUser(['change own username']);
21     $this->drupalLogin($account);
22
23     // Change own username.
24     $edit = [];
25     $edit['name'] = $this->randomMachineName();
26     $this->drupalPostForm('user/' . $account->id() . '/edit', $edit, t('Save'));
27
28     // Log out.
29     $this->drupalLogout();
30
31     // Set the new name on the user account and attempt to log back in.
32     $account->name = $edit['name'];
33     $this->drupalLogin($account);
34   }
35
36 }