Skip to content

Commit

Permalink
hasExpired() should use self::getTimeNow()
Browse files Browse the repository at this point in the history
  • Loading branch information
prikkprikkprikk authored and ramsey committed Dec 11, 2024
1 parent 2d06e3e commit 3c8c2b4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Token/AccessToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ public function hasExpired()
throw new RuntimeException('"expires" is not set on the token');
}

return $expires < time();
return $expires < $this->getTimeNow();
}

/**
Expand Down
16 changes: 16 additions & 0 deletions test/src/Token/AccessTokenTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,22 @@ public function testHasExpiredWhenPropertySetInPast()
self::tearDownForBackwardsCompatibility();
}

public function testHasExpiredWhenTimeNowIsInFuture()
{
$options = [
'access_token' => 'mock_access_token',
'expires' => time(),
];

$token = $this->getAccessToken($options);

$token->setTimeNow(time() + 60);

$this->assertTrue($token->hasExpired());

self::tearDownForBackwardsCompatibility();
}

public function testCannotReportExpiredWhenNoExpirationSet()
{
$options = [
Expand Down

0 comments on commit 3c8c2b4

Please sign in to comment.