protected function setUp()
{
parent::setUp();
$this->validationCallback = function ($credential, $passwordHash, $salt) {
// Recreate the legacy hash. This was the persisted password hash
// prior to upgrading.
$legacyHash = hash('sha512', $credential . $salt);
// Now test the old hash against the new, upgraded hash
if (password_verify($legacyHash, $passwordHash)) {
return true;
}
return false;
};
$interface = 'JeremyKendall\\Password\\PasswordValidatorInterface';
$this->decoratedValidator = $this->getMockBuilder($interface)->disableOriginalConstructor()->getMock();
$this->decorator = new UpgradeDecorator($this->decoratedValidator, $this->validationCallback);
$this->plainTextPassword = 'password';
$this->legacySalt = mt_rand(1000, 1000000);
$legacyHash = hash('sha512', $this->plainTextPassword . $this->legacySalt);
$this->upgradedLegacyHash = password_hash($legacyHash, PASSWORD_DEFAULT);
}