function UpdatePathTestBase::replaceUser1

Replace User 1 with the user created here.

1 call to UpdatePathTestBase::replaceUser1()
UpdatePathTestBase::installDrupal in core/tests/Drupal/FunctionalTests/Update/UpdatePathTestBase.php
Overrides BrowserTestBase::installDrupal() for update testing.
1 method overrides UpdatePathTestBase::replaceUser1()
UpdatePathTestBaseFilledTest::replaceUser1 in core/modules/system/tests/src/Functional/UpdateSystem/UpdatePathTestBaseFilledTest.php
Replace User 1 with the user created here.

File

core/tests/Drupal/FunctionalTests/Update/UpdatePathTestBase.php, line 236

Class

UpdatePathTestBase
Provides a base class for writing an update test.

Namespace

Drupal\FunctionalTests\Update

Code

protected function replaceUser1() {
  // We try not to save content entities in hook_update_N() because the schema
  // might be out of sync, or hook invocations might rely on other schemas
  // that also aren't updated yet. Hence we are directly updating the database
  // tables with the values.
  Database::getConnection()->update('users_field_data')
    ->fields([
    'name' => $this->rootUser
      ->getAccountName(),
    'pass' => \Drupal::service('password')->hash($this->rootUser->pass_raw),
    'mail' => $this->rootUser
      ->getEmail(),
  ])
    ->condition('uid', 1)
    ->execute();
}

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