Skip to content

Commit 64a2ad2

Browse files
authored
Fix unit test (#96)
* Update test.yml * Fix unit test
1 parent 51685d8 commit 64a2ad2

File tree

8 files changed

+34
-26
lines changed

8 files changed

+34
-26
lines changed

.editorconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,6 @@ trim_trailing_whitespace = true
1313

1414
[*.md]
1515
trim_trailing_whitespace = false
16+
17+
[*.yml]
18+
indent_size = 2

.github/workflows/test.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ jobs:
2020
fail-fast: false
2121
matrix:
2222
os: [ubuntu-latest]
23-
php: [8.1, '8.2']
24-
laravel: ['9.*', '11.*']
23+
php: [8.1, 8.2, 8.3]
24+
laravel: ['10.*', '11.*']
2525
stability: [prefer-lowest, prefer-stable]
2626
include:
27-
- laravel: 9.*
28-
testbench: 7.*
27+
- laravel: 10.*
28+
testbench: 8.*
2929
- laravel: 11.*
3030
testbench: 9.*
3131
exclude:

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ composer.lock
33
vendor
44
coverage
55
.env*
6+
.idea

.phpunit.result.cache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"version":1,"defects":{"Luigel\\Paymongo\\Tests\\PaymentIntentTest::it_can_attach_paymaya_payment_method_to_payment_intent":4,"Luigel\\Paymongo\\Tests\\PaymentTest::it_can_create_payment":4,"Luigel\\Paymongo\\Tests\\PaymentTest::it_cannot_create_payment_when_token_is_used_more_than_once":3,"Luigel\\Paymongo\\Tests\\PaymentTest::it_cannot_create_payment_when_token_is_not_valid":3,"Luigel\\Paymongo\\Tests\\PaymentTest::it_can_retrieve_a_payment":4,"Luigel\\Paymongo\\Tests\\PaymentTest::it_can_not_retrieve_a_payment_with_invalid_id":3,"Luigel\\Paymongo\\Tests\\PaymongoValidateSignatureTest::it_will_allow_valid_signature":4,"\/Users\/luigel\/Projects\/laravel-paymongo\/tests\/BaseModelTest.php::it":4,"\/Users\/luigel\/Projects\/laravel-paymongo\/tests\/PaymentIntentTest.php::it":3,"\/Users\/luigel\/Projects\/laravel-paymongo\/tests\/PaymentTest.php::it":3,"\/Users\/luigel\/Projects\/laravel-paymongo\/tests\/SourceTest.php::it":3,"\/Users\/luigel\/Projects\/laravel-paymongo\/tests\/WebhookListCommandTest.php::it":4,"\/Users\/luigel\/Projects\/laravel-paymongo\/tests\/AmounToIntegerTest.php::it":3,"\/Users\/luigel\/Projects\/laravel-paymongo\/tests\/RefundTest.php::it":3},"times":{"Luigel\\Paymongo\\Tests\\AmounToIntegerTest::it_can_convert_without_decimal":0.042,"Luigel\\Paymongo\\Tests\\AmounToIntegerTest::it_can_convert_with_in_tenth_decimal":0.002,"Luigel\\Paymongo\\Tests\\AmounToIntegerTest::it_can_convert_with_in_hundredth_decimal":0.001,"Luigel\\Paymongo\\Tests\\BaseModelTest::it_can_set_data":0.003,"Luigel\\Paymongo\\Tests\\PaymentIntentTest::it_can_create_payment_intent":1.034,"Luigel\\Paymongo\\Tests\\PaymentIntentTest::it_cannot_create_payment_intent_when_data_is_invalid":0.809,"Luigel\\Paymongo\\Tests\\PaymentIntentTest::it_can_cancel_payment_intent":1.694,"Luigel\\Paymongo\\Tests\\PaymentIntentTest::it_can_attach_payment_method_to_payment_intent":2.908,"Luigel\\Paymongo\\Tests\\PaymentIntentTest::it_cannot_attach_payment_intent_with_invalid_data":0.9,"Luigel\\Paymongo\\Tests\\PaymentIntentTest::it_can_retrieve_payment_intent":1.774,"Luigel\\Paymongo\\Tests\\PaymentMethodTest::it_can_create_payment_method":0.966,"Luigel\\Paymongo\\Tests\\PaymentMethodTest::it_cannot_create_payment_method_with_invalid_data":0.834,"Luigel\\Paymongo\\Tests\\PaymentMethodTest::it_can_retrieve_payment_method":1.755,"Luigel\\Paymongo\\Tests\\PaymentTest::it_can_create_payment":2.189,"Luigel\\Paymongo\\Tests\\PaymentTest::it_cannot_create_payment_when_token_is_used_more_than_once":2.784,"Luigel\\Paymongo\\Tests\\PaymentTest::it_cannot_create_payment_when_token_is_not_valid":2.779,"Luigel\\Paymongo\\Tests\\PaymentTest::it_can_retrieve_a_payment":2.82,"Luigel\\Paymongo\\Tests\\PaymentTest::it_can_not_retrieve_a_payment_with_invalid_id":1.72,"Luigel\\Paymongo\\Tests\\PaymentTest::it_can_get_all_payments":1.811,"Luigel\\Paymongo\\Tests\\PaymongoValidateSignatureTest::it_will_not_allow_invalid_signature":0.009,"Luigel\\Paymongo\\Tests\\PaymongoValidateSignatureTest::it_will_allow_valid_signature":0.055,"Luigel\\Paymongo\\Tests\\SourceTest::it_can_create_a_gcash_source":0.875,"Luigel\\Paymongo\\Tests\\SourceTest::it_can_create_a_grab_pay_source":0.857,"Luigel\\Paymongo\\Tests\\TokenTest::it_can_create_token":0.912,"Luigel\\Paymongo\\Tests\\TokenTest::it_cannot_create_token_with_invalid_data":0.855,"Luigel\\Paymongo\\Tests\\TokenTest::it_can_retrieve_token":1.782,"Luigel\\Paymongo\\Tests\\UnauthorizedTest::it_expects_unauthorized_exception_with_invalid_api_keys":0.825,"Luigel\\Paymongo\\Tests\\WebhookTest::it_can_list_all_webhooks":0.849,"Luigel\\Paymongo\\Tests\\WebhookTest::it_can_retrieve_webhook":1.646,"Luigel\\Paymongo\\Tests\\PaymentIntentTest::it_can_attach_paymaya_payment_method_to_payment_intent":2.616,"\/Users\/luigel\/Projects\/laravel-paymongo\/tests\/AmounToIntegerTest.php::it":0.047,"\/Users\/luigel\/Projects\/laravel-paymongo\/tests\/BaseModelTest.php::it":0.061,"\/Users\/luigel\/Projects\/laravel-paymongo\/tests\/PaymentIntentTest.php::it":1.063,"\/Users\/luigel\/Projects\/laravel-paymongo\/tests\/PaymentTest.php::it":1.19,"\/Users\/luigel\/Projects\/laravel-paymongo\/tests\/PaymongoValidateSignatureTest.php::it":0.061,"\/Users\/luigel\/Projects\/laravel-paymongo\/tests\/SourceTest.php::it":0.883,"\/Users\/luigel\/Projects\/laravel-paymongo\/tests\/TokenTest.php::it":0.815,"\/Users\/luigel\/Projects\/laravel-paymongo\/tests\/UnauthorizedTest.php::it":1.045,"\/Users\/luigel\/Projects\/laravel-paymongo\/tests\/WebhookTest.php::it":1.714,"\/Users\/luigel\/Projects\/laravel-paymongo\/tests\/WebhookListCommandTest.php::it":1.957,"\/Users\/luigel\/Projects\/laravel-paymongo\/tests\/RefundTest.php::it":1.658}}
1+
{"version":1,"defects":{"Luigel\\Paymongo\\Tests\\PaymentIntentTest::it_can_attach_paymaya_payment_method_to_payment_intent":4,"Luigel\\Paymongo\\Tests\\PaymentTest::it_can_create_payment":4,"Luigel\\Paymongo\\Tests\\PaymentTest::it_cannot_create_payment_when_token_is_used_more_than_once":3,"Luigel\\Paymongo\\Tests\\PaymentTest::it_cannot_create_payment_when_token_is_not_valid":3,"Luigel\\Paymongo\\Tests\\PaymentTest::it_can_retrieve_a_payment":4,"Luigel\\Paymongo\\Tests\\PaymentTest::it_can_not_retrieve_a_payment_with_invalid_id":3,"Luigel\\Paymongo\\Tests\\PaymongoValidateSignatureTest::it_will_allow_valid_signature":4,"\/Users\/luigel\/Projects\/laravel-paymongo\/tests\/BaseModelTest.php::it":4,"\/Users\/luigel\/Projects\/laravel-paymongo\/tests\/PaymentIntentTest.php::it":3,"\/Users\/luigel\/Projects\/laravel-paymongo\/tests\/PaymentTest.php::it":3,"\/Users\/luigel\/Projects\/laravel-paymongo\/tests\/SourceTest.php::it":3,"\/Users\/luigel\/Projects\/laravel-paymongo\/tests\/WebhookListCommandTest.php::it":4,"\/Users\/luigel\/Projects\/laravel-paymongo\/tests\/AmounToIntegerTest.php::it":3,"\/Users\/luigel\/Projects\/laravel-paymongo\/tests\/RefundTest.php::it":3},"times":{"Luigel\\Paymongo\\Tests\\AmounToIntegerTest::it_can_convert_without_decimal":0.042,"Luigel\\Paymongo\\Tests\\AmounToIntegerTest::it_can_convert_with_in_tenth_decimal":0.002,"Luigel\\Paymongo\\Tests\\AmounToIntegerTest::it_can_convert_with_in_hundredth_decimal":0.001,"Luigel\\Paymongo\\Tests\\BaseModelTest::it_can_set_data":0.003,"Luigel\\Paymongo\\Tests\\PaymentIntentTest::it_can_create_payment_intent":1.034,"Luigel\\Paymongo\\Tests\\PaymentIntentTest::it_cannot_create_payment_intent_when_data_is_invalid":0.809,"Luigel\\Paymongo\\Tests\\PaymentIntentTest::it_can_cancel_payment_intent":1.694,"Luigel\\Paymongo\\Tests\\PaymentIntentTest::it_can_attach_payment_method_to_payment_intent":2.908,"Luigel\\Paymongo\\Tests\\PaymentIntentTest::it_cannot_attach_payment_intent_with_invalid_data":0.9,"Luigel\\Paymongo\\Tests\\PaymentIntentTest::it_can_retrieve_payment_intent":1.774,"Luigel\\Paymongo\\Tests\\PaymentMethodTest::it_can_create_payment_method":0.966,"Luigel\\Paymongo\\Tests\\PaymentMethodTest::it_cannot_create_payment_method_with_invalid_data":0.834,"Luigel\\Paymongo\\Tests\\PaymentMethodTest::it_can_retrieve_payment_method":1.755,"Luigel\\Paymongo\\Tests\\PaymentTest::it_can_create_payment":2.189,"Luigel\\Paymongo\\Tests\\PaymentTest::it_cannot_create_payment_when_token_is_used_more_than_once":2.784,"Luigel\\Paymongo\\Tests\\PaymentTest::it_cannot_create_payment_when_token_is_not_valid":2.779,"Luigel\\Paymongo\\Tests\\PaymentTest::it_can_retrieve_a_payment":2.82,"Luigel\\Paymongo\\Tests\\PaymentTest::it_can_not_retrieve_a_payment_with_invalid_id":1.72,"Luigel\\Paymongo\\Tests\\PaymentTest::it_can_get_all_payments":1.811,"Luigel\\Paymongo\\Tests\\PaymongoValidateSignatureTest::it_will_not_allow_invalid_signature":0.009,"Luigel\\Paymongo\\Tests\\PaymongoValidateSignatureTest::it_will_allow_valid_signature":0.055,"Luigel\\Paymongo\\Tests\\SourceTest::it_can_create_a_gcash_source":0.875,"Luigel\\Paymongo\\Tests\\SourceTest::it_can_create_a_grab_pay_source":0.857,"Luigel\\Paymongo\\Tests\\TokenTest::it_can_create_token":0.912,"Luigel\\Paymongo\\Tests\\TokenTest::it_cannot_create_token_with_invalid_data":0.855,"Luigel\\Paymongo\\Tests\\TokenTest::it_can_retrieve_token":1.782,"Luigel\\Paymongo\\Tests\\UnauthorizedTest::it_expects_unauthorized_exception_with_invalid_api_keys":0.825,"Luigel\\Paymongo\\Tests\\WebhookTest::it_can_list_all_webhooks":0.849,"Luigel\\Paymongo\\Tests\\WebhookTest::it_can_retrieve_webhook":1.646,"Luigel\\Paymongo\\Tests\\PaymentIntentTest::it_can_attach_paymaya_payment_method_to_payment_intent":2.616,"\/Users\/luigel\/Projects\/laravel-paymongo\/tests\/AmounToIntegerTest.php::it":0.047,"\/Users\/luigel\/Projects\/laravel-paymongo\/tests\/BaseModelTest.php::it":0.061,"\/Users\/luigel\/Projects\/laravel-paymongo\/tests\/PaymentIntentTest.php::it":1.063,"\/Users\/luigel\/Projects\/laravel-paymongo\/tests\/PaymentTest.php::it":1.19,"\/Users\/luigel\/Projects\/laravel-paymongo\/tests\/PaymongoValidateSignatureTest.php::it":0.061,"\/Users\/luigel\/Projects\/laravel-paymongo\/tests\/SourceTest.php::it":0.883,"\/Users\/luigel\/Projects\/laravel-paymongo\/tests\/TokenTest.php::it":0.815,"\/Users\/luigel\/Projects\/laravel-paymongo\/tests\/UnauthorizedTest.php::it":1.045,"\/Users\/luigel\/Projects\/laravel-paymongo\/tests\/WebhookTest.php::it":1.714,"\/Users\/luigel\/Projects\/laravel-paymongo\/tests\/WebhookListCommandTest.php::it":1.957,"\/Users\/luigel\/Projects\/laravel-paymongo\/tests\/RefundTest.php::it":1.658,"\/Users\/luigel\/Projects\/php\/laravel-paymongo\/tests\/PaymentIntentTest.php::it":2.194}}

composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@
2929
},
3030
"require-dev": {
3131
"orchestra/testbench": "^6.0|^7.0|^8.0|^9.0",
32-
"pestphp/pest": "^1.20|^2.34",
33-
"pestphp/pest-plugin-parallel": "^1.0"
32+
"pestphp/pest": "^2.34"
3433
},
3534
"autoload": {
3635
"psr-4": {

phpunit.xml.dist

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@
1919
<directory suffix=".php">src/</directory>
2020
</whitelist>
2121
</filter>
22+
<source>
23+
<include>
24+
<directory suffix=".php">src/</directory>
25+
</include>
26+
</source>
2227

2328
<php>
2429
<env name="APP_ENV" value="testing" />

src/Traits/HasToggleWebhook.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public function enable(Webhook $webhook)
1818
$this->method = 'POST';
1919
$this->apiUrl = $this->apiUrl.$webhook->getId().'/enable';
2020

21-
$this->setOptions([
21+
$this->setGuzzleOptions([
2222
'headers' => [
2323
'Accept' => 'application/json',
2424
],
@@ -39,7 +39,7 @@ public function disable(Webhook $webhook)
3939
$this->method = 'POST';
4040
$this->apiUrl = $this->apiUrl.$webhook->getId().'/disable';
4141

42-
$this->setOptions([
42+
$this->setGuzzleOptions([
4343
'headers' => [
4444
'Accept' => 'application/json',
4545
],

src/Traits/Request.php

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ trait Request
2222
{
2323
protected array $data;
2424
protected array $payload;
25-
protected array $options;
25+
protected array $guzzleOptions;
2626

2727
/**
2828
* Request a create to API.
@@ -33,7 +33,7 @@ public function create(array $payload): BaseModel
3333
$this->payload = $this->convertPayloadAmountsToInteger($payload);
3434
$this->formRequestData();
3535

36-
$this->setOptions([
36+
$this->setGuzzleOptions([
3737
'headers' => [
3838
'Accept' => 'application/json',
3939
'Content-type' => 'application/json',
@@ -53,7 +53,7 @@ public function find(string $payload): BaseModel
5353
$this->method = 'GET';
5454
$this->apiUrl = $this->apiUrl.$payload;
5555

56-
$this->setOptions([
56+
$this->setGuzzleOptions([
5757
'headers' => [
5858
'Accept' => 'application/json',
5959
'Content-type' => 'application/json',
@@ -71,7 +71,7 @@ public function all(): Collection
7171
{
7272
$this->method = 'GET';
7373

74-
$this->setOptions([
74+
$this->setGuzzleOptions([
7575
'headers' => [
7676
'Accept' => 'application/json',
7777
'Content-type' => 'application/json',
@@ -92,7 +92,7 @@ public function update(Webhook $webhook, array $payload): BaseModel
9292
$this->apiUrl = $this->apiUrl.$webhook->id;
9393

9494
$this->formRequestData();
95-
$this->setOptions([
95+
$this->setGuzzleOptions([
9696
'headers' => [
9797
'Accept' => 'application/json',
9898
],
@@ -111,7 +111,7 @@ public function cancel(PaymentIntent $intent): BaseModel
111111
$this->method = 'POST';
112112
$this->apiUrl = $this->apiUrl.$intent->id.'/cancel';
113113

114-
$this->setOptions([
114+
$this->setGuzzleOptions([
115115
'headers' => [
116116
'Accept' => 'application/json',
117117
],
@@ -135,7 +135,7 @@ public function attach(PaymentIntent $intent, string $paymentMethodId, string|nu
135135
}
136136

137137
$this->formRequestData();
138-
$this->setOptions([
138+
$this->setGuzzleOptions([
139139
'headers' => [
140140
'Accept' => 'application/json',
141141
],
@@ -154,7 +154,7 @@ public function archive(Link $link)
154154
$this->method = 'POST';
155155
$this->apiUrl = $this->apiUrl.$link->id.'/archive';
156156

157-
$this->setOptions([
157+
$this->setGuzzleOptions([
158158
'headers' => [
159159
'Accept' => 'application/json',
160160
],
@@ -172,7 +172,7 @@ public function unarchive(Link $link)
172172
$this->method = 'POST';
173173
$this->apiUrl = $this->apiUrl.$link->id.'/unarchive';
174174

175-
$this->setOptions([
175+
$this->setGuzzleOptions([
176176
'headers' => [
177177
'Accept' => 'application/json',
178178
],
@@ -192,7 +192,7 @@ public function updateCustomer(Customer $customer, array $payload)
192192
$this->payload = $payload;
193193

194194
$this->formRequestData();
195-
$this->setOptions([
195+
$this->setGuzzleOptions([
196196
'headers' => [
197197
'Accept' => 'application/json',
198198
],
@@ -211,7 +211,7 @@ public function deleteCustomer(Customer $customer)
211211
$this->method = 'DELETE';
212212
$this->apiUrl = $this->apiUrl.$customer->id;
213213

214-
$this->setOptions([
214+
$this->setGuzzleOptions([
215215
'headers' => [
216216
'Accept' => 'application/json',
217217
],
@@ -229,7 +229,7 @@ public function getPaymentMethods(Customer $customer)
229229
$this->method = 'GET';
230230
$this->apiUrl = $this->apiUrl.$customer->id.'/payment_methods';
231231

232-
$this->setOptions([
232+
$this->setGuzzleOptions([
233233
'headers' => [
234234
'Accept' => 'application/json',
235235
],
@@ -244,7 +244,7 @@ public function expireCheckout(Checkout $checkout)
244244
$this->method = 'POST';
245245
$this->apiUrl = $this->apiUrl.$checkout->id.'/expire';
246246

247-
$this->setOptions([
247+
$this->setGuzzleOptions([
248248
'headers' => [
249249
'Accept' => 'application/json',
250250
],
@@ -268,7 +268,7 @@ protected function request(): BaseModel|Collection
268268
$client = new Client();
269269

270270
try {
271-
$response = $client->request($this->method, $this->apiUrl, $this->options);
271+
$response = $client->request($this->method, $this->apiUrl, $this->guzzleOptions);
272272

273273
$array = $this->parseToArray((string) $response->getBody());
274274

@@ -328,12 +328,12 @@ protected function setReturnModel($array)
328328
/**
329329
* Set the options.
330330
*
331-
* @param array $options
331+
* @param array $guzzleOptions
332332
* @return $this
333333
*/
334-
protected function setOptions($options)
334+
protected function setGuzzleOptions($guzzleOptions)
335335
{
336-
$this->options = $options;
336+
$this->guzzleOptions = $guzzleOptions;
337337

338338
return $this;
339339
}

0 commit comments

Comments
 (0)