function PasswordVerifyTest::testPasswordHash
Tests that hash() is forwarded to corePassword instance.
@covers ::hash
      
    
File
- 
              core/
modules/ phpass/ tests/ src/ Unit/ PasswordVerifyTest.php, line 25  
Class
- PasswordVerifyTest
 - Unit tests for password hashing API.
 
Namespace
Drupal\Tests\phpass\UnitCode
public function testPasswordHash() : void {
  $samplePassword = $this->randomMachineName();
  $sampleHash = $this->randomMachineName();
  $corePassword = $this->prophesize(PasswordInterface::class);
  $corePassword->hash($samplePassword)
    ->willReturn($sampleHash);
  $passwordService = new PhpassHashedPassword($corePassword->reveal());
  $result = $passwordService->hash($samplePassword);
  $this->assertSame($sampleHash, $result, 'Calls to hash() are forwarded to core password service.');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.