function UserAuthenticationTest::testAuthenticateWithCorrectPasswordAndNewPasswordHash
Tests the authenticate method with a correct password & new password hash.
File
-
core/
modules/ user/ tests/ src/ Unit/ UserAuthenticationTest.php, line 171
Class
Namespace
Drupal\Tests\user\UnitCode
public function testAuthenticateWithCorrectPasswordAndNewPasswordHash() : void {
$testUser = $this->createPartialMock(User::class, [
'id',
'setPassword',
'save',
'getPassword',
]);
$testUser->expects($this->once())
->method('setPassword')
->with($this->password);
$testUser->expects($this->once())
->method('save');
$this->userStorage
->expects($this->once())
->method('loadByProperties')
->with([
'name' => $this->username,
])
->willReturn([
$testUser,
]);
$this->passwordService
->method('check')
->willReturn(TRUE);
$this->passwordService
->method('needsRehash')
->willReturn(TRUE);
$user = $this->userAuth
->lookupAccount($this->username);
$this->assertTrue($this->userAuth
->authenticateAccount($user, $this->password));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.