class UserEditedOwnAccountTest
Same name and namespace in other branches
- 11.x core/modules/user/tests/src/Functional/UserEditedOwnAccountTest.php \Drupal\Tests\user\Functional\UserEditedOwnAccountTest
- 10 core/modules/user/tests/src/Functional/UserEditedOwnAccountTest.php \Drupal\Tests\user\Functional\UserEditedOwnAccountTest
- 8.9.x core/modules/user/tests/src/Functional/UserEditedOwnAccountTest.php \Drupal\Tests\user\Functional\UserEditedOwnAccountTest
Tests user edited own account can still log in.
@group user
Hierarchy
- class \Drupal\Tests\BrowserTestBase uses \Drupal\Core\Test\FunctionalTestSetupTrait, \Drupal\Tests\UiHelperTrait, \Drupal\Core\Test\TestSetupTrait, \Drupal\Tests\block\Traits\BlockCreationTrait, \Drupal\FunctionalTests\AssertLegacyTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\node\Traits\NodeCreationTrait, \Drupal\Tests\node\Traits\ContentTypeCreationTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\user\Traits\UserCreationTrait, \Drupal\Tests\XdebugRequestTrait, \Drupal\Tests\Traits\PhpUnitWarnings, \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait, \Drupal\Tests\ExtensionListTestTrait implements \PHPUnit\Framework\TestCase
- class \Drupal\Tests\user\Functional\UserEditedOwnAccountTest implements \Drupal\Tests\BrowserTestBase
Expanded class hierarchy of UserEditedOwnAccountTest
File
-
core/
modules/ user/ tests/ src/ Functional/ UserEditedOwnAccountTest.php, line 13
Namespace
Drupal\Tests\user\FunctionalView source
class UserEditedOwnAccountTest extends BrowserTestBase {
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
public function testUserEditedOwnAccount() {
// Change account setting 'Who can register accounts?' to Administrators
// only.
$this->config('user.settings')
->set('register', UserInterface::REGISTER_ADMINISTRATORS_ONLY)
->save();
// Create a new user account and log in.
$account = $this->drupalCreateUser([
'change own username',
]);
$this->drupalLogin($account);
// Change own username.
$edit = [];
$edit['name'] = $this->randomMachineName();
$this->drupalGet('user/' . $account->id() . '/edit');
$this->submitForm($edit, 'Save');
// Log out.
$this->drupalLogout();
// Set the new name on the user account and attempt to log back in.
$account->name = $edit['name'];
$this->drupalLogin($account);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.