function UserAuthenticationTest::testAuthenticateWithZeroPassword
Tests the authenticate method with a correct password.
We discovered in https://www.drupal.org/node/2563751 that logging in with a password that is literally "0" was not possible. This test ensures that this regression can't happen again.
File
-
core/
modules/ user/ tests/ src/ Unit/ UserAuthenticationTest.php, line 151
Class
Namespace
Drupal\Tests\user\UnitCode
public function testAuthenticateWithZeroPassword() : 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')
->with('0', 0)
->willReturn(TRUE);
$user = $this->userAuth
->lookupAccount($this->username);
$this->assertTrue($this->userAuth
->authenticateAccount($user, '0'));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.