Upgraded drupal core with security updates
[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   /**
15    * Modules to enable.
16    *
17    * @var array
18    */
19   public static $modules = ['user_form_test'];
20
21   public function testUserEditedOwnAccount() {
22     // Change account setting 'Who can register accounts?' to Administrators
23     // only.
24     $this->config('user.settings')->set('register', USER_REGISTER_ADMINISTRATORS_ONLY)->save();
25
26     // Create a new user account and log in.
27     $account = $this->drupalCreateUser(['change own username']);
28     $this->drupalLogin($account);
29
30     // Change own username.
31     $edit = [];
32     $edit['name'] = $this->randomMachineName();
33     $this->drupalPostForm('user/' . $account->id() . '/edit', $edit, t('Save'));
34
35     // Log out.
36     $this->drupalLogout();
37
38     // Set the new name on the user account and attempt to log back in.
39     $account->name = $edit['name'];
40     $this->drupalLogin($account);
41   }
42
43 }