You are here

protected function ThunderTestTrait::replaceUser1 in Thunder 6.2.x

Same name and namespace in other branches
  1. 8.5 tests/src/Traits/ThunderTestTrait.php \Drupal\Tests\thunder\Traits\ThunderTestTrait::replaceUser1()
  2. 8.4 tests/src/Traits/ThunderTestTrait.php \Drupal\Tests\thunder\Traits\ThunderTestTrait::replaceUser1()
  3. 6.0.x tests/src/Traits/ThunderTestTrait.php \Drupal\Tests\thunder\Traits\ThunderTestTrait::replaceUser1()
  4. 6.1.x tests/src/Traits/ThunderTestTrait.php \Drupal\Tests\thunder\Traits\ThunderTestTrait::replaceUser1()

Replace User 1 with the user created here.

1 call to ThunderTestTrait::replaceUser1()
ThunderTestTrait::installDrupal in tests/src/Traits/ThunderTestTrait.php

File

tests/src/Traits/ThunderTestTrait.php, line 61

Class

ThunderTestTrait
Use this trait to reuse an existing database.

Namespace

Drupal\Tests\thunder\Traits

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();
}