From 442862f0a3c23dcbfacddd4e841e0b35cc262e3d Mon Sep 17 00:00:00 2001 From: Raza Mehdi Date: Sat, 30 Sep 2023 22:25:14 +0500 Subject: [PATCH] Add selector function for json_encode. --- .github/workflows/static-analysis.yml | 4 +-- .github/workflows/tests.yml | 2 +- Dockerfile | 2 +- composer.json | 1 + src/Services/Str.php | 4 +-- src/Traits/JsonDecodeSelector.php | 16 ---------- src/Traits/JsonEncodeDecodeSelector.php | 30 +++++++++++++++++++ src/Traits/PayPalRequest.php | 2 +- tests/MockClientClasses.php | 9 ++---- tests/Unit/AdapterTest.php | 2 +- 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 +- 33 files changed, 130 insertions(+), 118 deletions(-) delete mode 100644 src/Traits/JsonDecodeSelector.php create mode 100644 src/Traits/JsonEncodeDecodeSelector.php diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index aabc3f6c..1c606e00 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -7,7 +7,7 @@ jobs: strategy: fail-fast: false matrix: - php-versions: ['7.0', '7.1', '7.2', '7.3', '7.4'] + php-versions: ['7.1', '7.2', '7.3', '7.4'] steps: - name: Checkout uses: actions/checkout@v2 @@ -28,7 +28,7 @@ jobs: - name: Install Composer dependencies env: PHP_VERSION: ${{ matrix.php-versions }} - run: composer install --no-progress --prefer-dist --optimize-autoloader $(if [ "$PHP_VERSION" == "8.0" || "$PHP_VERSION" == "8.1" ]; then echo "--ignore-platform-reqs"; fi;) + run: composer install --no-progress --prefer-dist --optimize-autoloader - name: Run type checking analysis env: PHP_VERSION: ${{ matrix.php-versions }} diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index a84706f7..b5447ee2 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -32,7 +32,7 @@ jobs: - name: Install Composer dependencies env: PHP_VERSION: ${{ matrix.php-versions }} - run: composer install --no-progress --prefer-dist --optimize-autoloader $(if [ "$PHP_VERSION" == "8.0" || "$PHP_VERSION" == "8.1" ]; then echo "--ignore-platform-reqs"; fi;) + run: $(if [ "$PHP_VERSION" == "7.0" ]; then composer config --no-plugins allow-plugins.kylekatarnls/update-helper && fi;) composer install --no-progress --prefer-dist --optimize-autoloader - name: Run tests with code coverage env: PHP_VERSION: ${{ matrix.php-versions }} diff --git a/Dockerfile b/Dockerfile index c494e727..e2780e7e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM srmklive/docker-php-cli:7.2 +FROM srmklive/docker-php-cli:7.1 LABEL maintainer="Raza Mehdi" diff --git a/composer.json b/composer.json index 0de606cd..6415ce69 100644 --- a/composer.json +++ b/composer.json @@ -26,6 +26,7 @@ "nesbot/carbon": "~1.0|~2.0" }, "require-dev": { + "phpstan/phpstan": "~0.1|~1.0", "phpunit/phpunit": "^5.7|^6.0|^7.0|^8.0", "symfony/var-dumper": "~3.0|~4.0|~5.0" }, diff --git a/src/Services/Str.php b/src/Services/Str.php index 96f9bc4b..105f9214 100644 --- a/src/Services/Str.php +++ b/src/Services/Str.php @@ -3,11 +3,11 @@ namespace Srmklive\PayPal\Services; use GuzzleHttp\Utils; -use Srmklive\PayPal\Traits\JsonDecodeSelector; +use Srmklive\PayPal\Traits\JsonEncodeDecodeSelector; class Str extends \Illuminate\Support\Str { - use JsonDecodeSelector; + use JsonEncodeDecodeSelector; /** * Determine if a given value is valid JSON. diff --git a/src/Traits/JsonDecodeSelector.php b/src/Traits/JsonDecodeSelector.php deleted file mode 100644 index 357c40d2..00000000 --- a/src/Traits/JsonDecodeSelector.php +++ /dev/null @@ -1,16 +0,0 @@ -jsonEncodeFunction()($response) ), ]); @@ -58,9 +58,6 @@ private function mock_http_request($expectedResponse, $expectedEndpoint, $expect private function mock_client($expectedResponse, $expectedMethod, $token = false, $additionalMethod = null) { $set_method_name = 'setMethods'; - if (strpos(phpversion(), '8.1') !== false || strpos(phpversion(), '8.2') !== false) { - $set_method_name = 'onlyMethods'; - } $methods = [$expectedMethod, 'setApiCredentials']; $methods[] = ($token) ? 'getAccessToken' : ''; diff --git a/tests/Unit/AdapterTest.php b/tests/Unit/AdapterTest.php index 9d7a4420..358f40e5 100644 --- a/tests/Unit/AdapterTest.php +++ b/tests/Unit/AdapterTest.php @@ -32,7 +32,7 @@ public function it_throws_exception_if_invalid_credentials_are_provided() public function it_throws_exception_if_invalid_mode_is_provided() { $this->expectException(\RuntimeException::class); - $this->expectErrorMessage('Invalid configuration provided. Please provide valid configuration for PayPal API. You can also refer to the documentation at https://srmklive.github.io/laravel-paypal/docs.html to setup correct configuration.'); + $this->expectExceptionMessage('Invalid configuration provided. Please provide valid configuration for PayPal API. You can also refer to the documentation at https://srmklive.github.io/laravel-paypal/docs.html to setup correct configuration.'); $credentials = $this->getMockCredentials(); $credentials['mode'] = ''; diff --git a/tests/Unit/Client/BillingPlansTest.php b/tests/Unit/Client/BillingPlansTest.php index 77480d20..628947a1 100644 --- a/tests/Unit/Client/BillingPlansTest.php +++ b/tests/Unit/Client/BillingPlansTest.php @@ -29,7 +29,7 @@ public function it_can_create_a_billing_plan() 'json' => $this->createPlanParams(), ]; - $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'post'); + $mockHttpClient = $this->mock_http_request($this->jsonEncodeFunction()($expectedResponse), $expectedEndpoint, $expectedParams, 'post'); $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); } @@ -48,7 +48,7 @@ public function it_can_list_billing_plans() ], ]; - $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'get'); + $mockHttpClient = $this->mock_http_request($this->jsonEncodeFunction()($expectedResponse), $expectedEndpoint, $expectedParams, 'get'); $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); } @@ -68,7 +68,7 @@ public function it_can_update_a_billing_plan() 'json' => $this->updatePlanParams(), ]; - $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'patch'); + $mockHttpClient = $this->mock_http_request($this->jsonEncodeFunction()($expectedResponse), $expectedEndpoint, $expectedParams, 'patch'); $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->patch($expectedEndpoint, $expectedParams)->getBody(), true)); } @@ -87,7 +87,7 @@ public function it_can_show_details_for_a_billing_plan() ], ]; - $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'get'); + $mockHttpClient = $this->mock_http_request($this->jsonEncodeFunction()($expectedResponse), $expectedEndpoint, $expectedParams, 'get'); $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); } @@ -106,7 +106,7 @@ public function it_can_activate_a_billing_plan() ], ]; - $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'post'); + $mockHttpClient = $this->mock_http_request($this->jsonEncodeFunction()($expectedResponse), $expectedEndpoint, $expectedParams, 'post'); $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); } @@ -125,7 +125,7 @@ public function it_can_deactivate_a_billing_plan() ], ]; - $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'post'); + $mockHttpClient = $this->mock_http_request($this->jsonEncodeFunction()($expectedResponse), $expectedEndpoint, $expectedParams, 'post'); $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); } @@ -145,7 +145,7 @@ public function it_can_update_pricing_for_a_billing_plan() 'json' => $this->updatePlanPricingParams(), ]; - $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'post'); + $mockHttpClient = $this->mock_http_request($this->jsonEncodeFunction()($expectedResponse), $expectedEndpoint, $expectedParams, 'post'); $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 ec277e9b..211c95c8 100644 --- a/tests/Unit/Client/CatalogProductsTest.php +++ b/tests/Unit/Client/CatalogProductsTest.php @@ -29,7 +29,7 @@ public function it_can_create_a_product() 'json' => $this->createProductParams(), ]; - $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'post'); + $mockHttpClient = $this->mock_http_request($this->jsonEncodeFunction()($expectedResponse), $expectedEndpoint, $expectedParams, 'post'); $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); } @@ -48,7 +48,7 @@ public function it_can_list_products() ], ]; - $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'get'); + $mockHttpClient = $this->mock_http_request($this->jsonEncodeFunction()($expectedResponse), $expectedEndpoint, $expectedParams, 'get'); $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); } @@ -68,7 +68,7 @@ public function it_can_update_a_product() 'json' => $this->updateProductParams(), ]; - $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'patch'); + $mockHttpClient = $this->mock_http_request($this->jsonEncodeFunction()($expectedResponse), $expectedEndpoint, $expectedParams, 'patch'); $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->patch($expectedEndpoint, $expectedParams)->getBody(), true)); } @@ -87,7 +87,7 @@ public function it_can_get_details_for_a_product() ], ]; - $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'get'); + $mockHttpClient = $this->mock_http_request($this->jsonEncodeFunction()($expectedResponse), $expectedEndpoint, $expectedParams, 'get'); $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 ce460165..8866a054 100644 --- a/tests/Unit/Client/DisputeActionsTest.php +++ b/tests/Unit/Client/DisputeActionsTest.php @@ -29,7 +29,7 @@ public function it_can_accept_dispute_claim() 'json' => $this->acceptDisputeClaimParams(), ]; - $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'post'); + $mockHttpClient = $this->mock_http_request($this->jsonEncodeFunction()($expectedResponse), $expectedEndpoint, $expectedParams, 'post'); $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); } @@ -49,7 +49,7 @@ public function it_can_accept_dispute_offer_resolution() 'json' => $this->acceptDisputeResolutionParams(), ]; - $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'post'); + $mockHttpClient = $this->mock_http_request($this->jsonEncodeFunction()($expectedResponse), $expectedEndpoint, $expectedParams, 'post'); $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); } @@ -69,7 +69,7 @@ public function it_can_acknowledge_item_is_returned_for_raised_dispute() 'json' => $this->acknowledgeItemReturnedParams(), ]; - $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'post'); + $mockHttpClient = $this->mock_http_request($this->jsonEncodeFunction()($expectedResponse), $expectedEndpoint, $expectedParams, 'post'); $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 e19b8ece..cde084cd 100644 --- a/tests/Unit/Client/DisputesTest.php +++ b/tests/Unit/Client/DisputesTest.php @@ -28,7 +28,7 @@ public function it_can_list_disputes() ], ]; - $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'get'); + $mockHttpClient = $this->mock_http_request($this->jsonEncodeFunction()($expectedResponse), $expectedEndpoint, $expectedParams, 'get'); $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); } @@ -48,7 +48,7 @@ public function it_can_partially_update_a_dispute() 'json' => $this->updateDisputeParams(), ]; - $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'patch'); + $mockHttpClient = $this->mock_http_request($this->jsonEncodeFunction()($expectedResponse), $expectedEndpoint, $expectedParams, 'patch'); $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->patch($expectedEndpoint, $expectedParams)->getBody(), true)); } @@ -67,7 +67,7 @@ public function it_can_get_details_for_a_dispute() ], ]; - $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'get'); + $mockHttpClient = $this->mock_http_request($this->jsonEncodeFunction()($expectedResponse), $expectedEndpoint, $expectedParams, 'get'); $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 0d1609e9..06d098a1 100644 --- a/tests/Unit/Client/IdentityTest.php +++ b/tests/Unit/Client/IdentityTest.php @@ -28,7 +28,7 @@ public function it_can_user_profile_details() ], ]; - $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'get'); + $mockHttpClient = $this->mock_http_request($this->jsonEncodeFunction()($expectedResponse), $expectedEndpoint, $expectedParams, 'get'); $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 12504c7f..de212e17 100644 --- a/tests/Unit/Client/InvoicesSearchTest.php +++ b/tests/Unit/Client/InvoicesSearchTest.php @@ -29,7 +29,7 @@ public function it_can_search_invoices() 'json' => $this->invoiceSearchParams(), ]; - $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'post'); + $mockHttpClient = $this->mock_http_request($this->jsonEncodeFunction()($expectedResponse), $expectedEndpoint, $expectedParams, 'post'); $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 ff3c7609..1bfdc5e4 100644 --- a/tests/Unit/Client/InvoicesTemplatesTest.php +++ b/tests/Unit/Client/InvoicesTemplatesTest.php @@ -29,7 +29,7 @@ public function it_can_create_invoice_template() 'json' => $this->mockCreateInvoiceTemplateParams(), ]; - $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'post'); + $mockHttpClient = $this->mock_http_request($this->jsonEncodeFunction()($expectedResponse), $expectedEndpoint, $expectedParams, 'post'); $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); } @@ -48,7 +48,7 @@ public function it_can_list_invoice_templates() ], ]; - $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'get'); + $mockHttpClient = $this->mock_http_request($this->jsonEncodeFunction()($expectedResponse), $expectedEndpoint, $expectedParams, 'get'); $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); } @@ -67,7 +67,7 @@ public function it_can_delete_an_invoice_template() ], ]; - $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'delete'); + $mockHttpClient = $this->mock_http_request($this->jsonEncodeFunction()($expectedResponse), $expectedEndpoint, $expectedParams, 'delete'); $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->delete($expectedEndpoint, $expectedParams)->getBody(), true)); } @@ -87,7 +87,7 @@ public function it_can_update_an_invoice_template() 'json' => $this->mockUpdateInvoiceTemplateParams(), ]; - $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'put'); + $mockHttpClient = $this->mock_http_request($this->jsonEncodeFunction()($expectedResponse), $expectedEndpoint, $expectedParams, 'put'); $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->put($expectedEndpoint, $expectedParams)->getBody(), true)); } @@ -106,7 +106,7 @@ public function it_can_get_details_for_an_invoice_template() ], ]; - $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'get'); + $mockHttpClient = $this->mock_http_request($this->jsonEncodeFunction()($expectedResponse), $expectedEndpoint, $expectedParams, 'get'); $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 3b4967f8..59c434bf 100644 --- a/tests/Unit/Client/InvoicesTest.php +++ b/tests/Unit/Client/InvoicesTest.php @@ -28,7 +28,7 @@ public function it_can_generate_unique_invoice_number() ], ]; - $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'post'); + $mockHttpClient = $this->mock_http_request($this->jsonEncodeFunction()($expectedResponse), $expectedEndpoint, $expectedParams, 'post'); $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); } @@ -48,7 +48,7 @@ public function it_can_create_a_draft_invoice() 'json' => $this->createInvoiceParams(), ]; - $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'post'); + $mockHttpClient = $this->mock_http_request($this->jsonEncodeFunction()($expectedResponse), $expectedEndpoint, $expectedParams, 'post'); $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); } @@ -67,7 +67,7 @@ public function it_can_list_current_invoices() ], ]; - $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'get'); + $mockHttpClient = $this->mock_http_request($this->jsonEncodeFunction()($expectedResponse), $expectedEndpoint, $expectedParams, 'get'); $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); } @@ -86,7 +86,7 @@ public function it_can_delete_an_invoice() ], ]; - $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'delete'); + $mockHttpClient = $this->mock_http_request($this->jsonEncodeFunction()($expectedResponse), $expectedEndpoint, $expectedParams, 'delete'); $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->delete($expectedEndpoint, $expectedParams)->getBody(), true)); } @@ -106,7 +106,7 @@ public function it_can_update_an_invoice() 'json' => $this->updateInvoiceParams(), ]; - $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'put'); + $mockHttpClient = $this->mock_http_request($this->jsonEncodeFunction()($expectedResponse), $expectedEndpoint, $expectedParams, 'put'); $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->put($expectedEndpoint, $expectedParams)->getBody(), true)); } @@ -125,7 +125,7 @@ public function it_can_show_details_for_an_invoice() ], ]; - $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'get'); + $mockHttpClient = $this->mock_http_request($this->jsonEncodeFunction()($expectedResponse), $expectedEndpoint, $expectedParams, 'get'); $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); } @@ -145,7 +145,7 @@ public function it_can_cancel_an_invoice() 'json' => $this->cancelInvoiceParams(), ]; - $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'post'); + $mockHttpClient = $this->mock_http_request($this->jsonEncodeFunction()($expectedResponse), $expectedEndpoint, $expectedParams, 'post'); $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); } @@ -165,7 +165,7 @@ public function it_can_generate_qr_code_for_invoice() 'json' => $this->generateQRCodeInvoiceParams(), ]; - $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'post'); + $mockHttpClient = $this->mock_http_request($this->jsonEncodeFunction()($expectedResponse), $expectedEndpoint, $expectedParams, 'post'); $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); } @@ -185,7 +185,7 @@ public function it_can_register_payment_for_invoice() 'json' => $this->registerInvoicePaymentParams(), ]; - $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'post'); + $mockHttpClient = $this->mock_http_request($this->jsonEncodeFunction()($expectedResponse), $expectedEndpoint, $expectedParams, 'post'); $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); } @@ -204,7 +204,7 @@ public function it_can_delete_payment_for_invoice() ], ]; - $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'delete'); + $mockHttpClient = $this->mock_http_request($this->jsonEncodeFunction()($expectedResponse), $expectedEndpoint, $expectedParams, 'delete'); $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->delete($expectedEndpoint, $expectedParams)->getBody(), true)); } @@ -224,7 +224,7 @@ public function it_can_refund_payment_for_invoice() 'json' => $this->refundInvoicePaymentParams(), ]; - $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'post'); + $mockHttpClient = $this->mock_http_request($this->jsonEncodeFunction()($expectedResponse), $expectedEndpoint, $expectedParams, 'post'); $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); } @@ -243,7 +243,7 @@ public function it_can_delete_refund_for_invoice() ], ]; - $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'delete'); + $mockHttpClient = $this->mock_http_request($this->jsonEncodeFunction()($expectedResponse), $expectedEndpoint, $expectedParams, 'delete'); $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->delete($expectedEndpoint, $expectedParams)->getBody(), true)); } @@ -263,7 +263,7 @@ public function it_can_send_an_invoice() 'json' => $this->sendInvoiceParams(), ]; - $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'post'); + $mockHttpClient = $this->mock_http_request($this->jsonEncodeFunction()($expectedResponse), $expectedEndpoint, $expectedParams, 'post'); $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); } @@ -283,7 +283,7 @@ public function it_can_send_reminder_for_an_invoice() 'json' => $this->sendInvoiceReminderParams(), ]; - $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'post'); + $mockHttpClient = $this->mock_http_request($this->jsonEncodeFunction()($expectedResponse), $expectedEndpoint, $expectedParams, 'post'); $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 76291ca7..6355b29a 100644 --- a/tests/Unit/Client/OrdersTest.php +++ b/tests/Unit/Client/OrdersTest.php @@ -29,7 +29,7 @@ public function it_can_create_an_order() 'json' => $this->createOrderParams(), ]; - $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'post'); + $mockHttpClient = $this->mock_http_request($this->jsonEncodeFunction()($expectedResponse), $expectedEndpoint, $expectedParams, 'post'); $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 b4891021..53a8a3ce 100644 --- a/tests/Unit/Client/PartnerReferralsTest.php +++ b/tests/Unit/Client/PartnerReferralsTest.php @@ -29,7 +29,7 @@ public function it_can_create_partner_referral() 'json' => $this->mockCreatePartnerReferralParams(), ]; - $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'post'); + $mockHttpClient = $this->mock_http_request($this->jsonEncodeFunction()($expectedResponse), $expectedEndpoint, $expectedParams, 'post'); $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); } @@ -48,7 +48,7 @@ public function it_can_get_referral_details() ], ]; - $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'get'); + $mockHttpClient = $this->mock_http_request($this->jsonEncodeFunction()($expectedResponse), $expectedEndpoint, $expectedParams, 'get'); $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 075b6df4..435bb161 100644 --- a/tests/Unit/Client/PaymentAuthorizationsTest.php +++ b/tests/Unit/Client/PaymentAuthorizationsTest.php @@ -28,7 +28,7 @@ public function it_can_show_details_for_an_authorized_payment() ], ]; - $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'get'); + $mockHttpClient = $this->mock_http_request($this->jsonEncodeFunction()($expectedResponse), $expectedEndpoint, $expectedParams, 'get'); $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); } @@ -48,7 +48,7 @@ public function it_can_capture_an_authorized_payment() 'json' => $this->mockCaptureAuthorizedPaymentParams(), ]; - $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'post'); + $mockHttpClient = $this->mock_http_request($this->jsonEncodeFunction()($expectedResponse), $expectedEndpoint, $expectedParams, 'post'); $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); } @@ -68,7 +68,7 @@ public function it_can_reauthorize_an_authorized_payment() 'json' => $this->mockReAuthorizeAuthorizedPaymentParams(), ]; - $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'post'); + $mockHttpClient = $this->mock_http_request($this->jsonEncodeFunction()($expectedResponse), $expectedEndpoint, $expectedParams, 'post'); $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); } @@ -87,7 +87,7 @@ public function it_can_void_an_authorized_payment() ], ]; - $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'post'); + $mockHttpClient = $this->mock_http_request($this->jsonEncodeFunction()($expectedResponse), $expectedEndpoint, $expectedParams, 'post'); $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 de42b707..5901a786 100644 --- a/tests/Unit/Client/PaymentCapturesTest.php +++ b/tests/Unit/Client/PaymentCapturesTest.php @@ -28,7 +28,7 @@ public function it_can_show_details_for_a_captured_payment() ], ]; - $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'get'); + $mockHttpClient = $this->mock_http_request($this->jsonEncodeFunction()($expectedResponse), $expectedEndpoint, $expectedParams, 'get'); $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); } @@ -48,7 +48,7 @@ public function it_can_refund_a_captured_payment() 'json' => $this->mockRefundCapturedPaymentParams(), ]; - $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'post'); + $mockHttpClient = $this->mock_http_request($this->jsonEncodeFunction()($expectedResponse), $expectedEndpoint, $expectedParams, 'post'); $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 5bb97af1..b69734ed 100644 --- a/tests/Unit/Client/PaymentExperienceWebProfilesTest.php +++ b/tests/Unit/Client/PaymentExperienceWebProfilesTest.php @@ -28,7 +28,7 @@ public function it_can_list_web_experience_profiles() ], ]; - $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'get'); + $mockHttpClient = $this->mock_http_request($this->jsonEncodeFunction()($expectedResponse), $expectedEndpoint, $expectedParams, 'get'); $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); } @@ -49,7 +49,7 @@ public function it_can_create_web_experience_profile() 'json' => $this->mockCreateWebProfileParams(), ]; - $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'post'); + $mockHttpClient = $this->mock_http_request($this->jsonEncodeFunction()($expectedResponse), $expectedEndpoint, $expectedParams, 'post'); $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); } @@ -68,7 +68,7 @@ public function it_can_delete_web_experience_profile() ], ]; - $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'delete'); + $mockHttpClient = $this->mock_http_request($this->jsonEncodeFunction()($expectedResponse), $expectedEndpoint, $expectedParams, 'delete'); $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->delete($expectedEndpoint, $expectedParams)->getBody(), true)); } @@ -88,7 +88,7 @@ public function it_can_partially_update_web_experience_profile() 'json' => $this->partiallyUpdateWebProfileParams(), ]; - $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'patch'); + $mockHttpClient = $this->mock_http_request($this->jsonEncodeFunction()($expectedResponse), $expectedEndpoint, $expectedParams, 'patch'); $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->patch($expectedEndpoint, $expectedParams)->getBody(), true)); } @@ -108,7 +108,7 @@ public function it_can_fully_update_web_experience_profile() 'json' => $this->updateWebProfileParams(), ]; - $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'patch'); + $mockHttpClient = $this->mock_http_request($this->jsonEncodeFunction()($expectedResponse), $expectedEndpoint, $expectedParams, 'patch'); $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->patch($expectedEndpoint, $expectedParams)->getBody(), true)); } @@ -127,7 +127,7 @@ public function it_can_get_web_experience_profile_details() ], ]; - $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'get'); + $mockHttpClient = $this->mock_http_request($this->jsonEncodeFunction()($expectedResponse), $expectedEndpoint, $expectedParams, 'get'); $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 5a6cc5e3..3bdcb247 100644 --- a/tests/Unit/Client/PaymentRefundsTest.php +++ b/tests/Unit/Client/PaymentRefundsTest.php @@ -26,7 +26,7 @@ public function it_can_show_details_for_a_refund() ], ]; - $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'get'); + $mockHttpClient = $this->mock_http_request($this->jsonEncodeFunction()($expectedResponse), $expectedEndpoint, $expectedParams, 'get'); $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 841ef7d5..ca4972e8 100644 --- a/tests/Unit/Client/PayoutsTest.php +++ b/tests/Unit/Client/PayoutsTest.php @@ -29,7 +29,7 @@ public function it_can_create_batch_payout() 'json' => $this->mockCreateBatchPayoutParams(), ]; - $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'post'); + $mockHttpClient = $this->mock_http_request($this->jsonEncodeFunction()($expectedResponse), $expectedEndpoint, $expectedParams, 'post'); $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); } @@ -48,7 +48,7 @@ public function it_can_show_batch_payout_details() ], ]; - $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'get'); + $mockHttpClient = $this->mock_http_request($this->jsonEncodeFunction()($expectedResponse), $expectedEndpoint, $expectedParams, 'get'); $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); } @@ -67,7 +67,7 @@ public function it_can_show_batch_payout_item_details() ], ]; - $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'get'); + $mockHttpClient = $this->mock_http_request($this->jsonEncodeFunction()($expectedResponse), $expectedEndpoint, $expectedParams, 'get'); $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); } @@ -86,7 +86,7 @@ public function it_can_cancel_unclaimed_batch_payout_item() ], ]; - $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'get'); + $mockHttpClient = $this->mock_http_request($this->jsonEncodeFunction()($expectedResponse), $expectedEndpoint, $expectedParams, 'get'); $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 cc7094e6..97b7aaa3 100644 --- a/tests/Unit/Client/ReferencedPayoutsTest.php +++ b/tests/Unit/Client/ReferencedPayoutsTest.php @@ -31,7 +31,7 @@ public function it_can_create_referenced_batch_payout() 'json' => $this->mockCreateReferencedBatchPayoutParams(), ]; - $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'post'); + $mockHttpClient = $this->mock_http_request($this->jsonEncodeFunction()($expectedResponse), $expectedEndpoint, $expectedParams, 'post'); $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); } @@ -50,7 +50,7 @@ public function it_can_list_items_referenced_in_batch_payout() ], ]; - $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'get'); + $mockHttpClient = $this->mock_http_request($this->jsonEncodeFunction()($expectedResponse), $expectedEndpoint, $expectedParams, 'get'); $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); } @@ -72,7 +72,7 @@ public function it_can_create_referenced_batch_payout_item() 'json' => $this->mockCreateReferencedBatchPayoutItemParams(), ]; - $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'post'); + $mockHttpClient = $this->mock_http_request($this->jsonEncodeFunction()($expectedResponse), $expectedEndpoint, $expectedParams, 'post'); $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); } @@ -94,7 +94,7 @@ public function it_can_show_referenced_payout_item_details() 'json' => $this->mockCreateReferencedBatchPayoutItemParams(), ]; - $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'get'); + $mockHttpClient = $this->mock_http_request($this->jsonEncodeFunction()($expectedResponse), $expectedEndpoint, $expectedParams, 'get'); $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 a7479b64..3e917d0b 100644 --- a/tests/Unit/Client/ReportingTest.php +++ b/tests/Unit/Client/ReportingTest.php @@ -28,7 +28,7 @@ public function it_can_list_transactions() ], ]; - $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'get'); + $mockHttpClient = $this->mock_http_request($this->jsonEncodeFunction()($expectedResponse), $expectedEndpoint, $expectedParams, 'get'); $mockResponse = $mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(); $this->assertArrayHasKey('transaction_details', $this->jsonDecodeFunction()($mockResponse, true)); @@ -48,7 +48,7 @@ public function it_can_list_balances() ], ]; - $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'get'); + $mockHttpClient = $this->mock_http_request($this->jsonEncodeFunction()($expectedResponse), $expectedEndpoint, $expectedParams, 'get'); $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 12c9138e..5998ed20 100644 --- a/tests/Unit/Client/SubscriptionsTest.php +++ b/tests/Unit/Client/SubscriptionsTest.php @@ -29,7 +29,7 @@ public function it_can_create_a_subscription() 'json' => $this->mockCreateSubscriptionParams(), ]; - $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'post'); + $mockHttpClient = $this->mock_http_request($this->jsonEncodeFunction()($expectedResponse), $expectedEndpoint, $expectedParams, 'post'); $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); } @@ -49,7 +49,7 @@ public function it_can_update_a_subscription() 'json' => $this->mockUpdateSubscriptionParams(), ]; - $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'patch'); + $mockHttpClient = $this->mock_http_request($this->jsonEncodeFunction()($expectedResponse), $expectedEndpoint, $expectedParams, 'patch'); $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->patch($expectedEndpoint, $expectedParams)->getBody(), true)); } @@ -68,7 +68,7 @@ public function it_can_show_details_for_a_subscription() ], ]; - $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'get'); + $mockHttpClient = $this->mock_http_request($this->jsonEncodeFunction()($expectedResponse), $expectedEndpoint, $expectedParams, 'get'); $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); } @@ -88,7 +88,7 @@ public function it_can_activate_a_subscription() 'json' => $this->mockActivateSubscriptionParams(), ]; - $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'post'); + $mockHttpClient = $this->mock_http_request($this->jsonEncodeFunction()($expectedResponse), $expectedEndpoint, $expectedParams, 'post'); $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); } @@ -108,7 +108,7 @@ public function it_can_cancel_a_subscription() 'json' => $this->mockCancelSubscriptionParams(), ]; - $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'post'); + $mockHttpClient = $this->mock_http_request($this->jsonEncodeFunction()($expectedResponse), $expectedEndpoint, $expectedParams, 'post'); $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); } @@ -128,7 +128,7 @@ public function it_can_suspend_a_subscription() 'json' => $this->mockSuspendSubscriptionParams(), ]; - $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'post'); + $mockHttpClient = $this->mock_http_request($this->jsonEncodeFunction()($expectedResponse), $expectedEndpoint, $expectedParams, 'post'); $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); } @@ -148,7 +148,7 @@ public function it_can_capture_payment_for_a_subscription() 'json' => $this->mockCaptureSubscriptionPaymentParams(), ]; - $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'post'); + $mockHttpClient = $this->mock_http_request($this->jsonEncodeFunction()($expectedResponse), $expectedEndpoint, $expectedParams, 'post'); $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); } @@ -168,7 +168,7 @@ public function it_can_update_quantity_or_product_for_a_subscription() 'json' => $this->mockUpdateSubscriptionItemsParams(), ]; - $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'post'); + $mockHttpClient = $this->mock_http_request($this->jsonEncodeFunction()($expectedResponse), $expectedEndpoint, $expectedParams, 'post'); $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); } @@ -187,7 +187,7 @@ public function it_can_list_transactions_for_a_subscription() ], ]; - $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'get'); + $mockHttpClient = $this->mock_http_request($this->jsonEncodeFunction()($expectedResponse), $expectedEndpoint, $expectedParams, 'get'); $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 9c8327f9..399274a9 100644 --- a/tests/Unit/Client/TrackersTest.php +++ b/tests/Unit/Client/TrackersTest.php @@ -28,7 +28,7 @@ public function it_can_get_tracking_details_for_tracking_id() ], ]; - $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'get'); + $mockHttpClient = $this->mock_http_request($this->jsonEncodeFunction()($expectedResponse), $expectedEndpoint, $expectedParams, 'get'); $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); } @@ -48,7 +48,7 @@ public function it_can_update_tracking_details_for_tracking_id() 'json' => $this->mockUpdateTrackingDetailsParams(), ]; - $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'put'); + $mockHttpClient = $this->mock_http_request($this->jsonEncodeFunction()($expectedResponse), $expectedEndpoint, $expectedParams, 'put'); $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->put($expectedEndpoint, $expectedParams)->getBody(), true)); } @@ -68,7 +68,7 @@ public function it_can_create_tracking_in_batches() 'json' => $this->mockCreateTrackinginBatchesParams(), ]; - $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'post'); + $mockHttpClient = $this->mock_http_request($this->jsonEncodeFunction()($expectedResponse), $expectedEndpoint, $expectedParams, 'post'); $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 e008359e..eb2a5e95 100644 --- a/tests/Unit/Client/WebHooksEventsTest.php +++ b/tests/Unit/Client/WebHooksEventsTest.php @@ -28,7 +28,7 @@ public function it_can_list_web_hooks_event_types() ], ]; - $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'get'); + $mockHttpClient = $this->mock_http_request($this->jsonEncodeFunction()($expectedResponse), $expectedEndpoint, $expectedParams, 'get'); $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); } @@ -47,7 +47,7 @@ public function it_can_list_web_hooks_events() ], ]; - $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'get'); + $mockHttpClient = $this->mock_http_request($this->jsonEncodeFunction()($expectedResponse), $expectedEndpoint, $expectedParams, 'get'); $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); } @@ -66,7 +66,7 @@ public function it_can_show_details_for_a_web_hooks_event() ], ]; - $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'get'); + $mockHttpClient = $this->mock_http_request($this->jsonEncodeFunction()($expectedResponse), $expectedEndpoint, $expectedParams, 'get'); $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); } @@ -86,7 +86,7 @@ public function it_can_resend_notification_for_a_web_hooks_event() 'json' => $this->mockResendWebHookEventNotificationParams(), ]; - $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'get'); + $mockHttpClient = $this->mock_http_request($this->jsonEncodeFunction()($expectedResponse), $expectedEndpoint, $expectedParams, 'get'); $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 91edb71b..ed8b78d9 100644 --- a/tests/Unit/Client/WebHooksTest.php +++ b/tests/Unit/Client/WebHooksTest.php @@ -29,7 +29,7 @@ public function it_can_create_a_web_hook() 'json' => $this->mockCreateWebHookParams(), ]; - $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'post'); + $mockHttpClient = $this->mock_http_request($this->jsonEncodeFunction()($expectedResponse), $expectedEndpoint, $expectedParams, 'post'); $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); } @@ -48,7 +48,7 @@ public function it_can_list_web_hooks() ], ]; - $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'get'); + $mockHttpClient = $this->mock_http_request($this->jsonEncodeFunction()($expectedResponse), $expectedEndpoint, $expectedParams, 'get'); $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); } @@ -67,7 +67,7 @@ public function it_can_delete_a_web_hook() ], ]; - $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'delete'); + $mockHttpClient = $this->mock_http_request($this->jsonEncodeFunction()($expectedResponse), $expectedEndpoint, $expectedParams, 'delete'); $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->delete($expectedEndpoint, $expectedParams)->getBody(), true)); } @@ -87,7 +87,7 @@ public function it_can_update_a_web_hook() 'json' => $this->mockUpdateWebHookParams(), ]; - $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'patch'); + $mockHttpClient = $this->mock_http_request($this->jsonEncodeFunction()($expectedResponse), $expectedEndpoint, $expectedParams, 'patch'); $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->patch($expectedEndpoint, $expectedParams)->getBody(), true)); } @@ -106,7 +106,7 @@ public function it_can_show_details_for_a_web_hook() ], ]; - $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'get'); + $mockHttpClient = $this->mock_http_request($this->jsonEncodeFunction()($expectedResponse), $expectedEndpoint, $expectedParams, 'get'); $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); } @@ -125,7 +125,7 @@ public function it_can_list_web_hooks_events() ], ]; - $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'get'); + $mockHttpClient = $this->mock_http_request($this->jsonEncodeFunction()($expectedResponse), $expectedEndpoint, $expectedParams, 'get'); $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 c3ef2248..16057513 100644 --- a/tests/Unit/Client/WebHooksVerificationTest.php +++ b/tests/Unit/Client/WebHooksVerificationTest.php @@ -29,7 +29,7 @@ public function it_can_verify_web_hook_signature() 'json' => $this->mockVerifyWebHookSignatureParams(), ]; - $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams, 'post'); + $mockHttpClient = $this->mock_http_request($this->jsonEncodeFunction()($expectedResponse), $expectedEndpoint, $expectedParams, 'post'); $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); } diff --git a/tests/Unit/ClientTest.php b/tests/Unit/ClientTest.php index 1a060dc3..1d60b885 100644 --- a/tests/Unit/ClientTest.php +++ b/tests/Unit/ClientTest.php @@ -34,7 +34,7 @@ public function it_can_get_access_token() 'auth' => ['username', 'password'], ]; - $mockHttpClient = $this->mock_http_request(Utils::jsonEncode($expectedResponse), $expectedEndpoint, $expectedParams); + $mockHttpClient = $this->mock_http_request($this->jsonEncodeFunction()($expectedResponse), $expectedEndpoint, $expectedParams); $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); }