Skip to content

Commit 9a17573

Browse files
Merge pull request #4 from Deyjandi/update_unit_testing
unit tests: stricter testing
2 parents d832b08 + 0f767ec commit 9a17573

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
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/VivaWalletTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@
99
)->toBeString();
1010
});
1111

12-
it('can generate webhook verification key', function () {
12+
it('can request webhook verification key', function () {
1313
expect(VivaWallet::requestWebhookKey())->toBeString();
1414
});

tests/VivaWalletTokenTest.php

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,26 @@
11
<?php
22

3-
use Deyjandi\VivaWallet\Helpers\ClientAuth;
43
use Deyjandi\VivaWallet\VivaWalletToken;
54
use Illuminate\Support\Carbon;
65

7-
it(
8-
'can make auth header',
9-
fn () => expect(ClientAuth::token(VivaWalletToken::getInstance()))->toBeString()
10-
);
6+
it('can issue auth token', function () {
7+
$token = VivaWalletToken::getInstance();
8+
9+
expect($token->getAccessToken())->toBeString();
10+
});
1111

12-
it('can hit and expire from cache', function () {
12+
it('can hit cache', function () {
1313
$token = VivaWalletToken::getInstance();
1414

1515
expect(cache('viva_wallet_token'))->toEqual($token);
16+
});
17+
18+
it('can expire', function () {
19+
$token = VivaWalletToken::getInstance();
1620

1721
Carbon::setTestNow(now()->addSeconds($token->getExpiresIn()));
1822

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

0 commit comments

Comments
 (0)