function PasswordVerifyTest::testPasswordNeedsRehash

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

Tests that needsRehash() is forwarded to corePassword instance.

@covers ::needsRehash

File

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

Class

PasswordVerifyTest
Unit tests for password hashing API.

Namespace

Drupal\Tests\phpass\Unit

Code

public function testPasswordNeedsRehash() : void {
    $sampleHash = $this->randomMachineName();
    $corePassword = $this->prophesize(PasswordInterface::class);
    $corePassword->needsRehash($sampleHash)
        ->willReturn(TRUE);
    $passwordService = new PhpassHashedPassword($corePassword->reveal());
    $result = $passwordService->needsRehash($sampleHash);
    $this->assertTrue($result, 'Calls to needsRehash() are forwarded to core password service.');
}

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