Skip to content

Commit 9cfe57b

Browse files
committed
feat: 🧪 add unit and integration test
1 parent a73c02f commit 9cfe57b

File tree

5 files changed

+114
-1
lines changed

5 files changed

+114
-1
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@ composer.phar
55
vendor/
66
.phpunit.*
77
.code-coverage
8+
tests/Fixtures/Fixture.php
89

910
index.php

phpunit.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,20 @@
77
<testsuite name="unit">
88
<directory>tests/Unit</directory>
99
</testsuite>
10+
<testsuite name="integration">
11+
<directory>tests/Integration</directory>
12+
</testsuite>
1013
</testsuites>
1114
<source>
1215
<include>
1316
<directory suffix=".php">src</directory>
1417
</include>
18+
<exclude>
19+
<file>src/Support/HttpResponse.php</file>
20+
<file>src/Support/Http.php</file>
21+
<directory>src/Exception</directory>
22+
<directory>src/Interfaces</directory>
23+
</exclude>
1524
</source>
1625
<coverage>
1726
<report>

tests/Fixtures/Fixture.example.php

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<?php
2+
namespace Otnansirk\SnapBI\Fixtures;
3+
4+
final class Fixture
5+
{
6+
7+
/**
8+
* These values ​​are just examples and are not real.
9+
*
10+
* Before run test please
11+
* Rename this file with Fixture.php
12+
* Then change with your config value
13+
*
14+
* @return array
15+
*/
16+
public static function configFixture(): array
17+
{
18+
return [
19+
"client_id" => "a82ed8bf-493a-4133-ba01-08129e3w8432",
20+
"client_secret" => "a82ed8bf-493a-4133-ba01-08129e3w8432",
21+
"ssh_private_key" => <<<SSHKEY
22+
-----BEGIN PRIVATE KEY-----
23+
MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDDxV9SCePfJzYZ
24+
OAO1hy/eipUsxHFIG3ouZQ3fOlHWTGwpLKt25uFEwgrx0TA8MAs4ScBeVd/naNXD
25+
+9vWNH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
41+
vz2MlkCtHWDkBLL/Aagctw946bI93SMq0QG8U0IMmpNRqF/DeNRuK4IsT9vkRNm8
42+
LwR9JlB/nqnKUMZBSURqgJvLSdDAGSpvvBW77+DESWRfewtectW/HsplAoGBAKY9
43+
40swderDdhyNilrdU/D/oRcScjY6DNmNN3naXCeDmwMBzy0jOfxi4SV0o86qgdUv
44+
+eW2SYWRepsU33Q7PSAiU58C+uEs3XdUwG1zgYqiLDJcHZnnbPrMoIvFBshPirhB
45+
2/10mNZZ8789ZDa9f73AksHbriCWTnAL+Mr00tZBAoGAeiXhOYs7+39tPSXK6D70
46+
km8/drryNzicud7nm1Rekg6fYzbJ6Ee/p8Y9C7wdwdef/rNMHcAhJEVf3Kyw0gqr
47+
PUB9lddfswhEeIGI+cZ1CCvm2y7Yc4665Z8fxFHf2HIaEa0v+rKyhzqS8Xq5ha4m
48+
PRzOwU/Wf9yBtYX9NStJheU=
49+
-----END PRIVATE KEY-----
50+
SSHKEY,
51+
"ssh_public_key" => <<<SSHKEY
52+
-----BEGIN PUBLIC KEY-----
53+
MIIBeZeNBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAw8VfUgnj3yc2GTgDtYcv
54+
3oqVeereSBt6LmUN3zpR1kxsKSyrdubhRMIK8dEwPDALOEnAXlXf52jVw/vb1jR/
55+
Ao9esrfr01AXLOVVpn7dMOCqvDyv1ZsRpk6BusocIzSS03l4pOUrEUHd3Sjrg8L6
56+
c46lkUhPHZG8+yEgGkcORgSrS9bCRX1PvNGiUG2CrrrCh+Hs/EqwbKxCzBWkNK0R
57+
9qC/1i0AZlj5VdhnzsuCozxbz9PSNG+84puM076Weeee6igJky+ZliZCu2Ta2L0O
58+
s31BtoNo0c7+6ydwd+tv2ETecgpBQZtE1rtDEdMdtgIjLfFMdwd62NyG2wK2yOtm
59+
/QIDEQAB
60+
-----END PUBLIC KEY-----
61+
SSHKEY,
62+
"partner_id" => "UAYCORQ011",
63+
"account_id" => "0643002227",
64+
"bank_card_token" => "1234567890",
65+
"channel_id" => "92221",
66+
"base_url" => "https://api.api.com",
67+
];
68+
}
69+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
use Otnansirk\SnapBI\Fixtures\Fixture;
3+
use Otnansirk\SnapBI\Services\Config;
4+
use Otnansirk\SnapBI\Services\SnapBi;
5+
use PHPUnit\Framework\TestCase;
6+
7+
final class BcaSnapBiTest extends TestCase
8+
{
9+
10+
public static function setUpBeforeClass(): void
11+
{
12+
Config::bca(Fixture::configFixture());
13+
}
14+
15+
function testAccessTokenB2b()
16+
{
17+
$res = SnapBi::bca()->accessTokenB2b();
18+
$this->assertEquals(200, $res->status());
19+
}
20+
21+
function testBankStatement()
22+
{
23+
$res = SnapBi::bca()
24+
->withTokenB2b()
25+
->bankStatement('2023-08-22T00:00:00+07:00', '2023-08-22T00:00:00+07:00');
26+
$this->assertEquals(200, $res->status());
27+
}
28+
29+
public function tearDown(): void
30+
{
31+
// One second interval to avoid throttle
32+
sleep(1);
33+
}
34+
35+
}

tests/Unit/SupportHttpTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
<?php
2-
use Otnansirk\SnapBI\Support\HttpResponse;
32
use PHPUnit\Framework\TestCase;
43
use Otnansirk\SnapBI\Support\Http;
54

0 commit comments

Comments
 (0)