JeremyKendall\Password\Tests\Decorator\UpgradeDecoratorTest::testPasswordValidAndPasswordRehashed PHP Method

testPasswordValidAndPasswordRehashed() public method

    public function testPasswordValidAndPasswordRehashed()
    {
        $password = 'password';
        $passwordHash = hash('sha512', $password);
        $validatorRehash = password_hash($password, PASSWORD_DEFAULT);
        $result = new ValidationResult(ValidationResult::SUCCESS_PASSWORD_REHASHED, $validatorRehash);
        $this->decoratedValidator->expects($this->once())->method('isValid')->with($password, $this->isType('string'))->will($this->returnValue($result));
        $result = $this->decorator->isValid($password, $passwordHash);
        $this->assertTrue($result->isValid());
        $this->assertEquals(ValidationResult::SUCCESS_PASSWORD_REHASHED, $result->getCode());
        // Rehashed password is a valid hash
        $this->assertTrue(password_verify($password, $result->getPassword()));
    }