function UserAuthTest::testAuthenticateWithZeroPassword
Same name in other branches
- 9 core/modules/user/tests/src/Unit/UserAuthTest.php \Drupal\Tests\user\Unit\UserAuthTest::testAuthenticateWithZeroPassword()
- 8.9.x core/modules/user/tests/src/Unit/UserAuthTest.php \Drupal\Tests\user\Unit\UserAuthTest::testAuthenticateWithZeroPassword()
- 11.x core/modules/user/tests/src/Unit/UserAuthTest.php \Drupal\Tests\user\Unit\UserAuthTest::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.
@covers ::authenticate
File
-
core/
modules/ user/ tests/ src/ Unit/ UserAuthTest.php, line 185
Class
- UserAuthTest
- @coversDefaultClass \Drupal\user\UserAuth @group user
Namespace
Drupal\Tests\user\UnitCode
public function testAuthenticateWithZeroPassword() : void {
$this->testUser
->expects($this->once())
->method('id')
->willReturn(2);
$this->userStorage
->expects($this->once())
->method('loadByProperties')
->with([
'name' => $this->username,
])
->willReturn([
$this->testUser,
]);
$this->passwordService
->expects($this->once())
->method('check')
->with(0, 0)
->willReturn(TRUE);
$this->assertSame(2, $this->userAuth
->authenticate($this->username, 0));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.