function MigrateUserAdminPassTest::setUp

Same name in other branches
  1. 8.9.x core/modules/user/tests/src/Kernel/Migrate/MigrateUserAdminPassTest.php \Drupal\Tests\user\Kernel\Migrate\MigrateUserAdminPassTest::setUp()
  2. 10 core/modules/user/tests/src/Kernel/Migrate/MigrateUserAdminPassTest.php \Drupal\Tests\user\Kernel\Migrate\MigrateUserAdminPassTest::setUp()
  3. 11.x core/modules/user/tests/src/Kernel/Migrate/MigrateUserAdminPassTest.php \Drupal\Tests\user\Kernel\Migrate\MigrateUserAdminPassTest::setUp()

Overrides MigrateTestBase::setUp

File

core/modules/user/tests/src/Kernel/Migrate/MigrateUserAdminPassTest.php, line 32

Class

MigrateUserAdminPassTest
Tests preservation of root account password.

Namespace

Drupal\Tests\user\Kernel\Migrate

Code

protected function setUp() : void {
    parent::setUp();
    // Make sure the admin user and a regular user are created.
    $this->container
        ->get('module_handler')
        ->loadInclude('user', 'install');
    $this->installEntitySchema('user');
    user_install();
    
    /** @var \Drupal\user\Entity\User $admin_account */
    $admin_account = User::load(1);
    $admin_account->setPassword('original');
    $admin_account->save();
    $this->originalPasswords[1] = $admin_account->getPassword();
    
    /** @var \Drupal\user\Entity\User $user_account */
    $user_account = User::create([
        'uid' => 2,
        'name' => 'original_username',
        'mail' => 'original_email@example.com',
        'pass' => 'original_password',
    ]);
    $user_account->save();
    $this->originalPasswords[2] = $user_account->getPassword();
}

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