function UserEntityTest::testPasswordProperty

Tests that accessing the password property is correctly deprecated.

Attributes

#[IgnoreDeprecations]

File

core/modules/user/tests/src/Kernel/UserEntityTest.php, line 115

Class

UserEntityTest
Tests the user entity class.

Namespace

Drupal\Tests\user\Kernel

Code

public function testPasswordProperty() : void {
  /** @var \Drupal\user\Entity\User $user */
  $user = User::create([
    'name' => $this->randomMachineName(),
  ]);
  $user->password = 'password';
  $this->expectDeprecation('Getting the password property is deprecated in drupal:11.4.0 and is removed from drupal:12.0.0. See https://www.drupal.org/node/3569185');
  $this->assertEquals('password', $user->password);
}

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