From db05a28bc219378b46317d9bec83d4e10101096c Mon Sep 17 00:00:00 2001 From: Guy Sartorelli <36352093+GuySartorelli@users.noreply.github.com> Date: Mon, 29 Jul 2024 16:57:30 +1200 Subject: [PATCH] MNT Fix unit test (#11314) --- tests/php/Security/RememberLoginHashTest.php | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/tests/php/Security/RememberLoginHashTest.php b/tests/php/Security/RememberLoginHashTest.php index b62b6819295..ced2991af5d 100644 --- a/tests/php/Security/RememberLoginHashTest.php +++ b/tests/php/Security/RememberLoginHashTest.php @@ -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); } }