function UpdatePathTestBase::replaceUser1

Same name in this branch
  1. 8.9.x core/tests/Drupal/FunctionalTests/Update/UpdatePathTestBase.php \Drupal\FunctionalTests\Update\UpdatePathTestBase::replaceUser1()
Same name in other branches
  1. 9 core/tests/Drupal/FunctionalTests/Update/UpdatePathTestBase.php \Drupal\FunctionalTests\Update\UpdatePathTestBase::replaceUser1()
  2. 10 core/tests/Drupal/FunctionalTests/Update/UpdatePathTestBase.php \Drupal\FunctionalTests\Update\UpdatePathTestBase::replaceUser1()
  3. 11.x core/tests/Drupal/FunctionalTests/Update/UpdatePathTestBase.php \Drupal\FunctionalTests\Update\UpdatePathTestBase::replaceUser1()

Replace User 1 with the user created here.

1 call to UpdatePathTestBase::replaceUser1()
UpdatePathTestBase::setUp in core/modules/system/src/Tests/Update/UpdatePathTestBase.php
Overrides WebTestBase::setUp() for update testing.

File

core/modules/system/src/Tests/Update/UpdatePathTestBase.php, line 338

Class

UpdatePathTestBase
Provides a base class for writing an update test.

Namespace

Drupal\system\Tests\Update

Code

protected function replaceUser1() {
    
    /** @var \Drupal\user\UserInterface $account */
    // @todo: Saving the account before the update is problematic.
    //   https://www.drupal.org/node/2560237
    $account = User::load(1);
    $account->setPassword($this->rootUser->pass_raw);
    $account->setEmail($this->rootUser
        ->getEmail());
    $account->setUsername($this->rootUser
        ->getAccountName());
    $account->save();
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.