Skip to content

Commit beb903f

Browse files
Merge pull request #6 from Deyjandi/develop
merge develop branch
2 parents 24753c8 + 601cc73 commit beb903f

File tree

5 files changed

+28
-10
lines changed

5 files changed

+28
-10
lines changed

.github/workflows/run-tests.yml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@ name: run-tests
22

33
on:
44
push:
5-
branches: [main]
5+
branches: [main, develop, test]
66
pull_request:
7-
branches: [main]
7+
branches: [main, develop, test]
88

99
jobs:
1010
test:
1111
runs-on: ${{ matrix.os }}
12+
environment: testing
1213
strategy:
1314
fail-fast: true
1415
matrix:
@@ -45,3 +46,14 @@ jobs:
4546
4647
- name: Execute tests
4748
run: vendor/bin/pest
49+
env:
50+
APP_KEY: ${{ secrets.APP_KEY }}
51+
APP_ENV: ${{ secrets.APP_ENV }}
52+
CACHE_DRIVER: ${{ secrets.CACHE_DRIVER }}
53+
FILESYSTEM_DISK: ${{ secrets.FILESYSTEM_DISK }}
54+
VIVA_WALLET_ENV: ${{ secrets.VIVA_WALLET_ENV }}
55+
VIVA_WALLET_MERCHANT_ID: ${{ secrets.VIVA_WALLET_MERCHANT_ID }}
56+
VIVA_WALLET_API_KEY: ${{ secrets.VIVA_WALLET_API_KEY }}
57+
VIVA_WALLET_CLIENT_ID: ${{ secrets.VIVA_WALLET_CLIENT_ID }}
58+
VIVA_WALLET_CLIENT_SECRET: ${{ secrets.VIVA_WALLET_CLIENT_SECRET }}
59+
VIVA_WALLET_PAYMENT_SOURCE_CODE: ${{ secrets.VIVA_WALLET_PAYMENT_SOURCE_CODE }}

database/.gitkeep

Whitespace-only changes.

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)