function PasswordVerifyTest::testPasswordHash

Tests that hash() is forwarded to corePassword instance.

@legacy-covers ::hash

File

core/modules/phpass/tests/src/Unit/PasswordVerifyTest.php, line 28

Class

PasswordVerifyTest
Unit tests for password hashing API.

Namespace

Drupal\Tests\phpass\Unit

Code

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.