Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MNT Fix unit test #11314

Merged
merged 1 commit into from
Jul 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
);
Comment on lines -113 to +115
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That config is deprecated, so we need to wrap this to avoid deprecation warnings when we go hunting for stuff we need to update for the final minor release.


$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
Loading