Skip to content

Commit 0f767ec

Browse files
chore(tests@token): stricter expiration test
1 parent 7caf7e4 commit 0f767ec

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/VivaWalletToken.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public function getScope(): string
8383
return $this->scope;
8484
}
8585

86-
private function isExpired(): bool
86+
public function isExpired(): bool
8787
{
8888
return now()->gte($this->issuedAt->addSeconds($this->getExpiresIn()));
8989
}

tests/VivaWalletTokenTest.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
use Illuminate\Support\Carbon;
55

66
it('can issue auth token', function () {
7-
expect(VivaWalletToken::getInstance())->toBeString();
7+
$token = VivaWalletToken::getInstance();
8+
9+
expect($token->getAccessToken())->toBeString();
810
});
911

1012
it('can hit cache', function () {
@@ -13,10 +15,12 @@
1315
expect(cache('viva_wallet_token'))->toEqual($token);
1416
});
1517

16-
it('can expire from cache', function () {
18+
it('can expire', function () {
1719
$token = VivaWalletToken::getInstance();
1820

1921
Carbon::setTestNow(now()->addSeconds($token->getExpiresIn()));
2022

23+
expect($token->isExpired())->toBeTrue();
24+
2125
expect(cache('viva_wallet_token'))->toBeNull();
2226
});

0 commit comments

Comments
 (0)