function UserAuthenticationTest::testAuthenticateWithCorrectPassword
Tests the authenticate method with a correct password.
File
-
core/
modules/ user/ tests/ src/ Unit/ UserAuthenticationTest.php, line 130
Class
Namespace
Drupal\Tests\user\UnitCode
public function testAuthenticateWithCorrectPassword() : void {
$testUser = $this->createPartialMock(User::class, [
'id',
'getPassword',
]);
$this->userStorage
->expects($this->once())
->method('loadByProperties')
->with([
'name' => $this->username,
])
->willReturn([
$testUser,
]);
$this->passwordService
->method('check')
->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.