public function UserAuthTest::testAuthenticateWithZeroPassword in Drupal 9
Same name and namespace in other branches
- 8 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 173
Class
- UserAuthTest
- @coversDefaultClass \Drupal\user\UserAuth @group user
Namespace
Drupal\Tests\user\UnitCode
public function testAuthenticateWithZeroPassword() {
$this->testUser
->expects($this
->once())
->method('id')
->will($this
->returnValue(2));
$this->userStorage
->expects($this
->once())
->method('loadByProperties')
->with([
'name' => $this->username,
])
->will($this
->returnValue([
$this->testUser,
]));
$this->passwordService
->expects($this
->once())
->method('check')
->with(0, 0)
->will($this
->returnValue(TRUE));
$this
->assertSame(2, $this->userAuth
->authenticate($this->username, 0));
}