MNT Fix unit test (#11314)

This commit is contained in:
Guy Sartorelli 2024-07-29 16:57:30 +12:00 committed by GitHub
parent fb7b1734eb
commit db05a28bc2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -110,20 +110,25 @@ class RememberLoginHashTest extends SapphireTest
$member = $this->objFromFixture(Member::class, 'main'); $member = $this->objFromFixture(Member::class, 'main');
RememberLoginHash::config()->set('replace_token_during_session_renewal', $replaceToken); Deprecation::withNoReplacement(
fn() => RememberLoginHash::config()->set('replace_token_during_session_renewal', $replaceToken)
);
$hash = RememberLoginHash::generate($member); $hash = RememberLoginHash::generate($member);
$oldToken = $hash->getToken(); $oldToken = $hash->getToken();
$oldHash = $hash->Hash; $oldHash = $hash->Hash;
Deprecation::withNoReplacement(fn() => $hash->renew()); // Fetch the token from the DB - otherwise we still have the token from when this was originally created
$storedHash = RememberLoginHash::get()->find('ID', $hash->ID);
Deprecation::withNoReplacement(fn() => $storedHash->renew());
if ($replaceToken) { if ($replaceToken) {
$this->assertNotEquals($oldToken, $hash->getToken()); $this->assertNotEquals($oldToken, $storedHash->getToken());
$this->assertNotEquals($oldHash, $hash->Hash); $this->assertNotEquals($oldHash, $storedHash->Hash);
} else { } else {
$this->assertEmpty($hash->getToken()); $this->assertEmpty($storedHash->getToken());
$this->assertEquals($oldHash, $hash->Hash); $this->assertEquals($oldHash, $storedHash->Hash);
} }
} }