Skip to content

Commit

Permalink
MNT Fix unit test (#11314)
Browse files Browse the repository at this point in the history
  • Loading branch information
GuySartorelli authored Jul 29, 2024
1 parent fb7b173 commit db05a28
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions tests/php/Security/RememberLoginHashTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,20 +110,25 @@ public function testRenew($replaceToken)

$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);
$oldToken = $hash->getToken();
$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) {
$this->assertNotEquals($oldToken, $hash->getToken());
$this->assertNotEquals($oldHash, $hash->Hash);
$this->assertNotEquals($oldToken, $storedHash->getToken());
$this->assertNotEquals($oldHash, $storedHash->Hash);
} else {
$this->assertEmpty($hash->getToken());
$this->assertEquals($oldHash, $hash->Hash);
$this->assertEmpty($storedHash->getToken());
$this->assertEquals($oldHash, $storedHash->Hash);
}
}

Expand Down

0 comments on commit db05a28

Please sign in to comment.