function PasswordVerifyTest::testPasswordCheckUnknownHash

Same name and namespace in other branches
  1. 11.x core/modules/phpass/tests/src/Unit/PasswordVerifyTest.php \Drupal\Tests\phpass\Unit\PasswordVerifyTest::testPasswordCheckUnknownHash()

Tests that check() is forwarded to corePassword instance if hash settings are not recognized.

@covers ::check

File

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

Class

PasswordVerifyTest
Unit tests for password hashing API.

Namespace

Drupal\Tests\phpass\Unit

Code

public function testPasswordCheckUnknownHash() : void {
  $samplePassword = $this->randomMachineName();
  $sampleHash = $this->randomMachineName();
  $corePassword = $this->prophesize(PasswordInterface::class);
  $corePassword->check($samplePassword, $sampleHash)
    ->willReturn(TRUE);
  $passwordService = new PhpassHashedPassword($corePassword->reveal());
  $result = $passwordService->check($samplePassword, $sampleHash);
  $this->assertTrue($result, 'Calls to check() are forwarded to core password service if hash settings are not recognized.');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.