From 6f66e668c919261290b1387abdd7a73adb5ffd97 Mon Sep 17 00:00:00 2001 From: Raza Mehdi Date: Sat, 30 Sep 2023 21:45:23 +0500 Subject: [PATCH] Add selector function for json_decode. --- src/Services/Str.php | 7 +++-- src/Traits/JsonDecodeSelector.php | 16 +++++++++++ src/Traits/PayPalHttpClient.php | 4 +-- src/Traits/PayPalRequest.php | 1 + tests/MockClientClasses.php | 3 ++ tests/Mocks/Requests/BillingPlans.php | 6 ++-- tests/Mocks/Requests/CatalogProducts.php | 4 +-- tests/Mocks/Requests/Disputes.php | 2 +- tests/Mocks/Requests/DisputesActions.php | 6 ++-- tests/Mocks/Requests/Identity.php | 4 +-- tests/Mocks/Requests/Invoices.php | 16 +++++------ tests/Mocks/Requests/InvoicesSearch.php | 2 +- tests/Mocks/Requests/InvoicesTemplates.php | 4 +-- tests/Mocks/Requests/Orders.php | 4 +-- tests/Mocks/Requests/PartnerReferrals.php | 2 +- .../Mocks/Requests/PaymentAuthorizations.php | 4 +-- tests/Mocks/Requests/PaymentCaptures.php | 2 +- .../Requests/PaymentExperienceWebProfiles.php | 6 ++-- tests/Mocks/Requests/PaymentMethodsTokens.php | 4 +-- tests/Mocks/Requests/Payouts.php | 2 +- tests/Mocks/Requests/ReferencedPayouts.php | 4 +-- tests/Mocks/Requests/Subscriptions.php | 14 +++++----- tests/Mocks/Requests/Trackers.php | 4 +-- tests/Mocks/Requests/WebHooks.php | 8 +++--- tests/Mocks/Responses/BillingPlans.php | 6 ++-- tests/Mocks/Responses/CatalogProducts.php | 6 ++-- tests/Mocks/Responses/Disputes.php | 4 +-- tests/Mocks/Responses/DisputesActions.php | 6 ++-- tests/Mocks/Responses/Identity.php | 10 +++---- tests/Mocks/Responses/Invoices.php | 14 +++++----- tests/Mocks/Responses/InvoicesSearch.php | 2 +- tests/Mocks/Responses/InvoicesTemplates.php | 8 +++--- tests/Mocks/Responses/Orders.php | 10 +++---- tests/Mocks/Responses/PartnerReferrals.php | 4 +-- .../Mocks/Responses/PaymentAuthorizations.php | 6 ++-- tests/Mocks/Responses/PaymentCaptures.php | 4 +-- .../PaymentExperienceWebProfiles.php | 4 +-- .../Mocks/Responses/PaymentMethodsTokens.php | 8 +++--- tests/Mocks/Responses/PaymentRefunds.php | 2 +- tests/Mocks/Responses/Payouts.php | 8 +++--- tests/Mocks/Responses/ReferencedPayouts.php | 8 +++--- tests/Mocks/Responses/Reporting.php | 4 +-- tests/Mocks/Responses/Subscriptions.php | 8 +++--- tests/Mocks/Responses/Trackers.php | 4 +-- tests/Mocks/Responses/WebHooks.php | 20 ++++++------- tests/Unit/Client/BillingPlansTest.php | 14 +++++----- tests/Unit/Client/CatalogProductsTest.php | 8 +++--- tests/Unit/Client/DisputeActionsTest.php | 6 ++-- tests/Unit/Client/DisputesTest.php | 6 ++-- tests/Unit/Client/IdentityTest.php | 2 +- tests/Unit/Client/InvoicesSearchTest.php | 2 +- tests/Unit/Client/InvoicesTemplatesTest.php | 10 +++---- tests/Unit/Client/InvoicesTest.php | 28 +++++++++---------- tests/Unit/Client/OrdersTest.php | 2 +- tests/Unit/Client/PartnerReferralsTest.php | 4 +-- .../Unit/Client/PaymentAuthorizationsTest.php | 8 +++--- tests/Unit/Client/PaymentCapturesTest.php | 4 +-- .../PaymentExperienceWebProfilesTest.php | 12 ++++---- tests/Unit/Client/PaymentRefundsTest.php | 2 +- tests/Unit/Client/PayoutsTest.php | 8 +++--- tests/Unit/Client/ReferencedPayoutsTest.php | 8 +++--- tests/Unit/Client/ReportingTest.php | 4 +-- tests/Unit/Client/SubscriptionsTest.php | 18 ++++++------ tests/Unit/Client/TrackersTest.php | 6 ++-- tests/Unit/Client/WebHooksEventsTest.php | 8 +++--- tests/Unit/Client/WebHooksTest.php | 12 ++++---- .../Unit/Client/WebHooksVerificationTest.php | 2 +- tests/Unit/ClientTest.php | 2 +- 68 files changed, 237 insertions(+), 214 deletions(-) create mode 100644 src/Traits/JsonDecodeSelector.php diff --git a/src/Services/Str.php b/src/Services/Str.php index 0fb4576f..96f9bc4b 100644 --- a/src/Services/Str.php +++ b/src/Services/Str.php @@ -3,9 +3,12 @@ namespace Srmklive\PayPal\Services; use GuzzleHttp\Utils; +use Srmklive\PayPal\Traits\JsonDecodeSelector; class Str extends \Illuminate\Support\Str { + use JsonDecodeSelector; + /** * Determine if a given value is valid JSON. * @@ -24,8 +27,8 @@ public static function isJson($value): bool } try { - Utils::jsonDecode($value, true, 512, 4194304); - } catch (\JsonException $jsonException) { + (new Str)->jsonDecodeFunction()($value, true, 512, 4194304); + } catch (\Exception $jsonException) { return false; } diff --git a/src/Traits/JsonDecodeSelector.php b/src/Traits/JsonDecodeSelector.php new file mode 100644 index 00000000..357c40d2 --- /dev/null +++ b/src/Traits/JsonDecodeSelector.php @@ -0,0 +1,16 @@ +makeHttpRequest(); - return ($decode === false) ? $response->getContents() : Utils::jsonDecode($response, true); + return ($decode === false) ? $response->getContents() : $this->jsonDecodeFunction()($response, true); } catch (RuntimeException $t) { - $error = ($decode === false) || (Str::isJson($t->getMessage()) === false) ? $t->getMessage() : Utils::jsonDecode($t->getMessage(), true); + $error = ($decode === false) || (Str::isJson($t->getMessage()) === false) ? $t->getMessage() : $this->jsonDecodeFunction()($t->getMessage(), true); return ['error' => $error]; } diff --git a/src/Traits/PayPalRequest.php b/src/Traits/PayPalRequest.php index 860b1fca..adfbe3eb 100644 --- a/src/Traits/PayPalRequest.php +++ b/src/Traits/PayPalRequest.php @@ -6,6 +6,7 @@ trait PayPalRequest { + use JsonDecodeSelector; use PayPalHttpClient; use PayPalAPI; use PayPalExperienceContext; diff --git a/tests/MockClientClasses.php b/tests/MockClientClasses.php index ff4019d5..45d446af 100644 --- a/tests/MockClientClasses.php +++ b/tests/MockClientClasses.php @@ -10,9 +10,12 @@ use GuzzleHttp\Utils; use Psr\Http\Message\ResponseInterface; use Srmklive\PayPal\Services\PayPal as PayPalClient; +use Srmklive\PayPal\Traits\JsonDecodeSelector; trait MockClientClasses { + use JsonDecodeSelector; + private function mock_http_client($response): HttpClient { $mock = new HttpMockHandler([ diff --git a/tests/Mocks/Requests/BillingPlans.php b/tests/Mocks/Requests/BillingPlans.php index 731d5837..c23ab9ce 100644 --- a/tests/Mocks/Requests/BillingPlans.php +++ b/tests/Mocks/Requests/BillingPlans.php @@ -11,7 +11,7 @@ trait BillingPlans */ private function createPlanParams(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "product_id": "PROD-XXCD1234QWER65782", "name": "Video Streaming Service Plan", "description": "Video Streaming Service basic plan", @@ -84,7 +84,7 @@ private function createPlanParams(): array */ private function updatePlanParams(): array { - return Utils::jsonDecode('[ + return $this->jsonDecodeFunction()('[ { "op": "replace", "path": "/payment_preferences/payment_failure_threshold", @@ -98,7 +98,7 @@ private function updatePlanParams(): array */ private function updatePlanPricingParams(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "pricing_schemes": [ { "billing_cycle_sequence": 2, diff --git a/tests/Mocks/Requests/CatalogProducts.php b/tests/Mocks/Requests/CatalogProducts.php index 45286511..3d8762be 100644 --- a/tests/Mocks/Requests/CatalogProducts.php +++ b/tests/Mocks/Requests/CatalogProducts.php @@ -11,7 +11,7 @@ trait CatalogProducts */ private function createProductParams(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "name": "Video Streaming Service", "description": "Video streaming service", "type": "SERVICE", @@ -26,7 +26,7 @@ private function createProductParams(): array */ private function updateProductParams(): array { - return Utils::jsonDecode('[ + return $this->jsonDecodeFunction()('[ { "op": "replace", "path": "/description", diff --git a/tests/Mocks/Requests/Disputes.php b/tests/Mocks/Requests/Disputes.php index 8ad807ff..902d7eca 100644 --- a/tests/Mocks/Requests/Disputes.php +++ b/tests/Mocks/Requests/Disputes.php @@ -11,7 +11,7 @@ trait Disputes */ protected function updateDisputeParams(): array { - return Utils::jsonDecode('[ + return $this->jsonDecodeFunction()('[ { "op": "add", "path": "/partner_actions/-", diff --git a/tests/Mocks/Requests/DisputesActions.php b/tests/Mocks/Requests/DisputesActions.php index 92fbcb04..cb7d83ff 100644 --- a/tests/Mocks/Requests/DisputesActions.php +++ b/tests/Mocks/Requests/DisputesActions.php @@ -11,7 +11,7 @@ trait DisputesActions */ protected function acceptDisputeClaimParams(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "note": "Full refund to the customer.", "accept_claim_type": "REFUND" }', true); @@ -22,7 +22,7 @@ protected function acceptDisputeClaimParams(): array */ protected function acceptDisputeResolutionParams(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "note": "I am ok with the refund offered." }', true); } @@ -32,7 +32,7 @@ protected function acceptDisputeResolutionParams(): array */ protected function acknowledgeItemReturnedParams(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "note": "I have received the item back.", "acknowledgement_type": "ITEM_RECEIVED" }', true); diff --git a/tests/Mocks/Requests/Identity.php b/tests/Mocks/Requests/Identity.php index 92a0a657..3a79277e 100644 --- a/tests/Mocks/Requests/Identity.php +++ b/tests/Mocks/Requests/Identity.php @@ -8,7 +8,7 @@ trait Identity { private function mockCreateMerchantApplicationParams(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "redirect_uris": [ "https://example.com/callback", "https://example.com/callback2" @@ -29,7 +29,7 @@ private function mockCreateMerchantApplicationParams(): array private function mockSetAccountPropertiesParams(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "categories": [ { "name": "PAYMENT", diff --git a/tests/Mocks/Requests/Invoices.php b/tests/Mocks/Requests/Invoices.php index 0177c04c..67d509d6 100644 --- a/tests/Mocks/Requests/Invoices.php +++ b/tests/Mocks/Requests/Invoices.php @@ -11,7 +11,7 @@ trait Invoices */ private function createInvoiceParams(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "detail": { "invoice_number": "#123", "reference": "deal-ref", @@ -175,7 +175,7 @@ private function createInvoiceParams(): array */ private function updateInvoiceParams(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "id": "INV2-C82X-JNN9-Y6S5-CNXW", "status": "DRAFT", "detail": { @@ -375,7 +375,7 @@ private function updateInvoiceParams(): array */ private function cancelInvoiceParams(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "subject": "Invoice Cancelled", "note": "Cancelling the invoice", "send_to_invoicer": true, @@ -391,7 +391,7 @@ private function cancelInvoiceParams(): array */ private function generateQRCodeInvoiceParams(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "width": 400, "height": 400 }', true); @@ -402,7 +402,7 @@ private function generateQRCodeInvoiceParams(): array */ private function registerInvoicePaymentParams(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "width": 400, "height": 400 }', true); @@ -413,7 +413,7 @@ private function registerInvoicePaymentParams(): array */ private function refundInvoicePaymentParams(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "method": "BANK_TRANSFER", "refund_date": "2018-05-21", "amount": { @@ -428,7 +428,7 @@ private function refundInvoicePaymentParams(): array */ private function sendInvoiceParams(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "subject": "Payment due for the invoice #ABC-123", "note": "Please pay before the due date to avoid incurring late payment charges which will be adjusted in the next bill generated.", "send_to_invoicer": true, @@ -444,7 +444,7 @@ private function sendInvoiceParams(): array */ private function sendInvoiceReminderParams(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "subject": "Reminder: Payment due for the invoice #ABC-123", "note": "Please pay before the due date to avoid incurring late payment charges which will be adjusted in the next bill generated.", "send_to_invoicer": true, diff --git a/tests/Mocks/Requests/InvoicesSearch.php b/tests/Mocks/Requests/InvoicesSearch.php index 9e5b1531..434eab1e 100644 --- a/tests/Mocks/Requests/InvoicesSearch.php +++ b/tests/Mocks/Requests/InvoicesSearch.php @@ -11,7 +11,7 @@ trait InvoicesSearch */ private function invoiceSearchParams(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "total_amount_range": { "lower_amount": { "currency_code": "USD", diff --git a/tests/Mocks/Requests/InvoicesTemplates.php b/tests/Mocks/Requests/InvoicesTemplates.php index 5d2ea24a..1fda4231 100644 --- a/tests/Mocks/Requests/InvoicesTemplates.php +++ b/tests/Mocks/Requests/InvoicesTemplates.php @@ -11,7 +11,7 @@ trait InvoicesTemplates */ private function mockCreateInvoiceTemplateParams(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "default_template": true, "template_info": { "configuration": { @@ -241,7 +241,7 @@ private function mockCreateInvoiceTemplateParams(): array */ private function mockUpdateInvoiceTemplateParams(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "default_template": true, "template_info": { "configuration": { diff --git a/tests/Mocks/Requests/Orders.php b/tests/Mocks/Requests/Orders.php index a57f057e..08a18a24 100644 --- a/tests/Mocks/Requests/Orders.php +++ b/tests/Mocks/Requests/Orders.php @@ -11,7 +11,7 @@ trait Orders */ private function createOrderParams(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "intent": "CAPTURE", "purchase_units": [ { @@ -29,7 +29,7 @@ private function createOrderParams(): array */ private function updateOrderParams(): array { - return Utils::jsonDecode('[ + return $this->jsonDecodeFunction()('[ { "op": "replace", "path": "/purchase_units/@reference_id==\'PUHF\'/shipping/address", diff --git a/tests/Mocks/Requests/PartnerReferrals.php b/tests/Mocks/Requests/PartnerReferrals.php index d7597f67..2215c7c8 100644 --- a/tests/Mocks/Requests/PartnerReferrals.php +++ b/tests/Mocks/Requests/PartnerReferrals.php @@ -8,7 +8,7 @@ trait PartnerReferrals { private function mockCreatePartnerReferralParams(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "individual_owners": [ { "names": [ diff --git a/tests/Mocks/Requests/PaymentAuthorizations.php b/tests/Mocks/Requests/PaymentAuthorizations.php index 0d1d5670..856a43e9 100644 --- a/tests/Mocks/Requests/PaymentAuthorizations.php +++ b/tests/Mocks/Requests/PaymentAuthorizations.php @@ -11,7 +11,7 @@ trait PaymentAuthorizations */ private function mockCaptureAuthorizedPaymentParams(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "amount": { "value": "10.99", "currency_code": "USD" @@ -27,7 +27,7 @@ private function mockCaptureAuthorizedPaymentParams(): array */ private function mockReAuthorizeAuthorizedPaymentParams(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "amount": { "value": "10.99", "currency_code": "USD" diff --git a/tests/Mocks/Requests/PaymentCaptures.php b/tests/Mocks/Requests/PaymentCaptures.php index adf81d1a..8d651703 100644 --- a/tests/Mocks/Requests/PaymentCaptures.php +++ b/tests/Mocks/Requests/PaymentCaptures.php @@ -11,7 +11,7 @@ trait PaymentCaptures */ private function mockRefundCapturedPaymentParams(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "amount": { "value": "10.99", "currency_code": "USD" diff --git a/tests/Mocks/Requests/PaymentExperienceWebProfiles.php b/tests/Mocks/Requests/PaymentExperienceWebProfiles.php index 28fcc16a..727e131d 100644 --- a/tests/Mocks/Requests/PaymentExperienceWebProfiles.php +++ b/tests/Mocks/Requests/PaymentExperienceWebProfiles.php @@ -11,7 +11,7 @@ trait PaymentExperienceWebProfiles */ private function mockCreateWebProfileParams(): array { - return Utils::jsonDecode('[ + return $this->jsonDecodeFunction()('[ { "id": "XP-GCUV-X35G-HNEY-5MJY", "name": "exampleProfile", @@ -64,7 +64,7 @@ private function mockCreateWebProfileParams(): array */ private function partiallyUpdateWebProfileParams(): array { - return Utils::jsonDecode('[ + return $this->jsonDecodeFunction()('[ { "op": "add", "path": "/presentation/brand_name", @@ -82,7 +82,7 @@ private function partiallyUpdateWebProfileParams(): array */ private function updateWebProfileParams(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "name": "exampleProfile", "presentation": { "logo_image": "https://example.com/logo_image/" diff --git a/tests/Mocks/Requests/PaymentMethodsTokens.php b/tests/Mocks/Requests/PaymentMethodsTokens.php index 202728ee..875575d6 100644 --- a/tests/Mocks/Requests/PaymentMethodsTokens.php +++ b/tests/Mocks/Requests/PaymentMethodsTokens.php @@ -11,7 +11,7 @@ trait PaymentMethodsTokens */ private function mockCreatePaymentSetupTokensParams(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "payment_source": { "card": { "number": "4111111111111111", @@ -41,7 +41,7 @@ private function mockCreatePaymentSetupTokensParams(): array */ private function mockCreatePaymentSetupPayPalParams(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "payment_source": { "paypal": { "description": "Description for PayPal to be shown to PayPal payer", diff --git a/tests/Mocks/Requests/Payouts.php b/tests/Mocks/Requests/Payouts.php index 5f9b6fa9..37e4efae 100644 --- a/tests/Mocks/Requests/Payouts.php +++ b/tests/Mocks/Requests/Payouts.php @@ -11,7 +11,7 @@ trait Payouts */ private function mockCreateBatchPayoutParams(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "sender_batch_header": { "sender_batch_id": "Payouts_2018_100007", "email_subject": "You have a payout!", diff --git a/tests/Mocks/Requests/ReferencedPayouts.php b/tests/Mocks/Requests/ReferencedPayouts.php index 81f703d2..c6254239 100644 --- a/tests/Mocks/Requests/ReferencedPayouts.php +++ b/tests/Mocks/Requests/ReferencedPayouts.php @@ -11,7 +11,7 @@ trait ReferencedPayouts */ private function mockCreateReferencedBatchPayoutParams(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "referenced_payouts": [ { "reference_id": "2KP03934U4415543C", @@ -30,7 +30,7 @@ private function mockCreateReferencedBatchPayoutParams(): array */ private function mockCreateReferencedBatchPayoutItemParams(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "reference_id": "CAPTURETXNID", "reference_type": "TRANSACTION_ID" }', true); diff --git a/tests/Mocks/Requests/Subscriptions.php b/tests/Mocks/Requests/Subscriptions.php index f150f294..cdc88112 100644 --- a/tests/Mocks/Requests/Subscriptions.php +++ b/tests/Mocks/Requests/Subscriptions.php @@ -11,7 +11,7 @@ trait Subscriptions */ private function mockCreateSubscriptionParams(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "plan_id": "P-5ML4271244454362WXNWU5NQ", "start_time": "2018-11-01T00:00:00Z", "quantity": "20", @@ -59,7 +59,7 @@ private function mockCreateSubscriptionParams(): array */ private function mockUpdateSubscriptionParams(): array { - return Utils::jsonDecode('[ + return $this->jsonDecodeFunction()('[ { "op": "replace", "path": "/billing_info/outstanding_balance", @@ -76,7 +76,7 @@ private function mockUpdateSubscriptionParams(): array */ private function mockActivateSubscriptionParams() { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "reason": "Reactivating the subscription" }', true); } @@ -86,7 +86,7 @@ private function mockActivateSubscriptionParams() */ private function mockCancelSubscriptionParams() { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "reason": "Not satisfied with the service" }', true); } @@ -96,7 +96,7 @@ private function mockCancelSubscriptionParams() */ private function mockSuspendSubscriptionParams() { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "reason": "Item out of stock" }', true); } @@ -106,7 +106,7 @@ private function mockSuspendSubscriptionParams() */ private function mockCaptureSubscriptionPaymentParams() { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "note": "Charging as the balance reached the limit", "capture_type": "OUTSTANDING_BALANCE", "amount": { @@ -121,7 +121,7 @@ private function mockCaptureSubscriptionPaymentParams() */ private function mockUpdateSubscriptionItemsParams() { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "plan_id": "P-5ML4271244454362WXNWU5NQ", "shipping_amount": { "currency_code": "USD", diff --git a/tests/Mocks/Requests/Trackers.php b/tests/Mocks/Requests/Trackers.php index a5a45e27..276e20d7 100644 --- a/tests/Mocks/Requests/Trackers.php +++ b/tests/Mocks/Requests/Trackers.php @@ -11,7 +11,7 @@ trait Trackers */ private function mockUpdateTrackingDetailsParams(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "transaction_id": "8MC585209K746392H", "tracking_number": "443844607820", "status": "SHIPPED", @@ -24,7 +24,7 @@ private function mockUpdateTrackingDetailsParams(): array */ private function mockCreateTrackinginBatchesParams(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "trackers": [ { "transaction_id": "8MC585209K746392H", diff --git a/tests/Mocks/Requests/WebHooks.php b/tests/Mocks/Requests/WebHooks.php index 4e6495c8..07cd6a09 100644 --- a/tests/Mocks/Requests/WebHooks.php +++ b/tests/Mocks/Requests/WebHooks.php @@ -11,7 +11,7 @@ trait WebHooks */ private function mockCreateWebHookParams(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "url": "https://example.com/example_webhook", "event_types": [ { @@ -29,7 +29,7 @@ private function mockCreateWebHookParams(): array */ private function mockUpdateWebHookParams(): array { - return Utils::jsonDecode('[ + return $this->jsonDecodeFunction()('[ { "op": "replace", "path": "/url", @@ -52,7 +52,7 @@ private function mockUpdateWebHookParams(): array */ private function mockResendWebHookEventNotificationParams(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "webhook_ids": [ "12334456" ] @@ -64,7 +64,7 @@ private function mockResendWebHookEventNotificationParams(): array */ private function mockVerifyWebHookSignatureParams(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "transmission_id": "69cd13f0-d67a-11e5-baa3-778b53f4ae55", "transmission_time": "2016-02-18T20:01:35Z", "cert_url": "cert_url", diff --git a/tests/Mocks/Responses/BillingPlans.php b/tests/Mocks/Responses/BillingPlans.php index 3cec7e41..0b2c7c85 100644 --- a/tests/Mocks/Responses/BillingPlans.php +++ b/tests/Mocks/Responses/BillingPlans.php @@ -11,7 +11,7 @@ trait BillingPlans */ private function mockCreatePlansResponse(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "id": "P-5ML4271244454362WXNWU5NQ", "product_id": "PROD-XXCD1234QWER65782", "name": "Video Streaming Service Plan", @@ -118,7 +118,7 @@ private function mockCreatePlansResponse(): array */ private function mockListPlansResponse(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "total_items": 12, "total_pages": 6, "plans": [ @@ -183,7 +183,7 @@ private function mockListPlansResponse(): array */ private function mockGetPlansResponse(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "id": "P-5ML4271244454362WXNWU5NQ", "product_id": "PROD-XXCD1234QWER65782", "name": "Basic Plan", diff --git a/tests/Mocks/Responses/CatalogProducts.php b/tests/Mocks/Responses/CatalogProducts.php index cb0fa70e..20a49f17 100644 --- a/tests/Mocks/Responses/CatalogProducts.php +++ b/tests/Mocks/Responses/CatalogProducts.php @@ -11,7 +11,7 @@ trait CatalogProducts */ private function mockCreateCatalogProductsResponse(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "id": "PROD-XYAB12ABSB7868434", "name": "Video Streaming Service", "description": "Video streaming service", @@ -41,7 +41,7 @@ private function mockCreateCatalogProductsResponse(): array */ private function mockListCatalogProductsResponse(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "total_items": 20, "total_pages": 1, "products": [ @@ -97,7 +97,7 @@ private function mockListCatalogProductsResponse(): array */ private function mockGetCatalogProductsResponse(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "id": "72255d4849af8ed6e0df1173", "name": "Video Streaming Service", "description": "Video streaming service", diff --git a/tests/Mocks/Responses/Disputes.php b/tests/Mocks/Responses/Disputes.php index 62a72de4..a7ad86f8 100644 --- a/tests/Mocks/Responses/Disputes.php +++ b/tests/Mocks/Responses/Disputes.php @@ -11,7 +11,7 @@ trait Disputes */ private function mockListDisputesResponse(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "items": [ { "dispute_id": "PP-000-003-648-191", @@ -71,7 +71,7 @@ private function mockListDisputesResponse(): array */ private function mockGetDisputesResponse(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "dispute_id": "PP-D-4012", "create_time": "2019-04-11T04:18:00.000Z", "update_time": "2019-04-21T04:19:08.000Z", diff --git a/tests/Mocks/Responses/DisputesActions.php b/tests/Mocks/Responses/DisputesActions.php index ad817488..75650939 100644 --- a/tests/Mocks/Responses/DisputesActions.php +++ b/tests/Mocks/Responses/DisputesActions.php @@ -11,7 +11,7 @@ trait DisputesActions */ private function mockAcceptDisputesClaimResponse(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "links": [ { "rel": "self", @@ -27,7 +27,7 @@ private function mockAcceptDisputesClaimResponse(): array */ private function mockAcceptDisputesOfferResolutionResponse(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "links": [ { "rel": "self", @@ -43,7 +43,7 @@ private function mockAcceptDisputesOfferResolutionResponse(): array */ private function mockAcknowledgeItemReturnedResponse(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "links": [ { "rel": "self", diff --git a/tests/Mocks/Responses/Identity.php b/tests/Mocks/Responses/Identity.php index 6d7873a1..3d0f619c 100644 --- a/tests/Mocks/Responses/Identity.php +++ b/tests/Mocks/Responses/Identity.php @@ -8,7 +8,7 @@ trait Identity { private function mockShowProfileInfoResponse(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "address": { "street_address": "7917394 Annursnac Hill Road Unit 0C", "locality": "Ventura", @@ -21,7 +21,7 @@ private function mockShowProfileInfoResponse(): array private function mocklistUsersResponse(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "schemas": [ "http://example.com" ], @@ -88,7 +88,7 @@ private function mocklistUsersResponse(): array private function mocklistUserResponse(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "schemas": [ "http://example.com" ], @@ -145,7 +145,7 @@ private function mocklistUserResponse(): array private function mockCreateMerchantApplicationResponse(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "client_id": "AeTeCqaPp7JZBfUUb2d21cQ2KqyQGVhonfiUOJu99kgLhFFSrE59ruvhLOT4K3NzQoErgsUH6MY9uRqD", "client_secret": "cf136dc3c1fc93f31185e5885805d", "client_id_issued_at": 2893256800, @@ -174,7 +174,7 @@ private function mockCreateMerchantApplicationResponse(): array private function mockGetClientTokenResponse(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "client_token": "eyJicmFpbnRyZWUiOnsiYXV0aG9yaXphdGlvbkZpbmdlcnByaW50IjoiYjA0MWE2M2JlMTM4M2NlZGUxZTI3OWFlNDlhMWIyNzZlY2FjOTYzOWU2NjlhMGIzODQyYTdkMTY3NzcwYmY0OHxtZXJjaGFudF9pZD1yd3dua3FnMnhnNTZobTJuJnB1YmxpY19rZXk9czlic3BuaGtxMmYzaDk0NCZjcmVhdGVkX2F0PTIwMTgtMTEtMTRUMTE6MTg6MDAuMTU3WiIsInZlcnNpb24iOiIzLXBheXBhbCJ9LCJwYXlwYWwiOnsiYWNjZXNzVG9rZW4iOiJBMjFBQUhNVExyMmctVDlhSTJacUZHUmlFZ0ZFZGRHTGwxTzRlX0lvdk9ESVg2Q3pSdW5BVy02TzI2MjdiWUJ2cDNjQ0FNWi1lTFBNc2NDWnN0bDUyNHJyUGhUQklJNlBBIn19", "expires_in": 3600 }', true); diff --git a/tests/Mocks/Responses/Invoices.php b/tests/Mocks/Responses/Invoices.php index 08b400bb..f4abc6ce 100644 --- a/tests/Mocks/Responses/Invoices.php +++ b/tests/Mocks/Responses/Invoices.php @@ -11,7 +11,7 @@ trait Invoices */ private function mockGenerateInvoiceNumberResponse(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "invoice_number": "ee0044" }', true); } @@ -21,7 +21,7 @@ private function mockGenerateInvoiceNumberResponse(): array */ private function mockCreateInvoicesResponse(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "id": "INV2-Z56S-5LLA-Q52L-CPZ5", "status": "DRAFT", "detail": { @@ -262,7 +262,7 @@ private function mockCreateInvoicesResponse(): array */ private function mockListInvoicesResponse(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "total_items": 2, "total_pages": 1, "items": [ @@ -391,7 +391,7 @@ private function mockListInvoicesResponse(): array */ private function mockUpdateInvoicesResponse(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "id": "INV2-C82X-JNN9-Y6S5-CNXW", "status": "DRAFT", "detail": { @@ -622,7 +622,7 @@ private function mockUpdateInvoicesResponse(): array */ private function mockGetInvoicesResponse(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "id": "INV2-Z56S-5LLA-Q52L-CPZ5", "status": "DRAFT", "detail": { @@ -871,7 +871,7 @@ private function mockGenerateInvoiceQRCodeResponse(): string */ private function mockInvoiceRegisterPaymentResponse(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "payment_id": "EXTR-86F38350LX4353815" }', true); } @@ -881,7 +881,7 @@ private function mockInvoiceRegisterPaymentResponse(): array */ private function mockInvoiceRefundPaymentResponse(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "refund_id": "EXTR-2LG703375E477444T" }', true); } diff --git a/tests/Mocks/Responses/InvoicesSearch.php b/tests/Mocks/Responses/InvoicesSearch.php index 8bf03a70..d5e4a744 100644 --- a/tests/Mocks/Responses/InvoicesSearch.php +++ b/tests/Mocks/Responses/InvoicesSearch.php @@ -11,7 +11,7 @@ trait InvoicesSearch */ private function mockSearchInvoicesResponse(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "total_items": 6, "total_pages": 1, "items": [ diff --git a/tests/Mocks/Responses/InvoicesTemplates.php b/tests/Mocks/Responses/InvoicesTemplates.php index 50b3a661..5ff41d3e 100644 --- a/tests/Mocks/Responses/InvoicesTemplates.php +++ b/tests/Mocks/Responses/InvoicesTemplates.php @@ -11,7 +11,7 @@ trait InvoicesTemplates */ private function mockCreateInvoiceTemplateResponse(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "id": "TEMP-19V05281TU309413B", "name": "reference-temp", "default_template": true, @@ -299,7 +299,7 @@ private function mockCreateInvoiceTemplateResponse(): array */ private function mockListInvoiceTemplateResponse() { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "addresses": [ { "address_line_1": "1234 First Street", @@ -672,7 +672,7 @@ private function mockListInvoiceTemplateResponse() */ private function mockUpdateInvoiceTemplateResponse() { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "id": "TEMP-19V05281TU309413B", "name": "reference-temp", "default_template": true, @@ -960,7 +960,7 @@ private function mockUpdateInvoiceTemplateResponse() */ private function mockGetInvoiceTemplateResponse() { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "id": "TEMP-19V05281TU309413B", "name": "reference-temp", "default_template": true, diff --git a/tests/Mocks/Responses/Orders.php b/tests/Mocks/Responses/Orders.php index 0dcc35db..774f8895 100644 --- a/tests/Mocks/Responses/Orders.php +++ b/tests/Mocks/Responses/Orders.php @@ -11,7 +11,7 @@ trait Orders */ public function mockCreateOrdersResponse(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "id": "5O190127TN364715T", "status": "CREATED", "links": [ @@ -52,7 +52,7 @@ public function mockUpdateOrdersResponse() */ public function mockOrderDetailsResponse(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "id": "5O190127TN364715T", "status": "PAYER_ACTION_REQUIRED", "intent": "CAPTURE", @@ -95,7 +95,7 @@ public function mockOrderDetailsResponse(): array */ public function mockOrderPaymentAuthorizedResponse(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "id": "5O190127TN364715T", "status": "COMPLETED", "payer": { @@ -180,7 +180,7 @@ public function mockOrderPaymentAuthorizedResponse(): array */ public function mockOrderPaymentCapturedResponse(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "id": "5O190127TN364715T", "status": "COMPLETED", "payer": { @@ -267,7 +267,7 @@ public function mockOrderPaymentCapturedResponse(): array private function mockConfirmOrderResponse() { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "id": "5O190127TN364715T", "status": "PAYER_ACTION_REQUIRED", "payment_source": { diff --git a/tests/Mocks/Responses/PartnerReferrals.php b/tests/Mocks/Responses/PartnerReferrals.php index b499e65c..8e690891 100644 --- a/tests/Mocks/Responses/PartnerReferrals.php +++ b/tests/Mocks/Responses/PartnerReferrals.php @@ -8,7 +8,7 @@ trait PartnerReferrals { private function mockCreatePartnerReferralsResponse(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "links": [ { "href": "https://uri.paypal.com/v2/customer/partner-referrals/ZjcyODU4ZWYtYTA1OC00ODIwLTk2M2EtOTZkZWQ4NmQwYzI3RU12cE5xa0xMRmk1NWxFSVJIT1JlTFdSbElCbFU1Q3lhdGhESzVQcU9iRT0=", @@ -26,7 +26,7 @@ private function mockCreatePartnerReferralsResponse(): array private function mockShowReferralDataResponse(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "partner_referral_id": "ZjcyODU4ZWYtYTA1OC00ODIwLTk2M2EtOTZkZWQ4NmQwYzI3RU12cE5xa0xMRmk1NWxFSVJIT1JlTFdSbElCbFU1Q3lhdGhESzVQcU9iRT0=", "submitter_payer_id": "RFYUH2QQDGUQU", "referral_data": { diff --git a/tests/Mocks/Responses/PaymentAuthorizations.php b/tests/Mocks/Responses/PaymentAuthorizations.php index e35a4a43..b6f5d86b 100644 --- a/tests/Mocks/Responses/PaymentAuthorizations.php +++ b/tests/Mocks/Responses/PaymentAuthorizations.php @@ -11,7 +11,7 @@ trait PaymentAuthorizations */ private function mockGetAuthorizedPaymentDetailsResponse(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "id": "0VF52814937998046", "status": "AUTHORIZED", "amount": { @@ -59,7 +59,7 @@ private function mockGetAuthorizedPaymentDetailsResponse(): array */ private function mockCaptureAuthorizedPaymentResponse(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "id": "2GG279541U471931P", "status": "COMPLETED", "links": [ @@ -87,7 +87,7 @@ private function mockCaptureAuthorizedPaymentResponse(): array */ private function mockReAuthorizeAuthorizedPaymentResponse(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "id": "8AA831015G517922L", "status": "CREATED", "links": [ diff --git a/tests/Mocks/Responses/PaymentCaptures.php b/tests/Mocks/Responses/PaymentCaptures.php index d77eaefb..df251348 100644 --- a/tests/Mocks/Responses/PaymentCaptures.php +++ b/tests/Mocks/Responses/PaymentCaptures.php @@ -11,7 +11,7 @@ trait PaymentCaptures */ private function mockGetCapturedPaymentDetailsResponse(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "id": "2GG279541U471931P", "status": "COMPLETED", "status_details": {}, @@ -69,7 +69,7 @@ private function mockGetCapturedPaymentDetailsResponse(): array */ private function mockRefundCapturedPaymentResponse(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "id": "1JU08902781691411", "status": "COMPLETED", "links": [ diff --git a/tests/Mocks/Responses/PaymentExperienceWebProfiles.php b/tests/Mocks/Responses/PaymentExperienceWebProfiles.php index 8a8ea42a..8c9fb442 100644 --- a/tests/Mocks/Responses/PaymentExperienceWebProfiles.php +++ b/tests/Mocks/Responses/PaymentExperienceWebProfiles.php @@ -11,7 +11,7 @@ trait PaymentExperienceWebProfiles */ private function mockListWebProfilesResponse(): array { - return Utils::jsonDecode('[ + return $this->jsonDecodeFunction()('[ { "id": "XP-GCUV-X35G-HNEY-5MJY", "name": "exampleProfile", @@ -64,7 +64,7 @@ private function mockListWebProfilesResponse(): array */ private function mockWebProfileResponse(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "id": "XP-RFV4-PVD8-AGHJ-8E5J", "name": "exampleProfile", "temporary": false, diff --git a/tests/Mocks/Responses/PaymentMethodsTokens.php b/tests/Mocks/Responses/PaymentMethodsTokens.php index 655e1b0e..6574cc56 100644 --- a/tests/Mocks/Responses/PaymentMethodsTokens.php +++ b/tests/Mocks/Responses/PaymentMethodsTokens.php @@ -11,7 +11,7 @@ trait PaymentMethodsTokens */ private function mockCreatePaymentMethodsTokenResponse(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "id": "8kk8451t", "customer": { "id": "customer_4029352050" @@ -54,7 +54,7 @@ private function mockCreatePaymentMethodsTokenResponse(): array */ private function mockListPaymentMethodsTokensResponse(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "customer": { "id": "customer_4029352050" }, @@ -298,7 +298,7 @@ private function mockListPaymentMethodsTokensResponse(): array */ private function mockCreatePaymentSetupTokenResponse(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "payment_source": { "card": { "number": "4111111111111111", @@ -328,7 +328,7 @@ private function mockCreatePaymentSetupTokenResponse(): array */ private function mockListPaymentSetupTokenResponse(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "id": "5C991763VB2781612", "customer": { "id": "customer_4029352050" diff --git a/tests/Mocks/Responses/PaymentRefunds.php b/tests/Mocks/Responses/PaymentRefunds.php index 110b2f03..33ba6c5d 100644 --- a/tests/Mocks/Responses/PaymentRefunds.php +++ b/tests/Mocks/Responses/PaymentRefunds.php @@ -11,7 +11,7 @@ trait PaymentRefunds */ private function mockGetRefundDetailsResponse(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "id": "1JU08902781691411", "amount": { "value": "10.99", diff --git a/tests/Mocks/Responses/Payouts.php b/tests/Mocks/Responses/Payouts.php index 793956bc..1bd88f80 100644 --- a/tests/Mocks/Responses/Payouts.php +++ b/tests/Mocks/Responses/Payouts.php @@ -11,7 +11,7 @@ trait Payouts */ private function mockCreateBatchPayoutResponse(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "batch_header": { "sender_batch_header": { "sender_batch_id": "Payouts_2018_100008", @@ -29,7 +29,7 @@ private function mockCreateBatchPayoutResponse(): array */ private function showBatchPayoutResponse(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "batch_header": { "payout_batch_id": "FYXMPQTX4JC9N", "batch_status": "PROCESSING", @@ -212,7 +212,7 @@ private function showBatchPayoutResponse(): array */ private function showBatchPayoutItemResponse(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "payout_item_id": "8AELMXH8UB2P8", "transaction_id": "0C413693MN970190K", "activity_id": "0E158638XS0329106", @@ -253,7 +253,7 @@ private function showBatchPayoutItemResponse(): array */ private function mockCancelUnclaimedBatchItemResponse(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "payout_item_id": "5KUDKLF8SDC7S", "transaction_id": "1DG93452WK758815H", "activity_id": "0E158638XS0329101", diff --git a/tests/Mocks/Responses/ReferencedPayouts.php b/tests/Mocks/Responses/ReferencedPayouts.php index d722e204..074bcf4f 100644 --- a/tests/Mocks/Responses/ReferencedPayouts.php +++ b/tests/Mocks/Responses/ReferencedPayouts.php @@ -11,7 +11,7 @@ trait ReferencedPayouts */ private function mockCreateReferencedBatchPayoutResponse(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "links": [ { "href": "https://api-m.sandbox.paypal.com/v1/payments/referenced-payouts/CDZEC5MJ8R5HY", @@ -27,7 +27,7 @@ private function mockCreateReferencedBatchPayoutResponse(): array */ private function mockShowReferencedBatchPayoutResponse(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "referenced_payouts": [ { "item_id": "dVeQhMc5Ck5WPw2gWYDLzh3qM2Dp1XbRlZb9fDouzLzDhx1eMYYTFe3syHEKKx4=", @@ -93,7 +93,7 @@ private function mockShowReferencedBatchPayoutResponse(): array */ private function mockCreateReferencedBatchPayoutItemResponse(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "item_id": "SOMEITEMID", "links": [ { @@ -110,7 +110,7 @@ private function mockCreateReferencedBatchPayoutItemResponse(): array */ private function mockShowReferencedBatchPayoutItemResponse(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "item_id": "SOMEITEMID", "processing_state": { "status": "PROCESSING" diff --git a/tests/Mocks/Responses/Reporting.php b/tests/Mocks/Responses/Reporting.php index a0d1b8f1..d2cfb609 100644 --- a/tests/Mocks/Responses/Reporting.php +++ b/tests/Mocks/Responses/Reporting.php @@ -11,7 +11,7 @@ trait Reporting */ private function mockListTransactionsResponse(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "transaction_details": [ { "transaction_info": { @@ -169,7 +169,7 @@ private function mockListTransactionsResponse(): array */ private function mockListBalancesResponse(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "balance": { "currency": "USD", "primary": true, diff --git a/tests/Mocks/Responses/Subscriptions.php b/tests/Mocks/Responses/Subscriptions.php index e13c0ed0..b8343b2d 100644 --- a/tests/Mocks/Responses/Subscriptions.php +++ b/tests/Mocks/Responses/Subscriptions.php @@ -11,7 +11,7 @@ trait Subscriptions */ private function mockCreateSubscriptionResponse(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "id": "I-BW452GLLEP1G", "status": "APPROVAL_PENDING", "status_update_time": "2018-12-10T21:20:49Z", @@ -69,7 +69,7 @@ private function mockCreateSubscriptionResponse(): array */ private function mockGetSubscriptionDetailsResponse(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "id": "I-BW452GLLEP1G", "plan_id": "P-5ML4271244454362WXNWU5NQ", "start_time": "2019-04-10T07:00:00Z", @@ -176,7 +176,7 @@ private function mockGetSubscriptionDetailsResponse(): array */ private function mockUpdateSubscriptionItemsResponse(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "plan_id": "P-5ML4271244454362WXNWU5NQ", "effective_time": "2018-11-01T00:00:00Z", "shipping_amount": { @@ -211,7 +211,7 @@ private function mockUpdateSubscriptionItemsResponse(): array */ private function mockListSubscriptionTransactionsResponse(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "transactions": [ { "id": "TRFGHNJKOIIOJKL", diff --git a/tests/Mocks/Responses/Trackers.php b/tests/Mocks/Responses/Trackers.php index a0774ecd..44bd2633 100644 --- a/tests/Mocks/Responses/Trackers.php +++ b/tests/Mocks/Responses/Trackers.php @@ -11,7 +11,7 @@ trait Trackers */ private function mockGetTrackingDetailsResponse(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "transaction_id": "8MC585209K746392H", "tracking_number": "443844607820", "status": "SHIPPED", @@ -40,7 +40,7 @@ private function mockGetTrackingDetailsResponse(): array */ private function mockCreateTrackinginBatchesResponse(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "tracker_identifiers": [ { "transaction_id": "8MC585209K746392H", diff --git a/tests/Mocks/Responses/WebHooks.php b/tests/Mocks/Responses/WebHooks.php index 51951e86..bc79de5d 100644 --- a/tests/Mocks/Responses/WebHooks.php +++ b/tests/Mocks/Responses/WebHooks.php @@ -11,7 +11,7 @@ trait WebHooks */ private function mockCreateWebHookResponse(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "id": "0EH40505U7160970P", "url": "https://example.com/example_webhook", "event_types": [ @@ -49,7 +49,7 @@ private function mockCreateWebHookResponse(): array */ private function mockListWebHookResponse(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "webhooks": [ { "id": "40Y916089Y8324740", @@ -122,7 +122,7 @@ private function mockListWebHookResponse(): array */ private function mockUpdateWebHookResponse(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "id": "0EH40505U7160970P", "url": "https://example.com/example_webhook_2", "event_types": [ @@ -156,7 +156,7 @@ private function mockUpdateWebHookResponse(): array */ private function mockGetWebHookResponse(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "id": "0EH40505U7160970P", "url": "https://example.com/example_webhook", "event_types": [ @@ -196,7 +196,7 @@ private function mockGetWebHookResponse(): array */ private function mockListWebHookEventsResponse(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "event_types": [ { "name": "PAYMENT.AUTHORIZATION.CREATED", @@ -222,7 +222,7 @@ private function mockListWebHookEventsResponse(): array */ private function mockListWebHookEventsTypesResponse(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "event_types": [ { "name": "PAYMENT.AUTHORIZATION.CREATED", @@ -257,7 +257,7 @@ private function mockListWebHookEventsTypesResponse(): array */ private function mockWebHookEventsListResponse(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "events": [ { "id": "8PT597110X687430LKGECATA", @@ -397,7 +397,7 @@ private function mockWebHookEventsListResponse(): array */ private function mockGetWebHookEventResponse(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "id": "8PT597110X687430LKGECATA", "create_time": "2013-06-25T21:41:28Z", "resource_type": "authorization", @@ -462,7 +462,7 @@ private function mockGetWebHookEventResponse(): array */ private function mockResendWebHookEventNotificationResponse(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "id": "8PT597110X687430LKGECATA", "create_time": "2013-06-25T21:41:28Z", "resource_type": "authorization", @@ -527,7 +527,7 @@ private function mockResendWebHookEventNotificationResponse(): array */ private function mockVerifyWebHookSignatureResponse(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "verification_status": "SUCCESS" }', true); } diff --git a/tests/Unit/Client/BillingPlansTest.php b/tests/Unit/Client/BillingPlansTest.php index 70bf72da..77480d20 100644 --- a/tests/Unit/Client/BillingPlansTest.php +++ b/tests/Unit/Client/BillingPlansTest.php @@ -31,7 +31,7 @@ public function it_can_create_a_billing_plan() $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'post'); - $this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); } /** @test */ @@ -50,7 +50,7 @@ public function it_can_list_billing_plans() $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'get'); - $this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); } /** @test */ @@ -70,7 +70,7 @@ public function it_can_update_a_billing_plan() $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'patch'); - $this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->patch($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->patch($expectedEndpoint, $expectedParams)->getBody(), true)); } /** @test */ @@ -89,7 +89,7 @@ public function it_can_show_details_for_a_billing_plan() $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'get'); - $this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); } /** @test */ @@ -108,7 +108,7 @@ public function it_can_activate_a_billing_plan() $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'post'); - $this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); } /** @test */ @@ -127,7 +127,7 @@ public function it_can_deactivate_a_billing_plan() $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'post'); - $this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); } /** @test */ @@ -147,6 +147,6 @@ public function it_can_update_pricing_for_a_billing_plan() $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'post'); - $this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); } } diff --git a/tests/Unit/Client/CatalogProductsTest.php b/tests/Unit/Client/CatalogProductsTest.php index 4cb42e02..ec277e9b 100644 --- a/tests/Unit/Client/CatalogProductsTest.php +++ b/tests/Unit/Client/CatalogProductsTest.php @@ -31,7 +31,7 @@ public function it_can_create_a_product() $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'post'); - $this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); } /** @test */ @@ -50,7 +50,7 @@ public function it_can_list_products() $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'get'); - $this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); } /** @test */ @@ -70,7 +70,7 @@ public function it_can_update_a_product() $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'patch'); - $this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->patch($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->patch($expectedEndpoint, $expectedParams)->getBody(), true)); } /** @test */ @@ -89,6 +89,6 @@ public function it_can_get_details_for_a_product() $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'get'); - $this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); } } diff --git a/tests/Unit/Client/DisputeActionsTest.php b/tests/Unit/Client/DisputeActionsTest.php index 00b279c2..ce460165 100644 --- a/tests/Unit/Client/DisputeActionsTest.php +++ b/tests/Unit/Client/DisputeActionsTest.php @@ -31,7 +31,7 @@ public function it_can_accept_dispute_claim() $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'post'); - $this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); } /** @test */ @@ -51,7 +51,7 @@ public function it_can_accept_dispute_offer_resolution() $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'post'); - $this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); } /** @test */ @@ -71,6 +71,6 @@ public function it_can_acknowledge_item_is_returned_for_raised_dispute() $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'post'); - $this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); } } diff --git a/tests/Unit/Client/DisputesTest.php b/tests/Unit/Client/DisputesTest.php index a0896984..e19b8ece 100644 --- a/tests/Unit/Client/DisputesTest.php +++ b/tests/Unit/Client/DisputesTest.php @@ -30,7 +30,7 @@ public function it_can_list_disputes() $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'get'); - $this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); } /** @test */ @@ -50,7 +50,7 @@ public function it_can_partially_update_a_dispute() $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'patch'); - $this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->patch($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->patch($expectedEndpoint, $expectedParams)->getBody(), true)); } /** @test */ @@ -69,6 +69,6 @@ public function it_can_get_details_for_a_dispute() $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'get'); - $this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); } } diff --git a/tests/Unit/Client/IdentityTest.php b/tests/Unit/Client/IdentityTest.php index bc6c0bb6..0d1609e9 100644 --- a/tests/Unit/Client/IdentityTest.php +++ b/tests/Unit/Client/IdentityTest.php @@ -30,6 +30,6 @@ public function it_can_user_profile_details() $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'get'); - $this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); } } diff --git a/tests/Unit/Client/InvoicesSearchTest.php b/tests/Unit/Client/InvoicesSearchTest.php index 540c0cee..12504c7f 100644 --- a/tests/Unit/Client/InvoicesSearchTest.php +++ b/tests/Unit/Client/InvoicesSearchTest.php @@ -31,6 +31,6 @@ public function it_can_search_invoices() $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'post'); - $this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); } } diff --git a/tests/Unit/Client/InvoicesTemplatesTest.php b/tests/Unit/Client/InvoicesTemplatesTest.php index ae09c0a2..ff3c7609 100644 --- a/tests/Unit/Client/InvoicesTemplatesTest.php +++ b/tests/Unit/Client/InvoicesTemplatesTest.php @@ -31,7 +31,7 @@ public function it_can_create_invoice_template() $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'post'); - $this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); } /** @test */ @@ -50,7 +50,7 @@ public function it_can_list_invoice_templates() $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'get'); - $this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); } /** @test */ @@ -69,7 +69,7 @@ public function it_can_delete_an_invoice_template() $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'delete'); - $this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->delete($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->delete($expectedEndpoint, $expectedParams)->getBody(), true)); } /** @test */ @@ -89,7 +89,7 @@ public function it_can_update_an_invoice_template() $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'put'); - $this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->put($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->put($expectedEndpoint, $expectedParams)->getBody(), true)); } /** @test */ @@ -108,6 +108,6 @@ public function it_can_get_details_for_an_invoice_template() $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'get'); - $this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); } } diff --git a/tests/Unit/Client/InvoicesTest.php b/tests/Unit/Client/InvoicesTest.php index ffaaf18e..3b4967f8 100644 --- a/tests/Unit/Client/InvoicesTest.php +++ b/tests/Unit/Client/InvoicesTest.php @@ -30,7 +30,7 @@ public function it_can_generate_unique_invoice_number() $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'post'); - $this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); } /** @test */ @@ -50,7 +50,7 @@ public function it_can_create_a_draft_invoice() $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'post'); - $this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); } /** @test */ @@ -69,7 +69,7 @@ public function it_can_list_current_invoices() $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'get'); - $this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); } /** @test */ @@ -88,7 +88,7 @@ public function it_can_delete_an_invoice() $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'delete'); - $this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->delete($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->delete($expectedEndpoint, $expectedParams)->getBody(), true)); } /** @test */ @@ -108,7 +108,7 @@ public function it_can_update_an_invoice() $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'put'); - $this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->put($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->put($expectedEndpoint, $expectedParams)->getBody(), true)); } /** @test */ @@ -127,7 +127,7 @@ public function it_can_show_details_for_an_invoice() $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'get'); - $this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); } /** @test */ @@ -147,7 +147,7 @@ public function it_can_cancel_an_invoice() $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'post'); - $this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); } /** @test */ @@ -167,7 +167,7 @@ public function it_can_generate_qr_code_for_invoice() $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'post'); - $this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); } /** @test */ @@ -187,7 +187,7 @@ public function it_can_register_payment_for_invoice() $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'post'); - $this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); } /** @test */ @@ -206,7 +206,7 @@ public function it_can_delete_payment_for_invoice() $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'delete'); - $this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->delete($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->delete($expectedEndpoint, $expectedParams)->getBody(), true)); } /** @test */ @@ -226,7 +226,7 @@ public function it_can_refund_payment_for_invoice() $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'post'); - $this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); } /** @test */ @@ -245,7 +245,7 @@ public function it_can_delete_refund_for_invoice() $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'delete'); - $this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->delete($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->delete($expectedEndpoint, $expectedParams)->getBody(), true)); } /** @test */ @@ -265,7 +265,7 @@ public function it_can_send_an_invoice() $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'post'); - $this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); } /** @test */ @@ -285,6 +285,6 @@ public function it_can_send_reminder_for_an_invoice() $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'post'); - $this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); } } diff --git a/tests/Unit/Client/OrdersTest.php b/tests/Unit/Client/OrdersTest.php index fccb25ab..76291ca7 100644 --- a/tests/Unit/Client/OrdersTest.php +++ b/tests/Unit/Client/OrdersTest.php @@ -31,6 +31,6 @@ public function it_can_create_an_order() $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'post'); - $this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); } } diff --git a/tests/Unit/Client/PartnerReferralsTest.php b/tests/Unit/Client/PartnerReferralsTest.php index 1d1f284d..b4891021 100644 --- a/tests/Unit/Client/PartnerReferralsTest.php +++ b/tests/Unit/Client/PartnerReferralsTest.php @@ -31,7 +31,7 @@ public function it_can_create_partner_referral() $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'post'); - $this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); } /** @test */ @@ -50,6 +50,6 @@ public function it_can_get_referral_details() $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'get'); - $this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); } } diff --git a/tests/Unit/Client/PaymentAuthorizationsTest.php b/tests/Unit/Client/PaymentAuthorizationsTest.php index 02b6e4f3..075b6df4 100644 --- a/tests/Unit/Client/PaymentAuthorizationsTest.php +++ b/tests/Unit/Client/PaymentAuthorizationsTest.php @@ -30,7 +30,7 @@ public function it_can_show_details_for_an_authorized_payment() $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'get'); - $this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); } /** @test */ @@ -50,7 +50,7 @@ public function it_can_capture_an_authorized_payment() $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'post'); - $this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); } /** @test */ @@ -70,7 +70,7 @@ public function it_can_reauthorize_an_authorized_payment() $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'post'); - $this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); } /** @test */ @@ -89,6 +89,6 @@ public function it_can_void_an_authorized_payment() $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'post'); - $this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); } } diff --git a/tests/Unit/Client/PaymentCapturesTest.php b/tests/Unit/Client/PaymentCapturesTest.php index 9f28d79b..de42b707 100644 --- a/tests/Unit/Client/PaymentCapturesTest.php +++ b/tests/Unit/Client/PaymentCapturesTest.php @@ -30,7 +30,7 @@ public function it_can_show_details_for_a_captured_payment() $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'get'); - $this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); } /** @test */ @@ -50,6 +50,6 @@ public function it_can_refund_a_captured_payment() $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'post'); - $this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); } } diff --git a/tests/Unit/Client/PaymentExperienceWebProfilesTest.php b/tests/Unit/Client/PaymentExperienceWebProfilesTest.php index 26ebf5be..5bb97af1 100644 --- a/tests/Unit/Client/PaymentExperienceWebProfilesTest.php +++ b/tests/Unit/Client/PaymentExperienceWebProfilesTest.php @@ -30,7 +30,7 @@ public function it_can_list_web_experience_profiles() $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'get'); - $this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); } /** @test */ @@ -51,7 +51,7 @@ public function it_can_create_web_experience_profile() $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'post'); - $this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); } /** @test */ @@ -70,7 +70,7 @@ public function it_can_delete_web_experience_profile() $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'delete'); - $this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->delete($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->delete($expectedEndpoint, $expectedParams)->getBody(), true)); } /** @test */ @@ -90,7 +90,7 @@ public function it_can_partially_update_web_experience_profile() $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'patch'); - $this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->patch($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->patch($expectedEndpoint, $expectedParams)->getBody(), true)); } /** @test */ @@ -110,7 +110,7 @@ public function it_can_fully_update_web_experience_profile() $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'patch'); - $this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->patch($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->patch($expectedEndpoint, $expectedParams)->getBody(), true)); } /** @test */ @@ -129,6 +129,6 @@ public function it_can_get_web_experience_profile_details() $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'get'); - $this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); } } diff --git a/tests/Unit/Client/PaymentRefundsTest.php b/tests/Unit/Client/PaymentRefundsTest.php index 073bee7b..5a6cc5e3 100644 --- a/tests/Unit/Client/PaymentRefundsTest.php +++ b/tests/Unit/Client/PaymentRefundsTest.php @@ -28,6 +28,6 @@ public function it_can_show_details_for_a_refund() $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'get'); - $this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); } } diff --git a/tests/Unit/Client/PayoutsTest.php b/tests/Unit/Client/PayoutsTest.php index 6413fa5f..841ef7d5 100644 --- a/tests/Unit/Client/PayoutsTest.php +++ b/tests/Unit/Client/PayoutsTest.php @@ -31,7 +31,7 @@ public function it_can_create_batch_payout() $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'post'); - $this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); } /** @test */ @@ -50,7 +50,7 @@ public function it_can_show_batch_payout_details() $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'get'); - $this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); } /** @test */ @@ -69,7 +69,7 @@ public function it_can_show_batch_payout_item_details() $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'get'); - $this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); } /** @test */ @@ -88,6 +88,6 @@ public function it_can_cancel_unclaimed_batch_payout_item() $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'get'); - $this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); } } diff --git a/tests/Unit/Client/ReferencedPayoutsTest.php b/tests/Unit/Client/ReferencedPayoutsTest.php index ff11d2a4..cc7094e6 100644 --- a/tests/Unit/Client/ReferencedPayoutsTest.php +++ b/tests/Unit/Client/ReferencedPayoutsTest.php @@ -33,7 +33,7 @@ public function it_can_create_referenced_batch_payout() $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'post'); - $this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); } /** @test */ @@ -52,7 +52,7 @@ public function it_can_list_items_referenced_in_batch_payout() $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'get'); - $this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); } /** @test */ @@ -74,7 +74,7 @@ public function it_can_create_referenced_batch_payout_item() $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'post'); - $this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); } /** @test */ @@ -96,6 +96,6 @@ public function it_can_show_referenced_payout_item_details() $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'get'); - $this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); } } diff --git a/tests/Unit/Client/ReportingTest.php b/tests/Unit/Client/ReportingTest.php index 5f37945d..a7479b64 100644 --- a/tests/Unit/Client/ReportingTest.php +++ b/tests/Unit/Client/ReportingTest.php @@ -31,7 +31,7 @@ public function it_can_list_transactions() $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'get'); $mockResponse = $mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(); - $this->assertArrayHasKey('transaction_details', Utils::jsonDecode($mockResponse, true)); + $this->assertArrayHasKey('transaction_details', $this->jsonDecodeFunction()($mockResponse, true)); } /** @test */ @@ -50,6 +50,6 @@ public function it_can_list_balances() $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'get'); - $this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); } } diff --git a/tests/Unit/Client/SubscriptionsTest.php b/tests/Unit/Client/SubscriptionsTest.php index eadd9887..12c9138e 100644 --- a/tests/Unit/Client/SubscriptionsTest.php +++ b/tests/Unit/Client/SubscriptionsTest.php @@ -31,7 +31,7 @@ public function it_can_create_a_subscription() $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'post'); - $this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); } /** @test */ @@ -51,7 +51,7 @@ public function it_can_update_a_subscription() $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'patch'); - $this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->patch($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->patch($expectedEndpoint, $expectedParams)->getBody(), true)); } /** @test */ @@ -70,7 +70,7 @@ public function it_can_show_details_for_a_subscription() $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'get'); - $this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); } /** @test */ @@ -90,7 +90,7 @@ public function it_can_activate_a_subscription() $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'post'); - $this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); } /** @test */ @@ -110,7 +110,7 @@ public function it_can_cancel_a_subscription() $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'post'); - $this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); } /** @test */ @@ -130,7 +130,7 @@ public function it_can_suspend_a_subscription() $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'post'); - $this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); } /** @test */ @@ -150,7 +150,7 @@ public function it_can_capture_payment_for_a_subscription() $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'post'); - $this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); } /** @test */ @@ -170,7 +170,7 @@ public function it_can_update_quantity_or_product_for_a_subscription() $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'post'); - $this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); } /** @test */ @@ -189,6 +189,6 @@ public function it_can_list_transactions_for_a_subscription() $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'get'); - $this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); } } diff --git a/tests/Unit/Client/TrackersTest.php b/tests/Unit/Client/TrackersTest.php index 6f85fec1..9c8327f9 100644 --- a/tests/Unit/Client/TrackersTest.php +++ b/tests/Unit/Client/TrackersTest.php @@ -30,7 +30,7 @@ public function it_can_get_tracking_details_for_tracking_id() $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'get'); - $this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); } /** @test */ @@ -50,7 +50,7 @@ public function it_can_update_tracking_details_for_tracking_id() $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'put'); - $this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->put($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->put($expectedEndpoint, $expectedParams)->getBody(), true)); } /** @test */ @@ -70,6 +70,6 @@ public function it_can_create_tracking_in_batches() $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'post'); - $this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); } } diff --git a/tests/Unit/Client/WebHooksEventsTest.php b/tests/Unit/Client/WebHooksEventsTest.php index 38e42c3c..e008359e 100644 --- a/tests/Unit/Client/WebHooksEventsTest.php +++ b/tests/Unit/Client/WebHooksEventsTest.php @@ -30,7 +30,7 @@ public function it_can_list_web_hooks_event_types() $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'get'); - $this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); } /** @test */ @@ -49,7 +49,7 @@ public function it_can_list_web_hooks_events() $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'get'); - $this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); } /** @test */ @@ -68,7 +68,7 @@ public function it_can_show_details_for_a_web_hooks_event() $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'get'); - $this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); } /** @test */ @@ -88,6 +88,6 @@ public function it_can_resend_notification_for_a_web_hooks_event() $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'get'); - $this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); } } diff --git a/tests/Unit/Client/WebHooksTest.php b/tests/Unit/Client/WebHooksTest.php index 8a08b235..91edb71b 100644 --- a/tests/Unit/Client/WebHooksTest.php +++ b/tests/Unit/Client/WebHooksTest.php @@ -31,7 +31,7 @@ public function it_can_create_a_web_hook() $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'post'); - $this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); } /** @test */ @@ -50,7 +50,7 @@ public function it_can_list_web_hooks() $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'get'); - $this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); } /** @test */ @@ -69,7 +69,7 @@ public function it_can_delete_a_web_hook() $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'delete'); - $this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->delete($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->delete($expectedEndpoint, $expectedParams)->getBody(), true)); } /** @test */ @@ -89,7 +89,7 @@ public function it_can_update_a_web_hook() $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'patch'); - $this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->patch($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->patch($expectedEndpoint, $expectedParams)->getBody(), true)); } /** @test */ @@ -108,7 +108,7 @@ public function it_can_show_details_for_a_web_hook() $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'get'); - $this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); } /** @test */ @@ -127,6 +127,6 @@ public function it_can_list_web_hooks_events() $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'get'); - $this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); } } diff --git a/tests/Unit/Client/WebHooksVerificationTest.php b/tests/Unit/Client/WebHooksVerificationTest.php index d888ccc1..c3ef2248 100644 --- a/tests/Unit/Client/WebHooksVerificationTest.php +++ b/tests/Unit/Client/WebHooksVerificationTest.php @@ -31,6 +31,6 @@ public function it_can_verify_web_hook_signature() $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'post'); - $this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); } } diff --git a/tests/Unit/ClientTest.php b/tests/Unit/ClientTest.php index c44c700d..1a060dc3 100644 --- a/tests/Unit/ClientTest.php +++ b/tests/Unit/ClientTest.php @@ -36,6 +36,6 @@ public function it_can_get_access_token() $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams); - $this->assertEquals($expectedResponse, Utils::jsonDecode($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); } }