function 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.
@legacy-covers ::authenticate
File
- 
              core/
modules/ user/ tests/ src/ Unit/ UserAuthTest.php, line 189  
Class
- UserAuthTest
 - Tests Drupal\user\UserAuth.
 
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.