diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index fdb19c0a..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: ['8.0', '8.1', '8.2', '8.3'] + 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 0644c8e9..fa3c0c7c 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,4 +1,4 @@ -name: Laravel PayPal +name: Laravel PayPal V2 on: [push, pull_request] jobs: paypal: @@ -7,10 +7,7 @@ jobs: strategy: fail-fast: false matrix: - php-versions: ['8.0', '8.1', '8.2', '8.3'] - include: - - php-versions: '8.0' - continue-on-error: true + php-versions: ['7.1', '7.2', '7.3', '7.4'] steps: - name: Checkout uses: actions/checkout@v2 @@ -35,22 +32,11 @@ 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;) - - name: Run tests for PHP 7.2 to 8.0 with code coverage - if: matrix.php-versions == '7.2' || matrix.php-versions == '7.3' || matrix.php-versions == '7.4' || matrix.php-versions == '8.0' + run: composer install --no-progress --prefer-dist --optimize-autoloader + - name: Run tests with code coverage env: PHP_VERSION: ${{ matrix.php-versions }} - run: vendor/bin/phpunit $(if [ "$PHP_VERSION" == "7.2" ]; then echo "-c phpunit.xml.dist.php72"; fi;) $(if [ "$PHP_VERSION" == "7.3" ]; then echo "-c phpunit.xml.dist.php8"; fi;) $(if [ "$PHP_VERSION" == "7.4" ]; then echo "-c phpunit.xml.dist.php8"; fi;) $(if [ "$PHP_VERSION" == "8.0" ]; then echo "-c phpunit.xml.dist.php8"; fi;) --coverage-clover build/logs/clover.xml - - name: Install PestPHP - if: matrix.php-versions == '8.1' || matrix.php-versions == '8.2' || matrix.php-versions == '8.3' - env: - PHP_VERSION: ${{ matrix.php-versions }} - run: composer require pestphp/pest --dev --with-all-dependencies - - name: Run tests for PHP 8.1+ with code coverage - if: matrix.php-versions == '8.1' || matrix.php-versions == '8.2' || matrix.php-versions == '8.3' - env: - PHP_VERSION: ${{ matrix.php-versions }} - run: vendor/bin/pest --coverage-clover build/logs/clover.xml + run: vendor/bin/phpunit --coverage-clover build/logs/clover.xml - name: Install PHP Coveralls library env: PHP_VERSION: ${{ matrix.php-versions }} @@ -72,8 +58,8 @@ jobs: needs: [paypal] runs-on: ubuntu-latest steps: - - name: Coveralls Finished - uses: coverallsapp/github-action@master - with: - github-token: ${{ secrets.github_token }} - parallel-finished: true + - name: Coveralls Finished + uses: coverallsapp/github-action@master + with: + github-token: ${{ secrets.github_token }} + parallel-finished: true diff --git a/.scrutinizer.yml b/.scrutinizer.yml index 683d440c..80f9c4fe 100644 --- a/.scrutinizer.yml +++ b/.scrutinizer.yml @@ -25,7 +25,7 @@ build: - php-scrutinizer-run environment: php: - version: 8.1.13 + version: '7.3.21' tests: override: - diff --git a/Dockerfile b/Dockerfile index e340a2fe..e2780e7e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM srmklive/docker-php-cli:7.4 +FROM srmklive/docker-php-cli:7.1 LABEL maintainer="Raza Mehdi" diff --git a/README.md b/README.md index 5b9a73aa..3a16cf76 100644 --- a/README.md +++ b/README.md @@ -108,6 +108,44 @@ By default, the currency used is `USD`. If you wish to change it, you may call ` $provider->setCurrency('EUR'); ``` +## Create Recurring Daily Subscription + +```php +$response = $provider->addProduct('Demo Product', 'Demo Product', 'SERVICE', 'SOFTWARE') + ->addSubscriptionTrialPricing('DAY', 7) + ->addDailyPlan('Demo Plan', 'Demo Plan', 1.50) + ->setupSubscription('John Doe', 'john@example.com', '2021-12-10') ; +``` + +## Create Recurring Weekly Subscription + +```php +$response = $provider->addProduct('Demo Product', 'Demo Product', 'SERVICE', 'SOFTWARE') + ->addSubscriptionTrialPricing('DAY', 7) + ->addWeeklyPlan('Demo Plan', 'Demo Plan', 30) + ->setupSubscription('John Doe', 'john@example.com', '2021-12-10') ; +``` + +## Create Recurring Monthly Subscription + +```php +$response = $provider->addProduct('Demo Product', 'Demo Product', 'SERVICE', 'SOFTWARE') + ->addSubscriptionTrialPricing('DAY', 7) + ->addMonthlyPlan('Demo Plan', 'Demo Plan', 100) + ->setupSubscription('John Doe', 'john@example.com', '2021-12-10') ; +``` + +## Create Recurring Annual Subscription + +```php +$response = $provider->addProduct('Demo Product', 'Demo Product', 'SERVICE', 'SOFTWARE') + ->addSubscriptionTrialPricing('DAY', 7) + ->addAnnualPlan('Demo Plan', 'Demo Plan', 600) + ->setupSubscription('John Doe', 'john@example.com', '2021-12-10') ; +``` + +## Create Subscription by Existing Product & Billing Plan + ## Helper Methods diff --git a/composer.json b/composer.json index ac11651c..adc65e16 100644 --- a/composer.json +++ b/composer.json @@ -1,59 +1,53 @@ { - "name": "srmklive/paypal", - "type": "library", - "description": "Laravel plugin For Processing Payments Through Paypal Express Checkout. Can Be Used Independently With Other Applications.", - "keywords": [ - "http", - "rest", - "web service", - "paypal", - "laravel paypal" - ], - "license": "MIT", - "authors": [ - { - "name": "Raza Mehdi", - "email": "srmk@outlook.com" - } - ], - "autoload": { - "psr-4": { - "Srmklive\\PayPal\\": "src/" - } + "name": "srmklive/paypal", + "type": "library", + "description": "Laravel plugin For Processing Payments Through Paypal Express Checkout. Can Be Used Independently With Other Applications.", + "keywords": ["http", "rest", "web service", "paypal", "laravel paypal"], + "license": "MIT", + "authors": [ + { + "name": "Raza Mehdi", + "email": "srmk@outlook.com" + } + ], + "autoload": { + "psr-4": { + "Srmklive\\PayPal\\": "src/" + } + }, + "autoload-dev": { + "psr-4": { + "Srmklive\\PayPal\\Tests\\": "tests/" + } + }, + "require": { + "php": "^7.0", + "guzzlehttp/guzzle": "~6.0|~7.0", + "illuminate/support": "~5.1|~5.2|~5.3|~5.4|~5.5|~5.6|~5.7|~5.8", + "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" + }, + "config": { + "allow-plugins": { + "kylekatarnls/update-helper": true }, - "autoload-dev": { - "psr-4": { - "Srmklive\\PayPal\\Tests\\": "tests/" - } - }, - "require": { - "php": ">=7.2|^8.0", - "ext-curl": "*", - "guzzlehttp/guzzle": "~7.0", - "illuminate/support": "~6.0|~7.0|~8.0|~9.0|^10.0|^11.0", - "nesbot/carbon": "~2.0|^3.0" - }, - "require-dev": { - "phpstan/phpstan": "^1.10", - "phpunit/phpunit": "^8.0|^9.0|^10.0|^11.0", - "symfony/var-dumper": "~5.0|^6.0|^7.0" - }, - "config": { - "sort-packages": true, - "allow-plugins": { - "pestphp/pest-plugin": true - } - }, - "extra": { - "laravel": { - "providers": [ - "Srmklive\\PayPal\\Providers\\PayPalServiceProvider" - ], - "aliases": { - "PayPal": "Srmklive\\PayPal\\Facades\\PayPal" - } - } - }, - "minimum-stability": "dev", - "prefer-stable": true + "sort-packages": true, + "optimize-autoloader": true + }, + "extra": { + "laravel": { + "providers": [ + "Srmklive\\PayPal\\Providers\\PayPalServiceProvider" + ], + "aliases": { + "PayPal": "Srmklive\\PayPal\\Facades\\PayPal" + } + } + }, + "minimum-stability": "dev", + "prefer-stable": true } diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 139dd0a3..69b5cd67 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,30 +1,35 @@ - - - - - - - - + tests + + + src/ + + src/PayPalFacadeAccessor.php + src/Traits/PayPalVerifyIPN.php + src/Services/Str.php + src/Facades/ + src/Providers/ + + + - + + + + - - - src/ - - - src/PayPalFacadeAccessor.php - src/Traits/PayPalVerifyIPN.php - src/Services/Str.php - src/Facades/ - src/Providers/ - - diff --git a/phpunit.xml.dist.php72 b/phpunit.xml.dist.php72 deleted file mode 100644 index 69b5cd67..00000000 --- a/phpunit.xml.dist.php72 +++ /dev/null @@ -1,35 +0,0 @@ - - - - - tests - - - - - src/ - - src/PayPalFacadeAccessor.php - src/Traits/PayPalVerifyIPN.php - src/Services/Str.php - src/Facades/ - src/Providers/ - - - - - - - - - - diff --git a/phpunit.xml.dist.php8 b/phpunit.xml.dist.php8 deleted file mode 100644 index 0748be70..00000000 --- a/phpunit.xml.dist.php8 +++ /dev/null @@ -1,28 +0,0 @@ - - - - - src/ - - - src/PayPalFacadeAccessor.php - src/Traits/PayPalVerifyIPN.php - src/Services/Str.php - src/Facades/ - src/Providers/ - - - - - - - - - - tests - - - - - - diff --git a/src/Services/PayPal.php b/src/Services/PayPal.php index 92559786..f4ec97e8 100644 --- a/src/Services/PayPal.php +++ b/src/Services/PayPal.php @@ -35,7 +35,7 @@ public function __construct(array $config = []) * * @param array $credentials */ - protected function setOptions(array $credentials): void + protected function setOptions(array $credentials) { // Setting API Endpoints $this->config['api_url'] = 'https://api-m.paypal.com'; diff --git a/src/Services/Str.php b/src/Services/Str.php index 0fb4576f..ad7d9c33 100644 --- a/src/Services/Str.php +++ b/src/Services/Str.php @@ -2,10 +2,12 @@ namespace Srmklive\PayPal\Services; -use GuzzleHttp\Utils; +use Srmklive\PayPal\Traits\JsonEncodeDecodeSelector; class Str extends \Illuminate\Support\Str { + use JsonEncodeDecodeSelector; + /** * Determine if a given value is valid JSON. * @@ -24,8 +26,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/JsonEncodeDecodeSelector.php b/src/Traits/JsonEncodeDecodeSelector.php new file mode 100644 index 00000000..90c93b29 --- /dev/null +++ b/src/Traits/JsonEncodeDecodeSelector.php @@ -0,0 +1,30 @@ +setRequestHeader('PayPal-Request-Id', Str::random()); $product = $this->createProduct([ 'name' => $name, 'description' => $description, 'type' => $type, 'category' => $category, - ], $request_id); + ]); if ($error = data_get($product, 'error', false)) { throw new \RuntimeException(data_get($error, 'details.0.description', 'Failed to add product')); @@ -387,9 +387,9 @@ public function addBillingPlanById(string $plan_id): \Srmklive\PayPal\Services\P * * @return void */ - protected function addBillingPlan(string $name, string $description, array $billing_cycles): void + protected function addBillingPlan(string $name, string $description, array $billing_cycles) { - $request_id = Str::random(); + $this->setRequestHeader('PayPal-Request-Id', Str::random()); $plan_params = [ 'product_id' => $this->product['id'], @@ -404,11 +404,12 @@ protected function addBillingPlan(string $name, string $description, array $bill ], ]; - $billingPlan = $this->createPlan($plan_params, $request_id); + $billingPlan = $this->createPlan($plan_params); if ($error = data_get($billingPlan, 'error', false)) { throw new \RuntimeException(data_get($error, 'details.0.description', 'Failed to add billing plan')); } $this->billing_plan = $billingPlan; + } /** diff --git a/src/Traits/PayPalHttpClient.php b/src/Traits/PayPalHttpClient.php index 8c030a97..9e7d9b11 100644 --- a/src/Traits/PayPalHttpClient.php +++ b/src/Traits/PayPalHttpClient.php @@ -4,7 +4,6 @@ use GuzzleHttp\Client as HttpClient; use GuzzleHttp\Exception\ClientException as HttpClientException; -use GuzzleHttp\Utils; use Psr\Http\Message\StreamInterface; use RuntimeException; use Srmklive\PayPal\Services\Str; @@ -212,9 +211,9 @@ private function doPayPalRequest(bool $decode = true) // Perform PayPal HTTP API request. $response = $this->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 09aecb50..b47a2809 100644 --- a/src/Traits/PayPalRequest.php +++ b/src/Traits/PayPalRequest.php @@ -6,6 +6,7 @@ trait PayPalRequest { + use JsonEncodeDecodeSelector; use PayPalHttpClient; use PayPalAPI; use PayPalExperienceContext; @@ -73,7 +74,7 @@ trait PayPalRequest * * @throws \RuntimeException|\Exception */ - public function setApiCredentials(array $credentials): void + public function setApiCredentials(array $credentials) { if (empty($credentials)) { $this->throwConfigurationException(); @@ -101,7 +102,7 @@ public function setApiCredentials(array $credentials): void * * @return \Srmklive\PayPal\Services\PayPal */ - public function setCurrency(string $currency = 'USD'): \Srmklive\PayPal\Services\PayPal + public function setCurrency(string $currency = 'USD') { $allowedCurrencies = ['AUD', 'BRL', 'CAD', 'CZK', 'DKK', 'EUR', 'HKD', 'HUF', 'ILS', 'INR', 'JPY', 'MYR', 'MXN', 'NOK', 'NZD', 'PHP', 'PLN', 'GBP', 'SGD', 'SEK', 'CHF', 'TWD', 'THB', 'USD', 'RUB', 'CNY']; @@ -117,8 +118,10 @@ public function setCurrency(string $currency = 'USD'): \Srmklive\PayPal\Services /** * Return the set currency. + * + * @return string */ - public function getCurrency(): string + public function getCurrency() { return $this->currency; } @@ -131,7 +134,7 @@ public function getCurrency(): string * * @return \Srmklive\PayPal\Services\PayPal */ - public function setRequestHeader(string $key, string $value): \Srmklive\PayPal\Services\PayPal + public function setRequestHeader(string $key, string $value) { $this->options['headers'][$key] = $value; @@ -145,7 +148,7 @@ public function setRequestHeader(string $key, string $value): \Srmklive\PayPal\S * * @return \Srmklive\PayPal\Services\PayPal */ - public function setRequestHeaders(array $headers): \Srmklive\PayPal\Services\PayPal + public function setRequestHeaders(array $headers) { foreach ($headers as $key=>$value) { $this->setRequestHeader($key, $value); @@ -163,7 +166,7 @@ public function setRequestHeaders(array $headers): \Srmklive\PayPal\Services\Pay * * @return string */ - public function getRequestHeader(string $key): string + public function getRequestHeader(string $key) { if (isset($this->options['headers'][$key])) { return $this->options['headers'][$key]; @@ -179,7 +182,7 @@ public function getRequestHeader(string $key): string * * @throws \Exception */ - private function setConfig(array $config): void + private function setConfig(array $config) { $api_config = empty($config) && function_exists('config') && !empty(config('paypal')) ? config('paypal') : $config; @@ -193,7 +196,7 @@ private function setConfig(array $config): void * * @param array $credentials */ - private function setApiEnvironment(array $credentials): void + private function setApiEnvironment(array $credentials) { $this->mode = 'live'; @@ -209,7 +212,7 @@ private function setApiEnvironment(array $credentials): void * * @param string $mode */ - private function setValidApiEnvironment(string $mode): void + private function setValidApiEnvironment(string $mode) { $this->mode = !in_array($mode, ['sandbox', 'live']) ? 'live' : $mode; } @@ -221,7 +224,7 @@ private function setValidApiEnvironment(string $mode): void * * @throws \Exception */ - private function setApiProviderConfiguration(array $credentials): void + private function setApiProviderConfiguration(array $credentials) { // Setting PayPal API Credentials if (empty($credentials[$this->mode])) { diff --git a/tests/Feature/AdapterBillingPlansPricingHelpersTest.php b/tests/Feature/AdapterBillingPlansPricingHelpersTest.php index 024b1a0a..e0a91a5b 100644 --- a/tests/Feature/AdapterBillingPlansPricingHelpersTest.php +++ b/tests/Feature/AdapterBillingPlansPricingHelpersTest.php @@ -2,7 +2,6 @@ namespace Srmklive\PayPal\Tests\Feature; -use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use Srmklive\PayPal\Services\PayPal as PayPalClient; use Srmklive\PayPal\Tests\MockClientClasses; @@ -35,7 +34,7 @@ protected function setUp(): void parent::setUp(); } - #[Test] + /** @test */ public function it_can_update_pricing_schemes_for_a_billing_plan(): void { $this->client->setAccessToken([ @@ -56,7 +55,7 @@ public function it_can_update_pricing_schemes_for_a_billing_plan(): void $this->assertEmpty($response); } - #[Test] + /** @test */ public function it_can_set_custom_limits_when_listing_billing_plans(): void { $this->client->setAccessToken([ diff --git a/tests/Feature/AdapterConfigTest.php b/tests/Feature/AdapterConfigTest.php index 6ee7d3e5..1932ebba 100644 --- a/tests/Feature/AdapterConfigTest.php +++ b/tests/Feature/AdapterConfigTest.php @@ -2,7 +2,6 @@ namespace Srmklive\PayPal\Tests\Feature; -use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use Srmklive\PayPal\Services\PayPal as PayPalClient; use Srmklive\PayPal\Tests\MockClientClasses; @@ -12,7 +11,7 @@ class AdapterConfigTest extends TestCase use MockClientClasses; /** @var PayPalClient */ - protected PayPalClient $client; + protected $client; protected function setUp(): void { @@ -21,7 +20,7 @@ protected function setUp(): void parent::setUp(); } - #[Test] + /** @test */ public function it_throws_exception_if_invalid_credentials_are_provided(): void { $this->expectException(\RuntimeException::class); @@ -30,7 +29,7 @@ public function it_throws_exception_if_invalid_credentials_are_provided(): void $this->client = new PayPalClient([]); } - #[Test] + /** @test */ public function it_throws_exception_if_invalid_mode_is_provided(): void { $this->expectException(\RuntimeException::class); @@ -42,7 +41,7 @@ public function it_throws_exception_if_invalid_mode_is_provided(): void $this->client = new PayPalClient($credentials); } - #[Test] + /** @test */ public function it_throws_exception_if_empty_credentials_are_provided(): void { $this->expectException(\RuntimeException::class); @@ -54,7 +53,7 @@ public function it_throws_exception_if_empty_credentials_are_provided(): void $this->client = new PayPalClient($credentials); } - #[Test] + /** @test */ public function it_throws_exception_if_credentials_items_are_not_provided(): void { $item = 'client_id'; @@ -68,13 +67,13 @@ public function it_throws_exception_if_credentials_items_are_not_provided(): voi $client = new PayPalClient($credentials); } - #[Test] + /** @test */ public function it_can_take_valid_credentials_and_return_the_client_instance(): void { $this->assertInstanceOf(PayPalClient::class, $this->client); } - #[Test] + /** @test */ public function it_throws_exception_if_invalid_credentials_are_provided_through_method(): void { $this->expectException(\RuntimeException::class); @@ -82,7 +81,7 @@ public function it_throws_exception_if_invalid_credentials_are_provided_through_ $this->client->setApiCredentials([]); } - #[Test] + /** @test */ public function it_returns_the_client_instance_if_valid_credentials_are_provided_through_method(): void { $this->client->setApiCredentials($this->getApiCredentials()); @@ -90,7 +89,7 @@ public function it_returns_the_client_instance_if_valid_credentials_are_provided $this->assertInstanceOf(PayPalClient::class, $this->client); } - #[Test] + /** @test */ public function it_throws_exception_if_invalid_currency_is_set(): void { $this->expectException(\RuntimeException::class); @@ -100,7 +99,7 @@ public function it_throws_exception_if_invalid_currency_is_set(): void $this->assertNotEquals('PKR', $this->client->getCurrency()); } - #[Test] + /** @test */ public function it_can_set_a_valid_currency(): void { $this->client->setCurrency('EUR'); @@ -109,7 +108,7 @@ public function it_can_set_a_valid_currency(): void $this->assertEquals('EUR', $this->client->getCurrency()); } - #[Test] + /** @test */ public function it_can_set_a_request_header(): void { $this->client->setRequestHeader('Prefer', 'return=representation'); @@ -118,7 +117,7 @@ public function it_can_set_a_request_header(): void $this->assertEquals($this->client->getRequestHeader('Prefer'), 'return=representation'); } - #[Test] + /** @test */ public function it_can_set_multiple_request_headers(): void { $this->client->setRequestHeaders([ @@ -130,7 +129,7 @@ public function it_can_set_multiple_request_headers(): void $this->assertEquals($this->client->getRequestHeader('PayPal-Partner-Attribution-Id'), 'some-attribution-id'); } - #[Test] + /** @test */ public function it_throws_exception_if_options_header_not_set(): void { $this->expectException(\RuntimeException::class); diff --git a/tests/Feature/AdapterCreateSubscriptionHelpersTest.php b/tests/Feature/AdapterCreateSubscriptionHelpersTest.php index 47934d16..da5e4988 100644 --- a/tests/Feature/AdapterCreateSubscriptionHelpersTest.php +++ b/tests/Feature/AdapterCreateSubscriptionHelpersTest.php @@ -3,7 +3,6 @@ namespace Srmklive\PayPal\Tests\Feature; use Carbon\Carbon; -use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use Srmklive\PayPal\Services\PayPal as PayPalClient; use Srmklive\PayPal\Tests\MockClientClasses; @@ -15,10 +14,10 @@ class AdapterCreateSubscriptionHelpersTest extends TestCase use MockResponsePayloads; /** @var string */ - protected static string $access_token = ''; + protected static $access_token = ''; /** @var PayPalClient */ - protected PayPalClient $client; + protected $client; protected function setUp(): void { @@ -36,7 +35,7 @@ protected function setUp(): void parent::setUp(); } - #[Test] + /** @test */ public function it_can_create_a_monthly_subscription(): void { $this->client->setAccessToken([ @@ -77,7 +76,7 @@ public function it_can_create_a_monthly_subscription(): void $this->assertArrayHasKey('plan_id', $response); } - #[Test] + /** @test */ public function it_can_create_a_daily_subscription(): void { $this->client->setAccessToken([ @@ -118,7 +117,7 @@ public function it_can_create_a_daily_subscription(): void $this->assertArrayHasKey('plan_id', $response); } - #[Test] + /** @test */ public function it_can_create_a_weekly_subscription(): void { $this->client->setAccessToken([ @@ -159,7 +158,7 @@ public function it_can_create_a_weekly_subscription(): void $this->assertArrayHasKey('plan_id', $response); } - #[Test] + /** @test */ public function it_can_create_an_annual_subscription(): void { $this->client->setAccessToken([ @@ -200,7 +199,7 @@ public function it_can_create_an_annual_subscription(): void $this->assertArrayHasKey('plan_id', $response); } - #[Test] + /** @test */ public function it_can_create_a_subscription_with_custom_defined_interval(): void { $this->client->setAccessToken([ @@ -241,7 +240,7 @@ public function it_can_create_a_subscription_with_custom_defined_interval(): voi $this->assertArrayHasKey('plan_id', $response); } - #[Test] + /** @test */ public function it_throws_exception_when_invalid_interval_is_provided_for_creating_a_subscription(): void { $this->client->setAccessToken([ @@ -256,7 +255,7 @@ public function it_throws_exception_when_invalid_interval_is_provided_for_creati $this->client = $this->client->addCustomPlan('Demo Plan', 'Demo Plan', 100, 'MONTHLY', 3); } - #[Test] + /** @test */ public function it_throws_exception_when_get_error_for_creating_a_billing_plan(): void { $this->client->setAccessToken([ @@ -283,7 +282,7 @@ public function it_throws_exception_when_get_error_for_creating_a_billing_plan() $this->client = $this->client->addMonthlyPlan('Demo Plan', 'Demo Plan', 100); } - #[Test] + /** @test */ public function it_throws_exception_when_get_error_for_creating_a_product(): void { $this->client->setAccessToken([ @@ -302,7 +301,7 @@ public function it_throws_exception_when_get_error_for_creating_a_product(): voi $this->client = $this->client->addProduct('Demo Product', 'Demo Product', 'SERVICE', 'SOFTWARE'); } - #[Test] + /** @test */ public function it_can_create_a_subscription_without_trial(): void { $this->client->setAccessToken([ @@ -341,7 +340,7 @@ public function it_can_create_a_subscription_without_trial(): void $this->assertArrayHasKey('plan_id', $response); } - #[Test] + /** @test */ public function it_can_create_a_subscription_by_existing_product_and_billing_plan(): void { $this->client->setAccessToken([ @@ -366,7 +365,7 @@ public function it_can_create_a_subscription_by_existing_product_and_billing_pla $this->assertArrayHasKey('plan_id', $response); } - #[Test] + /** @test */ public function it_skips_product_and_billing_plan_creation_if_already_set_when_creating_a_daily_subscription(): void { $this->client->setAccessToken([ @@ -394,7 +393,7 @@ public function it_skips_product_and_billing_plan_creation_if_already_set_when_c $this->assertArrayHasKey('plan_id', $response); } - #[Test] + /** @test */ public function it_skips_product_and_billing_plan_creation_if_already_set_when_creating_a_weekly_subscription(): void { $this->client->setAccessToken([ @@ -422,7 +421,7 @@ public function it_skips_product_and_billing_plan_creation_if_already_set_when_c $this->assertArrayHasKey('plan_id', $response); } - #[Test] + /** @test */ public function it_skips_product_and_billing_plan_creation_if_already_set_when_creating_a_monthly_subscription(): void { $this->client->setAccessToken([ @@ -450,7 +449,7 @@ public function it_skips_product_and_billing_plan_creation_if_already_set_when_c $this->assertArrayHasKey('plan_id', $response); } - #[Test] + /** @test */ public function it_skips_product_and_billing_plan_creation_if_already_set_when_creating_an_annual_subscription(): void { $this->client->setAccessToken([ @@ -478,7 +477,7 @@ public function it_skips_product_and_billing_plan_creation_if_already_set_when_c $this->assertArrayHasKey('plan_id', $response); } - #[Test] + /** @test */ public function it_skips_product_and_billing_plan_creation_if_already_set_when_creating_a_subscription_with_custom_intervals(): void { $this->client->setAccessToken([ @@ -506,7 +505,7 @@ public function it_skips_product_and_billing_plan_creation_if_already_set_when_c $this->assertArrayHasKey('plan_id', $response); } - #[Test] + /** @test */ public function it_can_add_setup_fees_when_creating_subscription(): void { $this->client->setAccessToken([ @@ -534,7 +533,7 @@ public function it_can_add_setup_fees_when_creating_subscription(): void $this->assertArrayHasKey('plan_id', $response); } - #[Test] + /** @test */ public function it_can_add_shipping_address_when_creating_subscription(): void { $this->client->setAccessToken([ @@ -561,7 +560,7 @@ public function it_can_add_shipping_address_when_creating_subscription(): void $this->assertArrayHasKey('plan_id', $response); } - #[Test] + /** @test */ public function it_can_add_custom_payment_failure_threshold_value_when_creating_subscription(): void { $this->client->setAccessToken([ @@ -589,7 +588,7 @@ public function it_can_add_custom_payment_failure_threshold_value_when_creating_ $this->assertArrayHasKey('plan_id', $response); } - #[Test] + /** @test */ public function it_can_set_tax_percentage_when_creating_subscription(): void { $this->client->setAccessToken([ @@ -617,7 +616,7 @@ public function it_can_set_tax_percentage_when_creating_subscription(): void $this->assertArrayHasKey('plan_id', $response); } - #[Test] + /** @test */ public function it_can_create_a_subscription_with_fixed_installments(): void { $this->client->setAccessToken([ diff --git a/tests/Feature/AdapterExperienceContextTest.php b/tests/Feature/AdapterExperienceContextTest.php index 9615cbf0..fd6c5452 100644 --- a/tests/Feature/AdapterExperienceContextTest.php +++ b/tests/Feature/AdapterExperienceContextTest.php @@ -19,10 +19,10 @@ class AdapterExperienceContextTest extends TestCase use MockResponsePayloads; /** @var string */ - protected static string $access_token = ''; + protected static $access_token = ''; /** @var PayPalClient */ - protected PayPalClient $client; + protected $client; protected function setUp(): void { @@ -40,7 +40,7 @@ protected function setUp(): void parent::setUp(); } - #[Test] + /** @test */ public function it_can_set_payment_experience_context_before_performing_api_call(): void { $this->client->setAccessToken([ diff --git a/tests/Feature/AdapterFeatureTest.php b/tests/Feature/AdapterFeatureTest.php index e4b04600..ba5c3b9c 100644 --- a/tests/Feature/AdapterFeatureTest.php +++ b/tests/Feature/AdapterFeatureTest.php @@ -3,7 +3,6 @@ namespace Srmklive\PayPal\Tests\Feature; use Carbon\Carbon; -use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use Srmklive\PayPal\Services\PayPal as PayPalClient; use Srmklive\PayPal\Tests\MockClientClasses; @@ -17,13 +16,13 @@ class AdapterFeatureTest extends TestCase use MockResponsePayloads; /** @var string */ - protected static string $access_token = ''; + protected static $access_token = ''; /** @var string */ - protected static string $product_id = ''; + protected static $product_id = ''; /** @var PayPalClient */ - protected PayPalClient $client; + protected $client; protected function setUp(): void { @@ -35,17 +34,16 @@ protected function setUp(): void parent::setUp(); } - #[Test] + /** @test */ public function it_returns_error_if_invalid_credentials_are_used_to_get_access_token(): void { $this->client = new PayPalClient($this->getMockCredentials()); $response = $this->client->getAccessToken(); - $this->assertIsArray($response['error']); $this->assertArrayHasKey('error', $response); } - #[Test] + /** @test */ public function it_can_get_access_token(): void { $this->client->setClient( @@ -61,7 +59,7 @@ public function it_can_get_access_token(): void $this->assertNotEmpty($response['access_token']); } - #[Test] + /** @test */ public function it_can_create_a_billing_plan(): void { $this->client->setAccessToken([ @@ -86,7 +84,7 @@ public function it_can_create_a_billing_plan(): void $this->assertArrayHasKey('id', $response); } - #[Test] + /** @test */ public function it_can_list_billing_plans(): void { $this->client->setAccessToken([ @@ -106,7 +104,7 @@ public function it_can_list_billing_plans(): void $this->assertArrayHasKey('plans', $response); } - #[Test] + /** @test */ public function it_can_update_a_billing_plan(): void { $this->client->setAccessToken([ @@ -125,7 +123,7 @@ public function it_can_update_a_billing_plan(): void $this->assertEmpty($response); } - #[Test] + /** @test */ public function it_can_show_details_for_a_billing_plan(): void { $this->client->setAccessToken([ @@ -145,7 +143,7 @@ public function it_can_show_details_for_a_billing_plan(): void $this->assertArrayHasKey('id', $response); } - #[Test] + /** @test */ public function it_can_activate_a_billing_plan(): void { $this->client->setAccessToken([ @@ -162,7 +160,7 @@ public function it_can_activate_a_billing_plan(): void $this->assertEmpty($response); } - #[Test] + /** @test */ public function it_can_deactivate_a_billing_plan(): void { $this->client->setAccessToken([ @@ -179,7 +177,7 @@ public function it_can_deactivate_a_billing_plan(): void $this->assertEmpty($response); } - #[Test] + /** @test */ public function it_can_update_pricing_for_a_billing_plan(): void { $this->client->setAccessToken([ @@ -198,7 +196,7 @@ public function it_can_update_pricing_for_a_billing_plan(): void $this->assertEmpty($response); } - #[Test] + /** @test */ public function it_can_list_products(): void { $this->client->setAccessToken([ @@ -218,7 +216,7 @@ public function it_can_list_products(): void $this->assertArrayHasKey('products', $response); } - #[Test] + /** @test */ public function it_can_create_a_product(): void { $this->client->setAccessToken([ @@ -242,7 +240,7 @@ public function it_can_create_a_product(): void $this->assertArrayHasKey('id', $response); } - #[Test] + /** @test */ public function it_can_update_a_product(): void { $this->client->setAccessToken([ @@ -261,7 +259,7 @@ public function it_can_update_a_product(): void $this->assertEmpty($response); } - #[Test] + /** @test */ public function it_can_get_details_for_a_product(): void { $this->client->setAccessToken([ @@ -281,7 +279,7 @@ public function it_can_get_details_for_a_product(): void $this->assertArrayHasKey('id', $response); } - #[Test] + /** @test */ public function it_can_acknowledge_item_is_returned_for_raised_dispute(): void { $this->client->setAccessToken([ @@ -305,7 +303,7 @@ public function it_can_acknowledge_item_is_returned_for_raised_dispute(): void $this->assertArrayHasKey('links', $response); } - #[Test] + /** @test */ public function it_can_list_disputes(): void { $this->client->setAccessToken([ @@ -325,7 +323,7 @@ public function it_can_list_disputes(): void $this->assertArrayHasKey('items', $response); } - #[Test] + /** @test */ public function it_can_partially_update_a_dispute(): void { $this->client->setAccessToken([ @@ -344,7 +342,7 @@ public function it_can_partially_update_a_dispute(): void $this->assertEmpty($response); } - #[Test] + /** @test */ public function it_can_get_details_for_a_dispute(): void { $this->client->setAccessToken([ @@ -364,7 +362,7 @@ public function it_can_get_details_for_a_dispute(): void $this->assertArrayHasKey('dispute_id', $response); } - #[Test] + /** @test */ public function it_can_provide_evidence_for_a_dispute_claim(): void { $this->client->setAccessToken([ @@ -395,7 +393,7 @@ public function it_can_provide_evidence_for_a_dispute_claim(): void $this->markTestIncomplete('Skipping the test'); } - #[Test] + /** @test */ public function it_throws_exception_if_invalid_file_as_evidence_is_provided_for_a_dispute_claim(): void { $this->client->setAccessToken([ @@ -424,7 +422,7 @@ public function it_throws_exception_if_invalid_file_as_evidence_is_provided_for_ ); } - #[Test] + /** @test */ public function it_throws_exception_if_file_size_as_evidence_exceeds_per_file_limit_for_a_dispute_claim(): void { $this->client->setAccessToken([ @@ -452,7 +450,7 @@ public function it_throws_exception_if_file_size_as_evidence_exceeds_per_file_li ); } - #[Test] + /** @test */ public function it_throws_exception_if_file_size_as_evidence_exceeds_overall_limit_for_a_dispute_claim(): void { $this->client->setAccessToken([ @@ -480,7 +478,7 @@ public function it_throws_exception_if_file_size_as_evidence_exceeds_overall_lim ); } - #[Test] + /** @test */ public function it_can_offer_to_resolve_dispute_claim(): void { $this->client->setAccessToken([ @@ -505,7 +503,7 @@ public function it_can_offer_to_resolve_dispute_claim(): void $this->assertArrayHasKey('links', $response); } - #[Test] + /** @test */ public function it_can_escalate_dispute_claim(): void { $this->client->setAccessToken([ @@ -528,7 +526,7 @@ public function it_can_escalate_dispute_claim(): void $this->assertArrayHasKey('links', $response); } - #[Test] + /** @test */ public function it_can_accept_dispute_claim(): void { $this->client->setAccessToken([ @@ -551,7 +549,7 @@ public function it_can_accept_dispute_claim(): void $this->assertArrayHasKey('links', $response); } - #[Test] + /** @test */ public function it_can_accept_dispute_offer_resolution(): void { $this->client->setAccessToken([ @@ -574,7 +572,7 @@ public function it_can_accept_dispute_offer_resolution(): void $this->assertArrayHasKey('links', $response); } - #[Test] + /** @test */ public function it_can_update_dispute_status(): void { $this->client->setAccessToken([ @@ -597,7 +595,7 @@ public function it_can_update_dispute_status(): void $this->assertArrayHasKey('links', $response); } - #[Test] + /** @test */ public function it_can_settle_dispute(): void { $this->client->setAccessToken([ @@ -620,7 +618,7 @@ public function it_can_settle_dispute(): void $this->assertArrayHasKey('links', $response); } - #[Test] + /** @test */ public function it_can_decline_dispute_offer_resolution(): void { $this->client->setAccessToken([ @@ -643,7 +641,7 @@ public function it_can_decline_dispute_offer_resolution(): void $this->assertArrayHasKey('links', $response); } - #[Test] + /** @test */ public function it_can_generate_unique_invoice_number(): void { $this->client->setAccessToken([ @@ -663,7 +661,7 @@ public function it_can_generate_unique_invoice_number(): void $this->assertArrayHasKey('invoice_number', $response); } - #[Test] + /** @test */ public function it_can_create_a_draft_invoice(): void { $this->client->setAccessToken([ @@ -685,7 +683,7 @@ public function it_can_create_a_draft_invoice(): void $this->assertArrayHasKey('id', $response); } - #[Test] + /** @test */ public function it_can_list_invoices(): void { $this->client->setAccessToken([ @@ -705,7 +703,7 @@ public function it_can_list_invoices(): void $this->assertArrayHasKey('total_items', $response); } - #[Test] + /** @test */ public function it_can_delete_an_invoice(): void { $this->client->setAccessToken([ @@ -722,7 +720,7 @@ public function it_can_delete_an_invoice(): void $this->assertEmpty($response); } - #[Test] + /** @test */ public function it_can_update_an_invoice(): void { $this->client->setAccessToken([ @@ -744,7 +742,7 @@ public function it_can_update_an_invoice(): void $this->assertArrayHasKey('id', $response); } - #[Test] + /** @test */ public function it_can_show_details_for_an_invoice(): void { $this->client->setAccessToken([ @@ -764,7 +762,7 @@ public function it_can_show_details_for_an_invoice(): void $this->assertArrayHasKey('id', $response); } - #[Test] + /** @test */ public function it_can_cancel_an_invoice(): void { $this->client->setAccessToken([ @@ -793,7 +791,7 @@ public function it_can_cancel_an_invoice(): void $this->assertEmpty($response); } - #[Test] + /** @test */ public function it_can_generate_qr_code_for_invoice(): void { $this->client->setAccessToken([ @@ -812,7 +810,7 @@ public function it_can_generate_qr_code_for_invoice(): void $this->assertNotEmpty($response); } - #[Test] + /** @test */ public function it_can_register_payment_for_invoice(): void { $this->client->setAccessToken([ @@ -832,7 +830,7 @@ public function it_can_register_payment_for_invoice(): void $this->assertArrayHasKey('payment_id', $response); } - #[Test] + /** @test */ public function it_can_delete_payment_for_invoice(): void { $this->client->setAccessToken([ @@ -849,7 +847,7 @@ public function it_can_delete_payment_for_invoice(): void $this->assertEmpty($response); } - #[Test] + /** @test */ public function it_can_refund_payment_for_invoice(): void { $this->client->setAccessToken([ @@ -869,7 +867,7 @@ public function it_can_refund_payment_for_invoice(): void $this->assertArrayHasKey('refund_id', $response); } - #[Test] + /** @test */ public function it_can_delete_refund_for_invoice(): void { $this->client->setAccessToken([ @@ -886,7 +884,7 @@ public function it_can_delete_refund_for_invoice(): void $this->assertEmpty($response); } - #[Test] + /** @test */ public function it_can_send_an_invoice(): void { $this->client->setAccessToken([ @@ -913,7 +911,7 @@ public function it_can_send_an_invoice(): void $this->assertEmpty($response); } - #[Test] + /** @test */ public function it_can_send_reminder_for_an_invoice(): void { $this->client->setAccessToken([ @@ -940,7 +938,7 @@ public function it_can_send_reminder_for_an_invoice(): void $this->assertEmpty($response); } - #[Test] + /** @test */ public function it_can_create_invoice_template(): void { $this->client->setAccessToken([ @@ -962,7 +960,7 @@ public function it_can_create_invoice_template(): void $this->assertArrayHasKey('id', $response); } - #[Test] + /** @test */ public function it_can_list_invoice_templates(): void { $this->client->setAccessToken([ @@ -982,7 +980,7 @@ public function it_can_list_invoice_templates(): void $this->assertArrayHasKey('templates', $response); } - #[Test] + /** @test */ public function it_can_delete_an_invoice_template(): void { $this->client->setAccessToken([ @@ -999,7 +997,7 @@ public function it_can_delete_an_invoice_template(): void $this->assertEmpty($response); } - #[Test] + /** @test */ public function it_can_update_an_invoice_template(): void { $this->client->setAccessToken([ @@ -1021,7 +1019,7 @@ public function it_can_update_an_invoice_template(): void $this->assertArrayHasKey('id', $response); } - #[Test] + /** @test */ public function it_can_get_details_for_an_invoice_template(): void { $this->client->setAccessToken([ @@ -1041,7 +1039,7 @@ public function it_can_get_details_for_an_invoice_template(): void $this->assertArrayHasKey('id', $response); } - #[Test] + /** @test */ public function it_can_search_invoices(): void { $this->client->setAccessToken([ @@ -1061,7 +1059,7 @@ public function it_can_search_invoices(): void $this->assertArrayHasKey('total_items', $response); } - #[Test] + /** @test */ public function it_can_search_invoices_with_custom_filters(): void { $this->client->setAccessToken([ @@ -1095,7 +1093,7 @@ public function it_can_search_invoices_with_custom_filters(): void $this->assertArrayHasKey('items', $response); } - #[Test] + /** @test */ public function it_throws_exception_on_search_invoices_with_invalid_status(): void { $this->client->setAccessToken([ @@ -1116,7 +1114,7 @@ public function it_throws_exception_on_search_invoices_with_invalid_status(): vo ->searchInvoices(); } - #[Test] + /** @test */ public function it_throws_exception_on_search_invoices_with_invalid_amount_ranges(): void { $this->client->setAccessToken([ @@ -1139,7 +1137,7 @@ public function it_throws_exception_on_search_invoices_with_invalid_amount_range ->searchInvoices(); } - #[Test] + /** @test */ public function it_throws_exception_on_search_invoices_with_invalid_date_ranges(): void { $this->client->setAccessToken([ @@ -1162,7 +1160,7 @@ public function it_throws_exception_on_search_invoices_with_invalid_date_ranges( ->searchInvoices(); } - #[Test] + /** @test */ public function it_throws_exception_on_search_invoices_with_invalid_date_range_type(): void { $this->client->setAccessToken([ @@ -1185,7 +1183,7 @@ public function it_throws_exception_on_search_invoices_with_invalid_date_range_t ->searchInvoices(); } - #[Test] + /** @test */ public function it_can_get_user_profile_details(): void { $this->client->setAccessToken([ @@ -1204,7 +1202,7 @@ public function it_can_get_user_profile_details(): void $this->assertArrayHasKey('address', $response); } - #[Test] + /** @test */ public function it_can_get_list_users(): void { $this->client->setAccessToken([ @@ -1223,7 +1221,7 @@ public function it_can_get_list_users(): void $this->assertArrayHasKey('Resources', $response); } - #[Test] + /** @test */ public function it_can_get_user_details() { $this->client->setAccessToken([ @@ -1244,7 +1242,7 @@ public function it_can_get_user_details() $this->assertArrayHasKey('userName', $response); } - #[Test] + /** @test */ public function it_can_deleta_a_user(): void { $this->client->setAccessToken([ @@ -1263,7 +1261,7 @@ public function it_can_deleta_a_user(): void $this->assertEmpty($response); } - #[Test] + /** @test */ public function it_can_create_merchant_applications(): void { $this->client->setAccessToken([ @@ -1296,7 +1294,7 @@ public function it_can_create_merchant_applications(): void $this->assertArrayHasKey('redirect_uris', $response); } - #[Test] + /** @test */ public function it_can_set_account_properties(): void { $this->client->setAccessToken([ @@ -1313,7 +1311,7 @@ public function it_can_set_account_properties(): void $this->assertEmpty($response); } - #[Test] + /** @test */ public function it_can_disable_account_properties(): void { $this->client->setAccessToken([ @@ -1332,7 +1330,7 @@ public function it_can_disable_account_properties(): void $this->assertEmpty($response); } - #[Test] + /** @test */ public function it_can_get_client_token(): void { $this->client->setAccessToken([ @@ -1351,7 +1349,7 @@ public function it_can_get_client_token(): void $this->assertArrayHasKey('client_token', $response); } - #[Test] + /** @test */ public function it_can_create_orders(): void { $this->client->setAccessToken([ @@ -1374,7 +1372,7 @@ public function it_can_create_orders(): void $this->assertArrayHasKey('links', $response); } - #[Test] + /** @test */ public function it_can_update_orders(): void { $this->client->setAccessToken([ @@ -1396,7 +1394,7 @@ public function it_can_update_orders(): void $this->assertNotEmpty($response); } - #[Test] + /** @test */ public function it_can_get_order_details(): void { $this->client->setAccessToken([ @@ -1422,7 +1420,7 @@ public function it_can_get_order_details(): void $this->assertArrayHasKey('links', $response); } - #[Test] + /** @test */ public function it_can_authorize_payment_for_an_order(): void { $this->client->setAccessToken([ @@ -1446,7 +1444,7 @@ public function it_can_authorize_payment_for_an_order(): void $this->assertArrayHasKey('links', $response); } - #[Test] + /** @test */ public function it_can_create_partner_referral(): void { $this->client->setAccessToken([ @@ -1467,7 +1465,7 @@ public function it_can_create_partner_referral(): void $this->assertArrayHasKey('links', $response); } - #[Test] + /** @test */ public function it_can_get_referral_details(): void { $this->client->setAccessToken([ @@ -1489,7 +1487,7 @@ public function it_can_get_referral_details(): void $this->assertArrayHasKey('referral_data', $response); } - #[Test] + /** @test */ public function it_can_list_seller_tracking_information(): void { $this->client->setAccessToken([ @@ -1512,7 +1510,7 @@ public function it_can_list_seller_tracking_information(): void $this->assertArrayHasKey('tracking_id', $response); } - #[Test] + /** @test */ public function it_can_show_seller_status(): void { $this->client->setAccessToken([ @@ -1534,7 +1532,7 @@ public function it_can_show_seller_status(): void $this->assertArrayHasKey('merchant_id', $response); } - #[Test] + /** @test */ public function it_can_list_merchant_credentials(): void { $this->client->setAccessToken([ @@ -1556,7 +1554,7 @@ public function it_can_list_merchant_credentials(): void $this->assertArrayHasKey('payer_id', $response); } - #[Test] + /** @test */ public function it_can_list_web_experience_profiles(): void { $this->client->setAccessToken([ @@ -1576,7 +1574,7 @@ public function it_can_list_web_experience_profiles(): void $this->assertArrayHasKey('id', collect($response)->first()); } - #[Test] + /** @test */ public function it_can_create_web_experience_profile(): void { $this->client->setAccessToken([ @@ -1598,7 +1596,7 @@ public function it_can_create_web_experience_profile(): void $this->assertArrayHasKey('name', $response); } - #[Test] + /** @test */ public function it_can_delete_web_experience_profile(): void { $expectedResponse = ''; @@ -1619,7 +1617,7 @@ public function it_can_delete_web_experience_profile(): void $this->assertEmpty($response); } - #[Test] + /** @test */ public function it_can_partially_update_web_experience_profile(): void { $expectedResponse = ''; @@ -1640,7 +1638,7 @@ public function it_can_partially_update_web_experience_profile(): void $this->assertEmpty($response); } - #[Test] + /** @test */ public function it_can_fully_update_web_experience_profile(): void { $expectedResponse = ''; @@ -1661,7 +1659,7 @@ public function it_can_fully_update_web_experience_profile(): void $this->assertEmpty($response); } - #[Test] + /** @test */ public function it_can_get_web_experience_profile_details(): void { $expectedResponse = $this->mockWebProfileResponse(); @@ -1683,7 +1681,7 @@ public function it_can_get_web_experience_profile_details(): void $this->assertArrayHasKey('name', $response); } - #[Test] + /** @test */ public function it_can_capture_payment_for_an_order(): void { $this->client->setAccessToken([ @@ -1707,7 +1705,7 @@ public function it_can_capture_payment_for_an_order(): void $this->assertArrayHasKey('links', $response); } - #[Test] + /** @test */ public function it_can_show_details_for_an_authorized_payment(): void { $this->client->setAccessToken([ @@ -1727,7 +1725,7 @@ public function it_can_show_details_for_an_authorized_payment(): void $this->assertArrayHasKey('id', $response); } - #[Test] + /** @test */ public function it_can_capture_an_authorized_payment(): void { $this->client->setAccessToken([ @@ -1752,7 +1750,7 @@ public function it_can_capture_an_authorized_payment(): void $this->assertArrayHasKey('id', $response); } - #[Test] + /** @test */ public function it_can_reauthorize_an_authorized_payment(): void { $this->client->setAccessToken([ @@ -1772,7 +1770,7 @@ public function it_can_reauthorize_an_authorized_payment(): void $this->assertArrayHasKey('id', $response); } - #[Test] + /** @test */ public function it_can_void_an_authorized_payment(): void { $this->client->setAccessToken([ @@ -1789,7 +1787,7 @@ public function it_can_void_an_authorized_payment(): void $this->assertEmpty($response); } - #[Test] + /** @test */ public function it_can_show_details_for_a_captured_payment(): void { $this->client->setAccessToken([ @@ -1809,7 +1807,7 @@ public function it_can_show_details_for_a_captured_payment(): void $this->assertArrayHasKey('id', $response); } - #[Test] + /** @test */ public function it_can_refund_a_captured_payment(): void { $this->client->setAccessToken([ @@ -1834,7 +1832,7 @@ public function it_can_refund_a_captured_payment(): void $this->assertArrayHasKey('id', $response); } - #[Test] + /** @test */ public function it_can_show_details_for_a_refund(): void { $this->client->setAccessToken([ @@ -1854,7 +1852,7 @@ public function it_can_show_details_for_a_refund(): void $this->assertArrayHasKey('id', $response); } - #[Test] + /** @test */ public function it_can_create_batch_payout(): void { $expectedResponse = $this->mockCreateBatchPayoutResponse(); @@ -1876,7 +1874,7 @@ public function it_can_create_batch_payout(): void $this->assertArrayHasKey('batch_header', $response); } - #[Test] + /** @test */ public function it_can_show_batch_payout_details(): void { $expectedResponse = $this->showBatchPayoutResponse(); @@ -1899,7 +1897,7 @@ public function it_can_show_batch_payout_details(): void $this->assertArrayHasKey('items', $response); } - #[Test] + /** @test */ public function it_can_show_batch_payout_item_details(): void { $expectedResponse = $this->showBatchPayoutItemResponse(); @@ -1923,7 +1921,7 @@ public function it_can_show_batch_payout_item_details(): void $this->assertArrayHasKey('payout_item', $response); } - #[Test] + /** @test */ public function it_can_cancel_unclaimed_batch_payout_item(): void { $expectedResponse = $this->mockCancelUnclaimedBatchItemResponse(); @@ -1947,7 +1945,7 @@ public function it_can_cancel_unclaimed_batch_payout_item(): void $this->assertArrayHasKey('payout_item', $response); } - #[Test] + /** @test */ public function it_can_create_referenced_batch_payout(): void { $expectedResponse = $this->mockCreateReferencedBatchPayoutResponse(); @@ -1972,7 +1970,7 @@ public function it_can_create_referenced_batch_payout(): void $this->assertArrayHasKey('links', $response); } - #[Test] + /** @test */ public function it_can_list_items_referenced_in_batch_payout(): void { $expectedResponse = $this->mockShowReferencedBatchPayoutResponse(); @@ -1994,7 +1992,7 @@ public function it_can_list_items_referenced_in_batch_payout(): void $this->assertArrayHasKey('links', $response); } - #[Test] + /** @test */ public function it_can_create_referenced_batch_payout_item(): void { $expectedResponse = $this->mockCreateReferencedBatchPayoutItemResponse(); @@ -2019,7 +2017,7 @@ public function it_can_create_referenced_batch_payout_item(): void $this->assertArrayHasKey('links', $response); } - #[Test] + /** @test */ public function it_can_show_referenced_payout_item_details(): void { $expectedResponse = $this->mockShowReferencedBatchPayoutItemResponse(); @@ -2036,14 +2034,14 @@ public function it_can_show_referenced_payout_item_details(): void ); $response = $this->client->setRequestHeader('PayPal-Partner-Attribution-Id', 'some-attribution-id') - ->showReferencedPayoutItemDetails($expectedParams); + ->showReferencedPayoutItemDetails($expectedParams); $this->assertNotEmpty($response); $this->assertArrayHasKey('item_id', $response); $this->assertArrayHasKey('reference_id', $response); } - #[Test] + /** @test */ public function it_can_list_transactions(): void { $this->client->setAccessToken([ @@ -2068,7 +2066,7 @@ public function it_can_list_transactions(): void $this->assertGreaterThan(0, sizeof($response['transaction_details'])); } - #[Test] + /** @test */ public function it_can_list_account_balances(): void { $this->client->setAccessToken([ @@ -2089,7 +2087,7 @@ public function it_can_list_account_balances(): void $this->assertNotEmpty($response); } - #[Test] + /** @test */ public function it_can_list_account_balances_for_a_different_currency(): void { $this->client->setAccessToken([ @@ -2110,7 +2108,7 @@ public function it_can_list_account_balances_for_a_different_currency(): void $this->assertNotEmpty($response); } - #[Test] + /** @test */ public function it_can_create_a_subscription(): void { $this->client->setAccessToken([ @@ -2132,7 +2130,7 @@ public function it_can_create_a_subscription(): void $this->assertArrayHasKey('id', $response); } - #[Test] + /** @test */ public function it_can_update_a_subscription(): void { $this->client->setAccessToken([ @@ -2151,7 +2149,7 @@ public function it_can_update_a_subscription(): void $this->assertEmpty($response); } - #[Test] + /** @test */ public function it_can_show_details_for_a_subscription(): void { $this->client->setAccessToken([ @@ -2171,7 +2169,7 @@ public function it_can_show_details_for_a_subscription(): void $this->assertArrayHasKey('id', $response); } - #[Test] + /** @test */ public function it_can_activate_a_subscription(): void { $this->client->setAccessToken([ @@ -2188,7 +2186,7 @@ public function it_can_activate_a_subscription(): void $this->assertEmpty($response); } - #[Test] + /** @test */ public function it_can_cancel_a_subscription(): void { $this->client->setAccessToken([ @@ -2205,7 +2203,7 @@ public function it_can_cancel_a_subscription(): void $this->assertEmpty($response); } - #[Test] + /** @test */ public function it_can_suspend_a_subscription() { $this->client->setAccessToken([ @@ -2222,7 +2220,7 @@ public function it_can_suspend_a_subscription() $this->assertEmpty($response); } - #[Test] + /** @test */ public function it_can_capture_payment_for_a_subscription(): void { $this->client->setAccessToken([ @@ -2239,7 +2237,7 @@ public function it_can_capture_payment_for_a_subscription(): void $this->assertEmpty($response); } - #[Test] + /** @test */ public function it_can_update_quantity_or_product_for_a_subscription(): void { $this->client->setAccessToken([ @@ -2261,7 +2259,7 @@ public function it_can_update_quantity_or_product_for_a_subscription(): void $this->assertArrayHasKey('plan_id', $response); } - #[Test] + /** @test */ public function it_can_list_transactions_for_a_subscription(): void { $this->client->setAccessToken([ @@ -2281,7 +2279,7 @@ public function it_can_list_transactions_for_a_subscription(): void $this->assertEquals($response, $this->mockListSubscriptionTransactionsResponse()); } - #[Test] + /** @test */ public function it_can_list_tracking_details(): void { $this->client->setAccessToken([ @@ -2303,7 +2301,7 @@ public function it_can_list_tracking_details(): void $this->assertArrayHasKey('tracking_number', $response); } - #[Test] + /** @test */ public function it_can_get_tracking_details_for_tracking_id(): void { $this->client->setAccessToken([ @@ -2324,7 +2322,7 @@ public function it_can_get_tracking_details_for_tracking_id(): void $this->assertArrayHasKey('tracking_number', $response); } - #[Test] + /** @test */ public function it_can_update_tracking_details_for_tracking_id(): void { $this->client->setAccessToken([ @@ -2344,7 +2342,7 @@ public function it_can_update_tracking_details_for_tracking_id(): void $this->assertEmpty($response); } - #[Test] + /** @test */ public function it_can_create_tracking_in_batches(): void { $this->client->setAccessToken([ @@ -2366,7 +2364,7 @@ public function it_can_create_tracking_in_batches(): void $this->assertArrayHasKey('tracker_identifiers', $response); } - #[Test] + /** @test */ public function it_can_create_single_tracking_for_single_transaction(): void { $this->client->setAccessToken([ @@ -2388,7 +2386,7 @@ public function it_can_create_single_tracking_for_single_transaction(): void $this->assertArrayHasKey('tracker_identifiers', $response); } - #[Test] + /** @test */ public function it_can_list_web_hooks_event_types(): void { $this->client->setAccessToken([ @@ -2408,7 +2406,7 @@ public function it_can_list_web_hooks_event_types(): void $this->assertArrayHasKey('event_types', $response); } - #[Test] + /** @test */ public function it_can_list_web_hooks_events(): void { $this->client->setAccessToken([ @@ -2428,7 +2426,7 @@ public function it_can_list_web_hooks_events(): void $this->assertArrayHasKey('events', $response); } - #[Test] + /** @test */ public function it_can_show_details_for_a_web_hooks_event(): void { $this->client->setAccessToken([ @@ -2448,7 +2446,7 @@ public function it_can_show_details_for_a_web_hooks_event(): void $this->assertArrayHasKey('id', $response); } - #[Test] + /** @test */ public function it_can_resend_notification_for_a_web_hooks_event(): void { $this->client->setAccessToken([ @@ -2470,7 +2468,7 @@ public function it_can_resend_notification_for_a_web_hooks_event(): void $this->assertArrayHasKey('id', $response); } - #[Test] + /** @test */ public function it_can_create_a_web_hook(): void { $this->client->setAccessToken([ @@ -2493,7 +2491,7 @@ public function it_can_create_a_web_hook(): void $this->assertArrayHasKey('event_types', $response); } - #[Test] + /** @test */ public function it_can_list_web_hooks(): void { $this->client->setAccessToken([ @@ -2513,7 +2511,7 @@ public function it_can_list_web_hooks(): void $this->assertArrayHasKey('webhooks', $response); } - #[Test] + /** @test */ public function it_can_delete_a_web_hook(): void { $this->client->setAccessToken([ @@ -2530,7 +2528,7 @@ public function it_can_delete_a_web_hook(): void $this->assertEmpty($response); } - #[Test] + /** @test */ public function it_can_update_a_web_hook(): void { $this->client->setAccessToken([ @@ -2552,7 +2550,7 @@ public function it_can_update_a_web_hook(): void $this->assertArrayHasKey('event_types', $response); } - #[Test] + /** @test */ public function it_can_show_details_for_a_web_hook(): void { $this->client->setAccessToken([ @@ -2572,7 +2570,7 @@ public function it_can_show_details_for_a_web_hook(): void $this->assertArrayHasKey('event_types', $response); } - #[Test] + /** @test */ public function it_can_list_events_for_web_hooks(): void { $this->client->setAccessToken([ @@ -2592,7 +2590,7 @@ public function it_can_list_events_for_web_hooks(): void $this->assertArrayHasKey('event_types', $response); } - #[Test] + /** @test */ public function it_can_verify_web_hook_signature(): void { $this->client->setAccessToken([ @@ -2614,7 +2612,7 @@ public function it_can_verify_web_hook_signature(): void $this->assertArrayHasKey('verification_status', $response); } - #[Test] + /** @test */ public function it_can_list_payment_methods_source_tokens(): void { $this->client->setAccessToken([ @@ -2629,13 +2627,13 @@ public function it_can_list_payment_methods_source_tokens(): void ); $response = $this->client->setCustomerSource('customer_4029352050') - ->listPaymentSourceTokens(); + ->listPaymentSourceTokens(); $this->assertNotEmpty($response); $this->assertArrayHasKey('payment_tokens', $response); } - #[Test] + /** @test */ public function it_can_show_details_for_payment_method_source_token(): void { $this->client->setAccessToken([ @@ -2657,7 +2655,7 @@ public function it_can_show_details_for_payment_method_source_token(): void $this->assertArrayHasKey('payment_source', $response); } - #[Test] + /** @test */ public function it_can_delete_a_payment_method_source_token(): void { $this->client->setAccessToken([ @@ -2674,7 +2672,7 @@ public function it_can_delete_a_payment_method_source_token(): void $this->assertEmpty($response); } - #[Test] + /** @test */ public function it_can_show_details_for_payment_setup_token(): void { $this->client->setAccessToken([ diff --git a/tests/Feature/AdapterOrdersHelperTest.php b/tests/Feature/AdapterOrdersHelperTest.php index 1cbc0c53..1b5061d2 100644 --- a/tests/Feature/AdapterOrdersHelperTest.php +++ b/tests/Feature/AdapterOrdersHelperTest.php @@ -3,7 +3,6 @@ namespace Srmklive\PayPal\Tests\Feature; use Carbon\Carbon; -use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use Srmklive\PayPal\Services\PayPal as PayPalClient; use Srmklive\PayPal\Tests\MockClientClasses; @@ -17,10 +16,10 @@ class AdapterOrdersHelperTest extends TestCase use MockResponsePayloads; /** @var string */ - protected static string $access_token = ''; + protected static $access_token = ''; /** @var PayPalClient */ - protected PayPalClient $client; + protected $client; protected function setUp(): void { @@ -38,7 +37,7 @@ protected function setUp(): void parent::setUp(); } - #[Test] + /** @test */ public function it_can_confirm_payment_for_an_order(): void { $this->client->setAccessToken([ diff --git a/tests/Feature/AdapterPaymentMethodTokensHelpersTest.php b/tests/Feature/AdapterPaymentMethodTokensHelpersTest.php index f981abc4..f3e04dec 100644 --- a/tests/Feature/AdapterPaymentMethodTokensHelpersTest.php +++ b/tests/Feature/AdapterPaymentMethodTokensHelpersTest.php @@ -2,7 +2,6 @@ namespace Srmklive\PayPal\Tests\Feature; -use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use Srmklive\PayPal\Services\PayPal as PayPalClient; use Srmklive\PayPal\Tests\MockClientClasses; @@ -16,10 +15,10 @@ class AdapterPaymentMethodTokensHelpersTest extends TestCase use MockResponsePayloads; /** @var string */ - protected static string $access_token = ''; + protected static $access_token = ''; /** @var PayPalClient */ - protected PayPalClient $client; + protected $client; protected function setUp(): void { @@ -37,7 +36,7 @@ protected function setUp(): void parent::setUp(); } - #[Test] + /** @test */ public function it_can_create_payment_token_from_a_vault_token(): void { $this->client->setAccessToken([ @@ -60,7 +59,7 @@ public function it_can_create_payment_token_from_a_vault_token(): void $this->assertArrayHasKey('customer', $response); } - #[Test] + /** @test */ public function it_can_create_payment_source_from_a_vault_token(): void { $this->client->setAccessToken([ @@ -82,7 +81,7 @@ public function it_can_create_payment_source_from_a_vault_token(): void $this->assertArrayHasKey('payment_source', $response); } - #[Test] + /** @test */ public function it_can_create_payment_source_from_a_credit_card(): void { $this->client->setAccessToken([ @@ -104,7 +103,7 @@ public function it_can_create_payment_source_from_a_credit_card(): void $this->assertArrayHasKey('payment_source', $response); } - #[Test] + /** @test */ public function it_can_create_payment_source_from_a_paypal_account(): void { $this->client->setAccessToken([ @@ -128,7 +127,7 @@ public function it_can_create_payment_source_from_a_paypal_account(): void $this->assertArrayHasKey('payment_source', $response); } - #[Test] + /** @test */ public function it_can_create_payment_source_from_a_venmo_account(): void { $this->client->setAccessToken([ diff --git a/tests/MockClientClasses.php b/tests/MockClientClasses.php index 109fe3fe..4d8b2037 100644 --- a/tests/MockClientClasses.php +++ b/tests/MockClientClasses.php @@ -7,19 +7,21 @@ use GuzzleHttp\HandlerStack as HttpHandlerStack; use GuzzleHttp\Psr7\Response as HttpResponse; use GuzzleHttp\Psr7\Stream as HttpStream; -use GuzzleHttp\Utils; use Psr\Http\Message\ResponseInterface; use Srmklive\PayPal\Services\PayPal as PayPalClient; +use Srmklive\PayPal\Traits\JsonEncodeDecodeSelector; trait MockClientClasses { + use JsonEncodeDecodeSelector; + private function mock_http_client($response): HttpClient { $mock = new HttpMockHandler([ new HttpResponse( 200, [], - ($response === false) ? '' : Utils::jsonEncode($response) + ($response === false) ? '' : $this->jsonEncodeFunction()($response) ), ]); @@ -55,7 +57,7 @@ private function mock_client($expectedResponse, $expectedMethod, $token = false, $methods = [$expectedMethod, 'setApiCredentials']; $methods[] = ($token) ? 'getAccessToken' : ''; - $methods[] = isset($additionalMethod) ? $additionalMethod : ''; + $methods[] = $additionalMethod ?? ''; $mockClient = $this->getMockBuilder(PayPalClient::class) ->{$set_method_name}(array_filter($methods)) @@ -71,6 +73,9 @@ private function mock_client($expectedResponse, $expectedMethod, $token = false, ->method($additionalMethod); } + $mockClient->expects($this->exactly(1)) + ->method('setApiCredentials'); + $mockClient->expects($this->exactly(1)) ->method('setApiCredentials'); diff --git a/tests/Mocks/Requests/BillingPlans.php b/tests/Mocks/Requests/BillingPlans.php index 731d5837..884fb9e8 100644 --- a/tests/Mocks/Requests/BillingPlans.php +++ b/tests/Mocks/Requests/BillingPlans.php @@ -2,8 +2,6 @@ namespace Srmklive\PayPal\Tests\Mocks\Requests; -use GuzzleHttp\Utils; - trait BillingPlans { /** @@ -11,7 +9,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 +82,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 +96,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..b3c86875 100644 --- a/tests/Mocks/Requests/CatalogProducts.php +++ b/tests/Mocks/Requests/CatalogProducts.php @@ -2,8 +2,6 @@ namespace Srmklive\PayPal\Tests\Mocks\Requests; -use GuzzleHttp\Utils; - trait CatalogProducts { /** @@ -11,7 +9,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 +24,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..d87c01b5 100644 --- a/tests/Mocks/Requests/Disputes.php +++ b/tests/Mocks/Requests/Disputes.php @@ -2,8 +2,6 @@ namespace Srmklive\PayPal\Tests\Mocks\Requests; -use GuzzleHttp\Utils; - trait Disputes { /** @@ -11,7 +9,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..ee61a252 100644 --- a/tests/Mocks/Requests/DisputesActions.php +++ b/tests/Mocks/Requests/DisputesActions.php @@ -2,8 +2,6 @@ namespace Srmklive\PayPal\Tests\Mocks\Requests; -use GuzzleHttp\Utils; - trait DisputesActions { /** @@ -11,7 +9,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 +20,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 +30,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..b3d388b1 100644 --- a/tests/Mocks/Requests/Identity.php +++ b/tests/Mocks/Requests/Identity.php @@ -2,13 +2,11 @@ namespace Srmklive\PayPal\Tests\Mocks\Requests; -use GuzzleHttp\Utils; - trait Identity { private function mockCreateMerchantApplicationParams(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "redirect_uris": [ "https://example.com/callback", "https://example.com/callback2" @@ -29,7 +27,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..5f9cfb1a 100644 --- a/tests/Mocks/Requests/Invoices.php +++ b/tests/Mocks/Requests/Invoices.php @@ -2,8 +2,6 @@ namespace Srmklive\PayPal\Tests\Mocks\Requests; -use GuzzleHttp\Utils; - trait Invoices { /** @@ -11,7 +9,7 @@ trait Invoices */ private function createInvoiceParams(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "detail": { "invoice_number": "#123", "reference": "deal-ref", @@ -175,7 +173,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 +373,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 +389,7 @@ private function cancelInvoiceParams(): array */ private function generateQRCodeInvoiceParams(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "width": 400, "height": 400 }', true); @@ -402,7 +400,7 @@ private function generateQRCodeInvoiceParams(): array */ private function registerInvoicePaymentParams(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "width": 400, "height": 400 }', true); @@ -413,7 +411,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 +426,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 +442,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..ac9d24c6 100644 --- a/tests/Mocks/Requests/InvoicesSearch.php +++ b/tests/Mocks/Requests/InvoicesSearch.php @@ -2,8 +2,6 @@ namespace Srmklive\PayPal\Tests\Mocks\Requests; -use GuzzleHttp\Utils; - trait InvoicesSearch { /** @@ -11,7 +9,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..e3d8b995 100644 --- a/tests/Mocks/Requests/InvoicesTemplates.php +++ b/tests/Mocks/Requests/InvoicesTemplates.php @@ -2,8 +2,6 @@ namespace Srmklive\PayPal\Tests\Mocks\Requests; -use GuzzleHttp\Utils; - trait InvoicesTemplates { /** @@ -11,7 +9,7 @@ trait InvoicesTemplates */ private function mockCreateInvoiceTemplateParams(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "default_template": true, "template_info": { "configuration": { @@ -241,7 +239,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 7b1c8fbd..e6192997 100644 --- a/tests/Mocks/Requests/Orders.php +++ b/tests/Mocks/Requests/Orders.php @@ -2,8 +2,6 @@ namespace Srmklive\PayPal\Tests\Mocks\Requests; -use GuzzleHttp\Utils; - trait Orders { /* @@ -11,16 +9,16 @@ trait Orders */ private function createOrderParams(): array { - return Utils::jsonDecode('{ - "intent": "CAPTURE", - "purchase_units": [ - { - "amount": { - "currency_code": "USD", - "value": "100.00" - } - } - ] + return $this->jsonDecodeFunction()('{ + "intent": "CAPTURE", + "purchase_units": [ + { + "amount": { + "currency_code": "USD", + "value": "100.00" + } + } + ] }', true); } @@ -29,19 +27,19 @@ private function createOrderParams(): array */ private function updateOrderParams(): array { - return Utils::jsonDecode('[ - { - "op": "replace", - "path": "/purchase_units/@reference_id==\'PUHF\'/shipping/address", - "value": { - "address_line_1": "123 Townsend St", - "address_line_2": "Floor 6", - "admin_area_2": "San Francisco", - "admin_area_1": "CA", - "postal_code": "94107", - "country_code": "US" - } - } + return $this->jsonDecodeFunction()('[ + { + "op": "replace", + "path": "/purchase_units/@reference_id==\'PUHF\'/shipping/address", + "value": { + "address_line_1": "123 Townsend St", + "address_line_2": "Floor 6", + "admin_area_2": "San Francisco", + "admin_area_1": "CA", + "postal_code": "94107", + "country_code": "US" + } + } ]', true); } } diff --git a/tests/Mocks/Requests/PartnerReferrals.php b/tests/Mocks/Requests/PartnerReferrals.php index d7597f67..b42abc97 100644 --- a/tests/Mocks/Requests/PartnerReferrals.php +++ b/tests/Mocks/Requests/PartnerReferrals.php @@ -2,13 +2,11 @@ namespace Srmklive\PayPal\Tests\Mocks\Requests; -use GuzzleHttp\Utils; - 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..e9507340 100644 --- a/tests/Mocks/Requests/PaymentAuthorizations.php +++ b/tests/Mocks/Requests/PaymentAuthorizations.php @@ -2,8 +2,6 @@ namespace Srmklive\PayPal\Tests\Mocks\Requests; -use GuzzleHttp\Utils; - trait PaymentAuthorizations { /** @@ -11,7 +9,7 @@ trait PaymentAuthorizations */ private function mockCaptureAuthorizedPaymentParams(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "amount": { "value": "10.99", "currency_code": "USD" @@ -27,7 +25,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..3b70c337 100644 --- a/tests/Mocks/Requests/PaymentCaptures.php +++ b/tests/Mocks/Requests/PaymentCaptures.php @@ -2,8 +2,6 @@ namespace Srmklive\PayPal\Tests\Mocks\Requests; -use GuzzleHttp\Utils; - trait PaymentCaptures { /** @@ -11,7 +9,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..7f9426c9 100644 --- a/tests/Mocks/Requests/PaymentExperienceWebProfiles.php +++ b/tests/Mocks/Requests/PaymentExperienceWebProfiles.php @@ -2,8 +2,6 @@ namespace Srmklive\PayPal\Tests\Mocks\Requests; -use GuzzleHttp\Utils; - trait PaymentExperienceWebProfiles { /** @@ -11,7 +9,7 @@ trait PaymentExperienceWebProfiles */ private function mockCreateWebProfileParams(): array { - return Utils::jsonDecode('[ + return $this->jsonDecodeFunction()('[ { "id": "XP-GCUV-X35G-HNEY-5MJY", "name": "exampleProfile", @@ -64,7 +62,7 @@ private function mockCreateWebProfileParams(): array */ private function partiallyUpdateWebProfileParams(): array { - return Utils::jsonDecode('[ + return $this->jsonDecodeFunction()('[ { "op": "add", "path": "/presentation/brand_name", @@ -82,7 +80,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..ef4aea56 100644 --- a/tests/Mocks/Requests/PaymentMethodsTokens.php +++ b/tests/Mocks/Requests/PaymentMethodsTokens.php @@ -2,8 +2,6 @@ namespace Srmklive\PayPal\Tests\Mocks\Requests; -use GuzzleHttp\Utils; - trait PaymentMethodsTokens { /** @@ -11,7 +9,7 @@ trait PaymentMethodsTokens */ private function mockCreatePaymentSetupTokensParams(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "payment_source": { "card": { "number": "4111111111111111", @@ -41,7 +39,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..b4a371f2 100644 --- a/tests/Mocks/Requests/Payouts.php +++ b/tests/Mocks/Requests/Payouts.php @@ -2,8 +2,6 @@ namespace Srmklive\PayPal\Tests\Mocks\Requests; -use GuzzleHttp\Utils; - trait Payouts { /** @@ -11,7 +9,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..54734f7d 100644 --- a/tests/Mocks/Requests/ReferencedPayouts.php +++ b/tests/Mocks/Requests/ReferencedPayouts.php @@ -2,8 +2,6 @@ namespace Srmklive\PayPal\Tests\Mocks\Requests; -use GuzzleHttp\Utils; - trait ReferencedPayouts { /** @@ -11,7 +9,7 @@ trait ReferencedPayouts */ private function mockCreateReferencedBatchPayoutParams(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "referenced_payouts": [ { "reference_id": "2KP03934U4415543C", @@ -30,7 +28,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..9fce602f 100644 --- a/tests/Mocks/Requests/Subscriptions.php +++ b/tests/Mocks/Requests/Subscriptions.php @@ -2,8 +2,6 @@ namespace Srmklive\PayPal\Tests\Mocks\Requests; -use GuzzleHttp\Utils; - trait Subscriptions { /** @@ -11,7 +9,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 +57,7 @@ private function mockCreateSubscriptionParams(): array */ private function mockUpdateSubscriptionParams(): array { - return Utils::jsonDecode('[ + return $this->jsonDecodeFunction()('[ { "op": "replace", "path": "/billing_info/outstanding_balance", @@ -76,7 +74,7 @@ private function mockUpdateSubscriptionParams(): array */ private function mockActivateSubscriptionParams() { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "reason": "Reactivating the subscription" }', true); } @@ -86,7 +84,7 @@ private function mockActivateSubscriptionParams() */ private function mockCancelSubscriptionParams() { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "reason": "Not satisfied with the service" }', true); } @@ -96,7 +94,7 @@ private function mockCancelSubscriptionParams() */ private function mockSuspendSubscriptionParams() { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "reason": "Item out of stock" }', true); } @@ -106,7 +104,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 +119,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..4561cfa7 100644 --- a/tests/Mocks/Requests/Trackers.php +++ b/tests/Mocks/Requests/Trackers.php @@ -2,8 +2,6 @@ namespace Srmklive\PayPal\Tests\Mocks\Requests; -use GuzzleHttp\Utils; - trait Trackers { /** @@ -11,7 +9,7 @@ trait Trackers */ private function mockUpdateTrackingDetailsParams(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "transaction_id": "8MC585209K746392H", "tracking_number": "443844607820", "status": "SHIPPED", @@ -24,7 +22,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..a8254a3a 100644 --- a/tests/Mocks/Requests/WebHooks.php +++ b/tests/Mocks/Requests/WebHooks.php @@ -2,8 +2,6 @@ namespace Srmklive\PayPal\Tests\Mocks\Requests; -use GuzzleHttp\Utils; - trait WebHooks { /** @@ -11,7 +9,7 @@ trait WebHooks */ private function mockCreateWebHookParams(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "url": "https://example.com/example_webhook", "event_types": [ { @@ -29,7 +27,7 @@ private function mockCreateWebHookParams(): array */ private function mockUpdateWebHookParams(): array { - return Utils::jsonDecode('[ + return $this->jsonDecodeFunction()('[ { "op": "replace", "path": "/url", @@ -52,7 +50,7 @@ private function mockUpdateWebHookParams(): array */ private function mockResendWebHookEventNotificationParams(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "webhook_ids": [ "12334456" ] @@ -64,7 +62,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 02fb3eb4..0544f922 100644 --- a/tests/Mocks/Responses/BillingPlans.php +++ b/tests/Mocks/Responses/BillingPlans.php @@ -2,8 +2,6 @@ namespace Srmklive\PayPal\Tests\Mocks\Responses; -use GuzzleHttp\Utils; - trait BillingPlans { /** @@ -11,7 +9,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 +116,7 @@ private function mockCreatePlansResponse(): array */ private function mockListPlansResponse(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "total_items": 12, "total_pages": 6, "plans": [ @@ -183,7 +181,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 45fbdf9f..e8216fe3 100644 --- a/tests/Mocks/Responses/CatalogProducts.php +++ b/tests/Mocks/Responses/CatalogProducts.php @@ -2,8 +2,6 @@ namespace Srmklive\PayPal\Tests\Mocks\Responses; -use GuzzleHttp\Utils; - trait CatalogProducts { /** @@ -11,7 +9,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 +39,7 @@ private function mockCreateCatalogProductsResponse(): array */ private function mockListCatalogProductsResponse(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "total_items": 20, "total_pages": 1, "products": [ @@ -97,7 +95,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..50cfb1c9 100644 --- a/tests/Mocks/Responses/Disputes.php +++ b/tests/Mocks/Responses/Disputes.php @@ -2,8 +2,6 @@ namespace Srmklive\PayPal\Tests\Mocks\Responses; -use GuzzleHttp\Utils; - trait Disputes { /** @@ -11,7 +9,7 @@ trait Disputes */ private function mockListDisputesResponse(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "items": [ { "dispute_id": "PP-000-003-648-191", @@ -71,7 +69,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..68fa3d98 100644 --- a/tests/Mocks/Responses/DisputesActions.php +++ b/tests/Mocks/Responses/DisputesActions.php @@ -2,8 +2,6 @@ namespace Srmklive\PayPal\Tests\Mocks\Responses; -use GuzzleHttp\Utils; - trait DisputesActions { /** @@ -11,7 +9,7 @@ trait DisputesActions */ private function mockAcceptDisputesClaimResponse(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "links": [ { "rel": "self", @@ -27,7 +25,7 @@ private function mockAcceptDisputesClaimResponse(): array */ private function mockAcceptDisputesOfferResolutionResponse(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "links": [ { "rel": "self", @@ -43,7 +41,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..c63b2c32 100644 --- a/tests/Mocks/Responses/Identity.php +++ b/tests/Mocks/Responses/Identity.php @@ -2,13 +2,11 @@ namespace Srmklive\PayPal\Tests\Mocks\Responses; -use GuzzleHttp\Utils; - 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 +19,7 @@ private function mockShowProfileInfoResponse(): array private function mocklistUsersResponse(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "schemas": [ "http://example.com" ], @@ -88,7 +86,7 @@ private function mocklistUsersResponse(): array private function mocklistUserResponse(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "schemas": [ "http://example.com" ], @@ -145,7 +143,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 +172,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..241c14ba 100644 --- a/tests/Mocks/Responses/Invoices.php +++ b/tests/Mocks/Responses/Invoices.php @@ -2,8 +2,6 @@ namespace Srmklive\PayPal\Tests\Mocks\Responses; -use GuzzleHttp\Utils; - trait Invoices { /** @@ -11,7 +9,7 @@ trait Invoices */ private function mockGenerateInvoiceNumberResponse(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "invoice_number": "ee0044" }', true); } @@ -21,7 +19,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 +260,7 @@ private function mockCreateInvoicesResponse(): array */ private function mockListInvoicesResponse(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "total_items": 2, "total_pages": 1, "items": [ @@ -391,7 +389,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 +620,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 +869,7 @@ private function mockGenerateInvoiceQRCodeResponse(): string */ private function mockInvoiceRegisterPaymentResponse(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "payment_id": "EXTR-86F38350LX4353815" }', true); } @@ -881,7 +879,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..0740c13b 100644 --- a/tests/Mocks/Responses/InvoicesSearch.php +++ b/tests/Mocks/Responses/InvoicesSearch.php @@ -2,8 +2,6 @@ namespace Srmklive\PayPal\Tests\Mocks\Responses; -use GuzzleHttp\Utils; - trait InvoicesSearch { /** @@ -11,7 +9,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..1c1f16b8 100644 --- a/tests/Mocks/Responses/InvoicesTemplates.php +++ b/tests/Mocks/Responses/InvoicesTemplates.php @@ -2,8 +2,6 @@ namespace Srmklive\PayPal\Tests\Mocks\Responses; -use GuzzleHttp\Utils; - trait InvoicesTemplates { /** @@ -11,7 +9,7 @@ trait InvoicesTemplates */ private function mockCreateInvoiceTemplateResponse(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "id": "TEMP-19V05281TU309413B", "name": "reference-temp", "default_template": true, @@ -299,7 +297,7 @@ private function mockCreateInvoiceTemplateResponse(): array */ private function mockListInvoiceTemplateResponse() { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "addresses": [ { "address_line_1": "1234 First Street", @@ -672,7 +670,7 @@ private function mockListInvoiceTemplateResponse() */ private function mockUpdateInvoiceTemplateResponse() { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "id": "TEMP-19V05281TU309413B", "name": "reference-temp", "default_template": true, @@ -960,7 +958,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 8bc8fa52..f7f57d68 100644 --- a/tests/Mocks/Responses/Orders.php +++ b/tests/Mocks/Responses/Orders.php @@ -2,8 +2,6 @@ namespace Srmklive\PayPal\Tests\Mocks\Responses; -use GuzzleHttp\Utils; - trait Orders { /** @@ -11,7 +9,7 @@ trait Orders */ public function mockCreateOrdersResponse(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "id": "5O190127TN364715T", "status": "CREATED", "links": [ @@ -52,7 +50,7 @@ public function mockUpdateOrdersResponse() */ public function mockOrderDetailsResponse(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "id": "5O190127TN364715T", "status": "PAYER_ACTION_REQUIRED", "intent": "CAPTURE", @@ -95,7 +93,7 @@ public function mockOrderDetailsResponse(): array */ public function mockOrderPaymentAuthorizedResponse(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "id": "5O190127TN364715T", "status": "COMPLETED", "payer": { @@ -180,7 +178,7 @@ public function mockOrderPaymentAuthorizedResponse(): array */ public function mockOrderPaymentCapturedResponse(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "id": "5O190127TN364715T", "status": "COMPLETED", "payer": { @@ -267,7 +265,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 0c620e32..11fbc39f 100644 --- a/tests/Mocks/Responses/PartnerReferrals.php +++ b/tests/Mocks/Responses/PartnerReferrals.php @@ -2,13 +2,11 @@ namespace Srmklive\PayPal\Tests\Mocks\Responses; -use GuzzleHttp\Utils; - 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 +24,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..c6560f7b 100644 --- a/tests/Mocks/Responses/PaymentAuthorizations.php +++ b/tests/Mocks/Responses/PaymentAuthorizations.php @@ -2,8 +2,6 @@ namespace Srmklive\PayPal\Tests\Mocks\Responses; -use GuzzleHttp\Utils; - trait PaymentAuthorizations { /** @@ -11,7 +9,7 @@ trait PaymentAuthorizations */ private function mockGetAuthorizedPaymentDetailsResponse(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "id": "0VF52814937998046", "status": "AUTHORIZED", "amount": { @@ -59,7 +57,7 @@ private function mockGetAuthorizedPaymentDetailsResponse(): array */ private function mockCaptureAuthorizedPaymentResponse(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "id": "2GG279541U471931P", "status": "COMPLETED", "links": [ @@ -87,7 +85,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..256ad895 100644 --- a/tests/Mocks/Responses/PaymentCaptures.php +++ b/tests/Mocks/Responses/PaymentCaptures.php @@ -2,8 +2,6 @@ namespace Srmklive\PayPal\Tests\Mocks\Responses; -use GuzzleHttp\Utils; - trait PaymentCaptures { /** @@ -11,7 +9,7 @@ trait PaymentCaptures */ private function mockGetCapturedPaymentDetailsResponse(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "id": "2GG279541U471931P", "status": "COMPLETED", "status_details": {}, @@ -69,7 +67,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..14bda116 100644 --- a/tests/Mocks/Responses/PaymentExperienceWebProfiles.php +++ b/tests/Mocks/Responses/PaymentExperienceWebProfiles.php @@ -2,8 +2,6 @@ namespace Srmklive\PayPal\Tests\Mocks\Responses; -use GuzzleHttp\Utils; - trait PaymentExperienceWebProfiles { /** @@ -11,7 +9,7 @@ trait PaymentExperienceWebProfiles */ private function mockListWebProfilesResponse(): array { - return Utils::jsonDecode('[ + return $this->jsonDecodeFunction()('[ { "id": "XP-GCUV-X35G-HNEY-5MJY", "name": "exampleProfile", @@ -64,7 +62,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..58778cb5 100644 --- a/tests/Mocks/Responses/PaymentMethodsTokens.php +++ b/tests/Mocks/Responses/PaymentMethodsTokens.php @@ -2,8 +2,6 @@ namespace Srmklive\PayPal\Tests\Mocks\Responses; -use GuzzleHttp\Utils; - trait PaymentMethodsTokens { /** @@ -11,7 +9,7 @@ trait PaymentMethodsTokens */ private function mockCreatePaymentMethodsTokenResponse(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "id": "8kk8451t", "customer": { "id": "customer_4029352050" @@ -54,7 +52,7 @@ private function mockCreatePaymentMethodsTokenResponse(): array */ private function mockListPaymentMethodsTokensResponse(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "customer": { "id": "customer_4029352050" }, @@ -298,7 +296,7 @@ private function mockListPaymentMethodsTokensResponse(): array */ private function mockCreatePaymentSetupTokenResponse(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "payment_source": { "card": { "number": "4111111111111111", @@ -328,7 +326,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..268bd830 100644 --- a/tests/Mocks/Responses/PaymentRefunds.php +++ b/tests/Mocks/Responses/PaymentRefunds.php @@ -2,8 +2,6 @@ namespace Srmklive\PayPal\Tests\Mocks\Responses; -use GuzzleHttp\Utils; - trait PaymentRefunds { /** @@ -11,7 +9,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..5f1823e3 100644 --- a/tests/Mocks/Responses/Payouts.php +++ b/tests/Mocks/Responses/Payouts.php @@ -2,8 +2,6 @@ namespace Srmklive\PayPal\Tests\Mocks\Responses; -use GuzzleHttp\Utils; - trait Payouts { /** @@ -11,7 +9,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 +27,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 +210,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 +251,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..e961438d 100644 --- a/tests/Mocks/Responses/ReferencedPayouts.php +++ b/tests/Mocks/Responses/ReferencedPayouts.php @@ -2,8 +2,6 @@ namespace Srmklive\PayPal\Tests\Mocks\Responses; -use GuzzleHttp\Utils; - trait ReferencedPayouts { /** @@ -11,7 +9,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 +25,7 @@ private function mockCreateReferencedBatchPayoutResponse(): array */ private function mockShowReferencedBatchPayoutResponse(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "referenced_payouts": [ { "item_id": "dVeQhMc5Ck5WPw2gWYDLzh3qM2Dp1XbRlZb9fDouzLzDhx1eMYYTFe3syHEKKx4=", @@ -93,7 +91,7 @@ private function mockShowReferencedBatchPayoutResponse(): array */ private function mockCreateReferencedBatchPayoutItemResponse(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "item_id": "SOMEITEMID", "links": [ { @@ -110,7 +108,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..20e1a853 100644 --- a/tests/Mocks/Responses/Reporting.php +++ b/tests/Mocks/Responses/Reporting.php @@ -2,8 +2,6 @@ namespace Srmklive\PayPal\Tests\Mocks\Responses; -use GuzzleHttp\Utils; - trait Reporting { /** @@ -11,7 +9,7 @@ trait Reporting */ private function mockListTransactionsResponse(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "transaction_details": [ { "transaction_info": { @@ -169,7 +167,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..32d5346f 100644 --- a/tests/Mocks/Responses/Subscriptions.php +++ b/tests/Mocks/Responses/Subscriptions.php @@ -2,8 +2,6 @@ namespace Srmklive\PayPal\Tests\Mocks\Responses; -use GuzzleHttp\Utils; - trait Subscriptions { /** @@ -11,7 +9,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 +67,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 +174,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 +209,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..6b19bb8e 100644 --- a/tests/Mocks/Responses/Trackers.php +++ b/tests/Mocks/Responses/Trackers.php @@ -2,8 +2,6 @@ namespace Srmklive\PayPal\Tests\Mocks\Responses; -use GuzzleHttp\Utils; - trait Trackers { /** @@ -11,7 +9,7 @@ trait Trackers */ private function mockGetTrackingDetailsResponse(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "transaction_id": "8MC585209K746392H", "tracking_number": "443844607820", "status": "SHIPPED", @@ -40,7 +38,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..70f8fb05 100644 --- a/tests/Mocks/Responses/WebHooks.php +++ b/tests/Mocks/Responses/WebHooks.php @@ -2,8 +2,6 @@ namespace Srmklive\PayPal\Tests\Mocks\Responses; -use GuzzleHttp\Utils; - trait WebHooks { /** @@ -11,7 +9,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 +47,7 @@ private function mockCreateWebHookResponse(): array */ private function mockListWebHookResponse(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "webhooks": [ { "id": "40Y916089Y8324740", @@ -122,7 +120,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 +154,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 +194,7 @@ private function mockGetWebHookResponse(): array */ private function mockListWebHookEventsResponse(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "event_types": [ { "name": "PAYMENT.AUTHORIZATION.CREATED", @@ -222,7 +220,7 @@ private function mockListWebHookEventsResponse(): array */ private function mockListWebHookEventsTypesResponse(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "event_types": [ { "name": "PAYMENT.AUTHORIZATION.CREATED", @@ -257,7 +255,7 @@ private function mockListWebHookEventsTypesResponse(): array */ private function mockWebHookEventsListResponse(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "events": [ { "id": "8PT597110X687430LKGECATA", @@ -397,7 +395,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 +460,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 +525,7 @@ private function mockResendWebHookEventNotificationResponse(): array */ private function mockVerifyWebHookSignatureResponse(): array { - return Utils::jsonDecode('{ + return $this->jsonDecodeFunction()('{ "verification_status": "SUCCESS" }', true); } diff --git a/tests/Unit/Adapter/BillingPlansTest.php b/tests/Unit/Adapter/BillingPlansTest.php index 75740558..120766ea 100644 --- a/tests/Unit/Adapter/BillingPlansTest.php +++ b/tests/Unit/Adapter/BillingPlansTest.php @@ -2,7 +2,6 @@ namespace Srmklive\PayPal\Tests\Unit\Adapter; -use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use Srmklive\PayPal\Tests\MockClientClasses; use Srmklive\PayPal\Tests\MockRequestPayloads; @@ -14,7 +13,7 @@ class BillingPlansTest extends TestCase use MockRequestPayloads; use MockResponsePayloads; - #[Test] + /** @test */ public function it_can_create_a_billing_plan(): void { $expectedResponse = $this->mockCreatePlansResponse(); @@ -33,7 +32,7 @@ public function it_can_create_a_billing_plan(): void $this->assertEquals($expectedResponse, $mockClient->{$expectedMethod}($expectedParams, 'some-request-id')); } - #[Test] + /** @test */ public function it_can_list_billing_plans(): void { $expectedResponse = $this->mockListPlansResponse(); @@ -48,7 +47,7 @@ public function it_can_list_billing_plans(): void $this->assertEquals($expectedResponse, $mockClient->{$expectedMethod}(1, 2, true)); } - #[Test] + /** @test */ public function it_can_update_a_billing_plan(): void { $expectedResponse = ''; @@ -65,7 +64,7 @@ public function it_can_update_a_billing_plan(): void $this->assertEquals($expectedResponse, $mockClient->{$expectedMethod}('P-7GL4271244454362WXNWU5NQ', $expectedParams)); } - #[Test] + /** @test */ public function it_can_show_details_for_a_billing_plan(): void { $expectedResponse = $this->mockGetPlansResponse(); @@ -80,7 +79,7 @@ public function it_can_show_details_for_a_billing_plan(): void $this->assertEquals($expectedResponse, $mockClient->{$expectedMethod}('P-7GL4271244454362WXNWU5NQ')); } - #[Test] + /** @test */ public function it_can_activate_a_billing_plan(): void { $expectedResponse = ''; @@ -95,7 +94,7 @@ public function it_can_activate_a_billing_plan(): void $this->assertEquals($expectedResponse, $mockClient->{$expectedMethod}('P-7GL4271244454362WXNWU5NQ')); } - #[Test] + /** @test */ public function it_can_deactivate_a_billing_plan(): void { $expectedResponse = ''; @@ -110,7 +109,7 @@ public function it_can_deactivate_a_billing_plan(): void $this->assertEquals($expectedResponse, $mockClient->{$expectedMethod}('P-7GL4271244454362WXNWU5NQ')); } - #[Test] + /** @test */ public function it_can_update_pricing_for_a_billing_plan(): void { $expectedResponse = ''; diff --git a/tests/Unit/Adapter/CatalogProductsTest.php b/tests/Unit/Adapter/CatalogProductsTest.php index 20797583..3595dd1f 100644 --- a/tests/Unit/Adapter/CatalogProductsTest.php +++ b/tests/Unit/Adapter/CatalogProductsTest.php @@ -2,7 +2,6 @@ namespace Srmklive\PayPal\Tests\Unit\Adapter; -use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use Srmklive\PayPal\Tests\MockClientClasses; use Srmklive\PayPal\Tests\MockRequestPayloads; @@ -14,7 +13,7 @@ class CatalogProductsTest extends TestCase use MockRequestPayloads; use MockResponsePayloads; - #[Test] + /** @test */ public function it_can_create_a_product(): void { $expectedResponse = $this->mockCreateCatalogProductsResponse(); @@ -33,7 +32,7 @@ public function it_can_create_a_product(): void $this->assertEquals($expectedResponse, $mockClient->{$expectedMethod}($expectedParams)); } - #[Test] + /** @test */ public function it_can_list_products(): void { $expectedResponse = $this->mockListCatalogProductsResponse(); @@ -48,7 +47,7 @@ public function it_can_list_products(): void $this->assertEquals($expectedResponse, $mockClient->{$expectedMethod}()); } - #[Test] + /** @test */ public function it_can_update_a_product(): void { $expectedResponse = ''; @@ -65,7 +64,7 @@ public function it_can_update_a_product(): void $this->assertEquals($expectedResponse, $mockClient->{$expectedMethod}('72255d4849af8ed6e0df1173', $expectedParams)); } - #[Test] + /** @test */ public function it_can_get_details_for_a_product(): void { $expectedResponse = $this->mockGetCatalogProductsResponse(); diff --git a/tests/Unit/Adapter/DisputeActionsTest.php b/tests/Unit/Adapter/DisputeActionsTest.php index ec962968..8cab5063 100644 --- a/tests/Unit/Adapter/DisputeActionsTest.php +++ b/tests/Unit/Adapter/DisputeActionsTest.php @@ -2,7 +2,6 @@ namespace Srmklive\PayPal\Tests\Unit\Adapter; -use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use Srmklive\PayPal\Tests\MockClientClasses; use Srmklive\PayPal\Tests\MockResponsePayloads; @@ -12,7 +11,7 @@ class DisputeActionsTest extends TestCase use MockClientClasses; use MockResponsePayloads; - #[Test] + /** @test */ public function it_can_accept_dispute_claim(): void { $expectedResponse = $this->mockAcceptDisputesClaimResponse(); @@ -27,7 +26,7 @@ public function it_can_accept_dispute_claim(): void $this->assertEquals($expectedResponse, $mockClient->{$expectedMethod}('PP-D-27803', 'Full refund to the customer.')); } - #[Test] + /** @test */ public function it_can_accept_dispute_offer_resolution(): void { $expectedResponse = $this->mockAcceptDisputesOfferResolutionResponse(); @@ -42,7 +41,7 @@ public function it_can_accept_dispute_offer_resolution(): void $this->assertEquals($expectedResponse, $mockClient->{$expectedMethod}('PP-000-000-651-454', 'I am ok with the refund offered.')); } - #[Test] + /** @test */ public function it_can_acknowledge_item_is_returned_for_raised_dispute(): void { $expectedResponse = $this->mockAcknowledgeItemReturnedResponse(); diff --git a/tests/Unit/Adapter/DisputesTest.php b/tests/Unit/Adapter/DisputesTest.php index 76771c39..d4c41144 100644 --- a/tests/Unit/Adapter/DisputesTest.php +++ b/tests/Unit/Adapter/DisputesTest.php @@ -2,7 +2,6 @@ namespace Srmklive\PayPal\Tests\Unit\Adapter; -use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use Srmklive\PayPal\Tests\MockClientClasses; use Srmklive\PayPal\Tests\MockRequestPayloads; @@ -14,7 +13,7 @@ class DisputesTest extends TestCase use MockRequestPayloads; use MockResponsePayloads; - #[Test] + /** @test */ public function it_can_list_disputes(): void { $expectedResponse = $this->mockListDisputesResponse(); @@ -29,7 +28,7 @@ public function it_can_list_disputes(): void $this->assertEquals($expectedResponse, $mockClient->{$expectedMethod}()); } - #[Test] + /** @test */ public function it_can_partially_update_a_dispute(): void { $expectedResponse = ''; @@ -46,7 +45,7 @@ public function it_can_partially_update_a_dispute(): void $this->assertEquals($expectedResponse, $mockClient->{$expectedMethod}('PP-D-27803', $expectedParams)); } - #[Test] + /** @test */ public function it_can_get_details_for_a_dispute(): void { $expectedResponse = $this->mockGetDisputesResponse(); diff --git a/tests/Unit/Adapter/IdentityTest.php b/tests/Unit/Adapter/IdentityTest.php index 0314729b..762f13f3 100644 --- a/tests/Unit/Adapter/IdentityTest.php +++ b/tests/Unit/Adapter/IdentityTest.php @@ -2,7 +2,6 @@ namespace Srmklive\PayPal\Tests\Unit\Adapter; -use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use Srmklive\PayPal\Tests\MockClientClasses; use Srmklive\PayPal\Tests\MockRequestPayloads; @@ -14,7 +13,7 @@ class IdentityTest extends TestCase use MockRequestPayloads; use MockResponsePayloads; - #[Test] + /** @test */ public function it_can_get_user_profile_details(): void { $expectedResponse = $this->mockShowProfileInfoResponse(); @@ -28,4 +27,63 @@ public function it_can_get_user_profile_details(): void $this->assertEquals($expectedResponse, $mockClient->{$expectedMethod}()); } + + /** @test */ + public function it_can_create_merchant_applications() + { + $expectedResponse = $this->mockCreateMerchantApplicationResponse(); + + $expectedMethod = 'createMerchantApplication'; + + $mockClient = $this->mock_client($expectedResponse, $expectedMethod, true); + + $mockClient->setApiCredentials($this->getMockCredentials()); + $mockClient->getAccessToken(); + + $this->assertEquals($expectedResponse, $mockClient->{$expectedMethod}( + 'AGGREGATOR', + [ + 'https://example.com/callback', + 'https://example.com/callback2', + ], + [ + 'facilitator@example.com', + 'merchant@example.com', + ], + 'WDJJHEBZ4X2LY', + 'some-open-id' + )); + } + + /** @test */ + public function it_can_set_account_properties() + { + $expectedResponse = ''; + + $expectedParams = $this->mockSetAccountPropertiesParams(); + + $expectedMethod = 'setAccountProperties'; + + $mockClient = $this->mock_client($expectedResponse, $expectedMethod, true); + + $mockClient->setApiCredentials($this->getMockCredentials()); + $mockClient->getAccessToken(); + + $this->assertEquals($expectedResponse, $mockClient->{$expectedMethod}($expectedParams)); + } + + /** @test */ + public function it_can_disable_account_properties() + { + $expectedResponse = ''; + + $expectedMethod = 'disableAccountProperties'; + + $mockClient = $this->mock_client($expectedResponse, $expectedMethod, true); + + $mockClient->setApiCredentials($this->getMockCredentials()); + $mockClient->getAccessToken(); + + $this->assertEquals($expectedResponse, $mockClient->{$expectedMethod}()); + } } diff --git a/tests/Unit/Adapter/InvoicesSearchTest.php b/tests/Unit/Adapter/InvoicesSearchTest.php index c93efcdd..c2306954 100644 --- a/tests/Unit/Adapter/InvoicesSearchTest.php +++ b/tests/Unit/Adapter/InvoicesSearchTest.php @@ -2,7 +2,6 @@ namespace Srmklive\PayPal\Tests\Unit\Adapter; -use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use Srmklive\PayPal\Tests\MockClientClasses; use Srmklive\PayPal\Tests\MockRequestPayloads; @@ -14,7 +13,7 @@ class InvoicesSearchTest extends TestCase use MockRequestPayloads; use MockResponsePayloads; - #[Test] + /** @test */ public function it_can_search_invoices(): void { $expectedResponse = $this->mockSearchInvoicesResponse(); @@ -29,7 +28,7 @@ public function it_can_search_invoices(): void $this->assertEquals($expectedResponse, $mockClient->{$expectedMethod}(1, 1, true)); } - #[Test] + /** @test */ public function it_can_search_invoices_with_custom_filters(): void { $expectedResponse = $this->mockSearchInvoicesResponse(); diff --git a/tests/Unit/Adapter/InvoicesTemplatesTest.php b/tests/Unit/Adapter/InvoicesTemplatesTest.php index feaf2f16..d5536342 100644 --- a/tests/Unit/Adapter/InvoicesTemplatesTest.php +++ b/tests/Unit/Adapter/InvoicesTemplatesTest.php @@ -2,7 +2,6 @@ namespace Srmklive\PayPal\Tests\Unit\Adapter; -use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use Srmklive\PayPal\Tests\MockClientClasses; use Srmklive\PayPal\Tests\MockRequestPayloads; @@ -14,7 +13,7 @@ class InvoicesTemplatesTest extends TestCase use MockRequestPayloads; use MockResponsePayloads; - #[Test] + /** @test */ public function it_can_create_invoice_template(): void { $expectedResponse = $this->mockCreateInvoiceTemplateResponse(); @@ -31,7 +30,7 @@ public function it_can_create_invoice_template(): void $this->assertEquals($expectedResponse, $mockClient->{$expectedMethod}($expectedParams)); } - #[Test] + /** @test */ public function it_can_list_invoice_templates(): void { $expectedResponse = $this->mockListInvoiceTemplateResponse(); @@ -46,7 +45,7 @@ public function it_can_list_invoice_templates(): void $this->assertEquals($expectedResponse, $mockClient->{$expectedMethod}()); } - #[Test] + /** @test */ public function it_can_delete_an_invoice_template(): void { $expectedResponse = ''; @@ -61,7 +60,7 @@ public function it_can_delete_an_invoice_template(): void $this->assertEquals($expectedResponse, $mockClient->{$expectedMethod}('TEMP-19V05281TU309413B')); } - #[Test] + /** @test */ public function it_can_update_an_invoice_template(): void { $expectedResponse = $this->mockUpdateInvoiceTemplateResponse(); @@ -78,7 +77,7 @@ public function it_can_update_an_invoice_template(): void $this->assertEquals($expectedResponse, $mockClient->{$expectedMethod}('TEMP-19V05281TU309413B', $expectedParams)); } - #[Test] + /** @test */ public function it_can_get_details_for_an_invoice_template(): void { $expectedResponse = $this->mockGetInvoiceTemplateResponse(); diff --git a/tests/Unit/Adapter/InvoicesTest.php b/tests/Unit/Adapter/InvoicesTest.php index e2be7b45..9caf5142 100644 --- a/tests/Unit/Adapter/InvoicesTest.php +++ b/tests/Unit/Adapter/InvoicesTest.php @@ -2,7 +2,6 @@ namespace Srmklive\PayPal\Tests\Unit\Adapter; -use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use Srmklive\PayPal\Tests\MockClientClasses; use Srmklive\PayPal\Tests\MockRequestPayloads; @@ -14,7 +13,7 @@ class InvoicesTest extends TestCase use MockRequestPayloads; use MockResponsePayloads; - #[Test] + /** @test */ public function it_can_generate_unique_invoice_number(): void { $expectedResponse = $this->mockGenerateInvoiceNumberResponse(); @@ -29,7 +28,7 @@ public function it_can_generate_unique_invoice_number(): void $this->assertEquals($expectedResponse, $mockClient->{$expectedMethod}()); } - #[Test] + /** @test */ public function it_can_create_a_draft_invoice(): void { $expectedResponse = $this->mockCreateInvoicesResponse(); @@ -46,7 +45,7 @@ public function it_can_create_a_draft_invoice(): void $this->assertEquals($expectedResponse, $mockClient->{$expectedMethod}($expectedParams)); } - #[Test] + /** @test */ public function it_can_list_current_invoices(): void { $expectedResponse = $this->mockListInvoicesResponse(); @@ -61,7 +60,7 @@ public function it_can_list_current_invoices(): void $this->assertEquals($expectedResponse, $mockClient->{$expectedMethod}()); } - #[Test] + /** @test */ public function it_can_delete_an_invoice(): void { $expectedResponse = ''; @@ -76,7 +75,7 @@ public function it_can_delete_an_invoice(): void $this->assertEquals($expectedResponse, $mockClient->{$expectedMethod}('INV2-Z56S-5LLA-Q52L-CPZ5')); } - #[Test] + /** @test */ public function it_can_update_an_invoice(): void { $expectedResponse = $this->mockUpdateInvoicesResponse(); @@ -93,7 +92,7 @@ public function it_can_update_an_invoice(): void $this->assertEquals($expectedResponse, $mockClient->{$expectedMethod}('INV2-Z56S-5LLA-Q52L-CPZ5', $expectedParams)); } - #[Test] + /** @test */ public function it_can_show_details_for_an_invoice(): void { $expectedResponse = $this->mockGetInvoicesResponse(); @@ -108,7 +107,7 @@ public function it_can_show_details_for_an_invoice(): void $this->assertEquals($expectedResponse, $mockClient->{$expectedMethod}('INV2-Z56S-5LLA-Q52L-CPZ5')); } - #[Test] + /** @test */ public function it_can_cancel_an_invoice(): void { $expectedResponse = ''; @@ -135,7 +134,7 @@ public function it_can_cancel_an_invoice(): void )); } - #[Test] + /** @test */ public function it_can_generate_qr_code_for_invoice(): void { $expectedResponse = $this->mockGenerateInvoiceQRCodeResponse(); @@ -150,7 +149,7 @@ public function it_can_generate_qr_code_for_invoice(): void $this->assertEquals($expectedResponse, $mockClient->{$expectedMethod}('INV2-Z56S-5LLA-Q52L-CPZ5', 400, 400)); } - #[Test] + /** @test */ public function it_can_register_payment_for_invoice(): void { $expectedResponse = $this->mockInvoiceRegisterPaymentResponse(); @@ -165,7 +164,7 @@ public function it_can_register_payment_for_invoice(): void $this->assertEquals($expectedResponse, $mockClient->{$expectedMethod}('INV2-Z56S-5LLA-Q52L-CPZ5', '2018-05-01', 'BANK_TRANSFER', 10.00)); } - #[Test] + /** @test */ public function it_can_delete_payment_for_invoice(): void { $expectedResponse = ''; @@ -180,7 +179,7 @@ public function it_can_delete_payment_for_invoice(): void $this->assertEquals($expectedResponse, $mockClient->{$expectedMethod}('INV2-Z56S-5LLA-Q52L-CPZ5', 'EXTR-86F38350LX4353815')); } - #[Test] + /** @test */ public function it_can_refund_payment_for_invoice(): void { $expectedResponse = $this->mockInvoiceRefundPaymentResponse(); @@ -195,7 +194,7 @@ public function it_can_refund_payment_for_invoice(): void $this->assertEquals($expectedResponse, $mockClient->{$expectedMethod}('INV2-Z56S-5LLA-Q52L-CPZ5', '2018-05-01', 'BANK_TRANSFER', 5.00)); } - #[Test] + /** @test */ public function it_can_delete_refund_for_invoice(): void { $expectedResponse = ''; @@ -210,7 +209,7 @@ public function it_can_delete_refund_for_invoice(): void $this->assertEquals($expectedResponse, $mockClient->{$expectedMethod}('INV2-Z56S-5LLA-Q52L-CPZ5', 'EXTR-2LG703375E477444T')); } - #[Test] + /** @test */ public function it_can_send_an_invoice(): void { $expectedResponse = ''; @@ -235,7 +234,7 @@ public function it_can_send_an_invoice(): void )); } - #[Test] + /** @test */ public function it_can_send_reminder_for_an_invoice(): void { $expectedResponse = ''; diff --git a/tests/Unit/Adapter/OrdersTest.php b/tests/Unit/Adapter/OrdersTest.php index e1377e0a..87b8865c 100644 --- a/tests/Unit/Adapter/OrdersTest.php +++ b/tests/Unit/Adapter/OrdersTest.php @@ -2,7 +2,6 @@ namespace Srmklive\PayPal\Tests\Unit\Adapter; -use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use Srmklive\PayPal\Tests\MockClientClasses; use Srmklive\PayPal\Tests\MockRequestPayloads; @@ -14,7 +13,7 @@ class OrdersTest extends TestCase use MockRequestPayloads; use MockResponsePayloads; - #[Test] + /** @test */ public function it_can_create_an_order(): void { $expectedResponse = $this->mockCreateOrdersResponse(); @@ -31,7 +30,7 @@ public function it_can_create_an_order(): void $this->assertEquals($expectedResponse, $mockClient->{$expectedMethod}($expectedParams)); } - #[Test] + /** @test */ public function it_can_update_an_order(): void { $expectedResponse = ''; diff --git a/tests/Unit/Adapter/PartnerReferralsTest.php b/tests/Unit/Adapter/PartnerReferralsTest.php index 0ae469fc..beefb467 100644 --- a/tests/Unit/Adapter/PartnerReferralsTest.php +++ b/tests/Unit/Adapter/PartnerReferralsTest.php @@ -2,7 +2,6 @@ namespace Srmklive\PayPal\Tests\Unit\Adapter; -use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use Srmklive\PayPal\Tests\MockClientClasses; use Srmklive\PayPal\Tests\MockRequestPayloads; @@ -14,7 +13,7 @@ class PartnerReferralsTest extends TestCase use MockRequestPayloads; use MockResponsePayloads; - #[Test] + /** @test */ public function it_can_create_partner_referral(): void { $expectedResponse = $this->mockCreatePartnerReferralsResponse(); @@ -31,7 +30,7 @@ public function it_can_create_partner_referral(): void $this->assertEquals($expectedResponse, $mockClient->{$expectedMethod}($expectedParams)); } - #[Test] + /** @test */ public function it_can_get_referral_details(): void { $expectedResponse = $this->mockShowReferralDataResponse(); diff --git a/tests/Unit/Adapter/PaymentAuthorizationsTest.php b/tests/Unit/Adapter/PaymentAuthorizationsTest.php index 181b4f52..141cc189 100644 --- a/tests/Unit/Adapter/PaymentAuthorizationsTest.php +++ b/tests/Unit/Adapter/PaymentAuthorizationsTest.php @@ -2,7 +2,6 @@ namespace Srmklive\PayPal\Tests\Unit\Adapter; -use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use Srmklive\PayPal\Tests\MockClientClasses; use Srmklive\PayPal\Tests\MockResponsePayloads; @@ -12,7 +11,7 @@ class PaymentAuthorizationsTest extends TestCase use MockClientClasses; use MockResponsePayloads; - #[Test] + /** @test */ public function it_can_show_details_for_an_authorized_payment(): void { $expectedResponse = $this->mockGetAuthorizedPaymentDetailsResponse(); @@ -27,7 +26,7 @@ public function it_can_show_details_for_an_authorized_payment(): void $this->assertEquals($expectedResponse, $mockClient->{$expectedMethod}('0VF52814937998046')); } - #[Test] + /** @test */ public function it_can_capture_an_authorized_payment(): void { $expectedResponse = $this->mockCaptureAuthorizedPaymentResponse(); @@ -47,7 +46,7 @@ public function it_can_capture_an_authorized_payment(): void )); } - #[Test] + /** @test */ public function it_can_reauthorize_an_authorized_payment(): void { $expectedResponse = $this->mockReAuthorizeAuthorizedPaymentResponse(); @@ -62,7 +61,7 @@ public function it_can_reauthorize_an_authorized_payment(): void $this->assertEquals($expectedResponse, $mockClient->{$expectedMethod}('0VF52814937998046', 10.99)); } - #[Test] + /** @test */ public function it_can_void_an_authorized_payment(): void { $expectedResponse = ''; diff --git a/tests/Unit/Adapter/PaymentCapturesTest.php b/tests/Unit/Adapter/PaymentCapturesTest.php index 550c005b..b1ffca25 100644 --- a/tests/Unit/Adapter/PaymentCapturesTest.php +++ b/tests/Unit/Adapter/PaymentCapturesTest.php @@ -2,7 +2,6 @@ namespace Srmklive\PayPal\Tests\Unit\Adapter; -use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use Srmklive\PayPal\Tests\MockClientClasses; use Srmklive\PayPal\Tests\MockResponsePayloads; @@ -12,7 +11,7 @@ class PaymentCapturesTest extends TestCase use MockClientClasses; use MockResponsePayloads; - #[Test] + /** @test */ public function it_can_show_details_for_a_captured_payment(): void { $expectedResponse = $this->mockGetCapturedPaymentDetailsResponse(); @@ -27,7 +26,7 @@ public function it_can_show_details_for_a_captured_payment(): void $this->assertEquals($expectedResponse, $mockClient->{$expectedMethod}('2GG279541U471931P')); } - #[Test] + /** @test */ public function it_can_refund_a_captured_payment(): void { $expectedResponse = $this->mockRefundCapturedPaymentResponse(); diff --git a/tests/Unit/Adapter/PaymentExperienceWebProfilesTest.php b/tests/Unit/Adapter/PaymentExperienceWebProfilesTest.php index 3963ced2..d152f218 100644 --- a/tests/Unit/Adapter/PaymentExperienceWebProfilesTest.php +++ b/tests/Unit/Adapter/PaymentExperienceWebProfilesTest.php @@ -2,7 +2,6 @@ namespace Srmklive\PayPal\Tests\Unit\Adapter; -use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use Srmklive\PayPal\Tests\MockClientClasses; use Srmklive\PayPal\Tests\MockRequestPayloads; @@ -14,7 +13,7 @@ class PaymentExperienceWebProfilesTest extends TestCase use MockRequestPayloads; use MockResponsePayloads; - #[Test] + /** @test */ public function it_can_list_web_experience_profiles(): void { $expectedResponse = $this->mockListWebProfilesResponse(); @@ -29,7 +28,7 @@ public function it_can_list_web_experience_profiles(): void $this->assertEquals($expectedResponse, $mockClient->{$expectedMethod}()); } - #[Test] + /** @test */ public function it_can_create_web_experience_profile(): void { $expectedResponse = $this->mockWebProfileResponse(); @@ -48,7 +47,7 @@ public function it_can_create_web_experience_profile(): void $this->assertEquals($expectedResponse, $mockClient->{$expectedMethod}($expectedParams)); } - #[Test] + /** @test */ public function it_can_delete_web_experience_profile(): void { $expectedResponse = ''; @@ -65,7 +64,7 @@ public function it_can_delete_web_experience_profile(): void $this->assertEquals($expectedResponse, $mockClient->{$expectedMethod}($expectedParams)); } - #[Test] + /** @test */ public function it_can_partially_update_web_experience_profile(): void { $expectedResponse = ''; @@ -82,7 +81,7 @@ public function it_can_partially_update_web_experience_profile(): void $this->assertEquals($expectedResponse, $mockClient->{$expectedMethod}('XP-A88A-LYLW-8Y3X-E5ER', $expectedParams)); } - #[Test] + /** @test */ public function it_can_fully_update_web_experience_profile(): void { $expectedResponse = ''; @@ -99,7 +98,7 @@ public function it_can_fully_update_web_experience_profile(): void $this->assertEquals($expectedResponse, $mockClient->{$expectedMethod}('XP-A88A-LYLW-8Y3X-E5ER', $expectedParams)); } - #[Test] + /** @test */ public function it_can_get_web_experience_profile_details(): void { $expectedResponse = $this->mockWebProfileResponse(); diff --git a/tests/Unit/Adapter/PaymentRefundsTest.php b/tests/Unit/Adapter/PaymentRefundsTest.php index faa4b9c6..55a0bb62 100644 --- a/tests/Unit/Adapter/PaymentRefundsTest.php +++ b/tests/Unit/Adapter/PaymentRefundsTest.php @@ -2,7 +2,6 @@ namespace Srmklive\PayPal\Tests\Unit\Adapter; -use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use Srmklive\PayPal\Tests\MockClientClasses; use Srmklive\PayPal\Tests\MockResponsePayloads; @@ -12,7 +11,7 @@ class PaymentRefundsTest extends TestCase use MockClientClasses; use MockResponsePayloads; - #[Test] + /** @test */ public function it_can_show_details_for_a_refund(): void { $expectedResponse = $this->mockGetRefundDetailsResponse(); diff --git a/tests/Unit/Adapter/PayoutsTest.php b/tests/Unit/Adapter/PayoutsTest.php index 152e72d7..88dccaa0 100644 --- a/tests/Unit/Adapter/PayoutsTest.php +++ b/tests/Unit/Adapter/PayoutsTest.php @@ -2,7 +2,6 @@ namespace Srmklive\PayPal\Tests\Unit\Adapter; -use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use Srmklive\PayPal\Tests\MockClientClasses; use Srmklive\PayPal\Tests\MockRequestPayloads; @@ -14,7 +13,7 @@ class PayoutsTest extends TestCase use MockRequestPayloads; use MockResponsePayloads; - #[Test] + /** @test */ public function it_can_create_batch_payout(): void { $expectedResponse = $this->mockCreateBatchPayoutResponse(); @@ -31,7 +30,7 @@ public function it_can_create_batch_payout(): void $this->assertEquals($expectedResponse, $mockClient->{$expectedMethod}($expectedParams)); } - #[Test] + /** @test */ public function it_can_show_batch_payout_details(): void { $expectedResponse = $this->showBatchPayoutResponse(); @@ -48,7 +47,7 @@ public function it_can_show_batch_payout_details(): void $this->assertEquals($expectedResponse, $mockClient->{$expectedMethod}($expectedParams)); } - #[Test] + /** @test */ public function it_can_show_batch_payout_item_details(): void { $expectedResponse = $this->showBatchPayoutItemResponse(); @@ -65,7 +64,7 @@ public function it_can_show_batch_payout_item_details(): void $this->assertEquals($expectedResponse, $mockClient->{$expectedMethod}($expectedParams)); } - #[Test] + /** @test */ public function it_can_cancel_unclaimed_batch_payout_item(): void { $expectedResponse = $this->mockCancelUnclaimedBatchItemResponse(); diff --git a/tests/Unit/Adapter/ReferencedPayoutsTest.php b/tests/Unit/Adapter/ReferencedPayoutsTest.php index c10d7bd9..1f97d58e 100644 --- a/tests/Unit/Adapter/ReferencedPayoutsTest.php +++ b/tests/Unit/Adapter/ReferencedPayoutsTest.php @@ -2,7 +2,6 @@ namespace Srmklive\PayPal\Tests\Unit\Adapter; -use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use Srmklive\PayPal\Tests\MockClientClasses; use Srmklive\PayPal\Tests\MockRequestPayloads; @@ -14,7 +13,7 @@ class ReferencedPayoutsTest extends TestCase use MockRequestPayloads; use MockResponsePayloads; - #[Test] + /** @test */ public function it_can_create_referenced_batch_payout(): void { $expectedResponse = $this->mockCreateReferencedBatchPayoutResponse(); @@ -36,7 +35,7 @@ public function it_can_create_referenced_batch_payout(): void $this->assertEquals($expectedResponse, $mockClient->{$expectedMethod}($expectedParams)); } - #[Test] + /** @test */ public function it_can_list_items_referenced_in_batch_payout(): void { $expectedResponse = $this->mockShowReferencedBatchPayoutResponse(); @@ -53,7 +52,7 @@ public function it_can_list_items_referenced_in_batch_payout(): void $this->assertEquals($expectedResponse, $mockClient->{$expectedMethod}($expectedParams)); } - #[Test] + /** @test */ public function it_can_create_referenced_batch_payout_item(): void { $expectedResponse = $this->mockCreateReferencedBatchPayoutItemResponse(); @@ -75,7 +74,7 @@ public function it_can_create_referenced_batch_payout_item(): void $this->assertEquals($expectedResponse, $mockClient->{$expectedMethod}($expectedParams)); } - #[Test] + /** @test */ public function it_can_show_referenced_payout_item_details(): void { $expectedResponse = $this->mockShowReferencedBatchPayoutItemResponse(); diff --git a/tests/Unit/Adapter/ReportingTest.php b/tests/Unit/Adapter/ReportingTest.php index 7f307057..125fc883 100644 --- a/tests/Unit/Adapter/ReportingTest.php +++ b/tests/Unit/Adapter/ReportingTest.php @@ -3,7 +3,6 @@ namespace Srmklive\PayPal\Tests\Unit\Adapter; use Carbon\Carbon; -use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use Srmklive\PayPal\Tests\MockClientClasses; use Srmklive\PayPal\Tests\MockResponsePayloads; @@ -13,7 +12,7 @@ class ReportingTest extends TestCase use MockClientClasses; use MockResponsePayloads; - #[Test] + /** @test */ public function it_can_list_transactions(): void { $expectedResponse = $this->mockListTransactionsResponse(); @@ -33,7 +32,7 @@ public function it_can_list_transactions(): void $this->assertEquals($expectedResponse, $mockClient->{$expectedMethod}($filters)); } - #[Test] + /** @test */ public function it_can_list_balances(): void { $expectedResponse = $this->mockListBalancesResponse(); diff --git a/tests/Unit/Adapter/SubscriptionsTest.php b/tests/Unit/Adapter/SubscriptionsTest.php index cd1f75d5..c4866b01 100644 --- a/tests/Unit/Adapter/SubscriptionsTest.php +++ b/tests/Unit/Adapter/SubscriptionsTest.php @@ -2,7 +2,6 @@ namespace Srmklive\PayPal\Tests\Unit\Adapter; -use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use Srmklive\PayPal\Tests\MockClientClasses; use Srmklive\PayPal\Tests\MockRequestPayloads; @@ -14,7 +13,7 @@ class SubscriptionsTest extends TestCase use MockRequestPayloads; use MockResponsePayloads; - #[Test] + /** @test */ public function it_can_create_a_subscription(): void { $expectedResponse = $this->mockCreateSubscriptionResponse(); @@ -31,7 +30,7 @@ public function it_can_create_a_subscription(): void $this->assertEquals($expectedResponse, $mockClient->{$expectedMethod}($expectedParams)); } - #[Test] + /** @test */ public function it_can_update_a_subscription(): void { $expectedResponse = ''; @@ -48,7 +47,7 @@ public function it_can_update_a_subscription(): void $this->assertEquals($expectedResponse, $mockClient->{$expectedMethod}('I-BW452GLLEP1G', $expectedParams)); } - #[Test] + /** @test */ public function it_can_show_details_for_a_subscription(): void { $expectedResponse = $this->mockGetSubscriptionDetailsResponse(); @@ -63,7 +62,7 @@ public function it_can_show_details_for_a_subscription(): void $this->assertEquals($expectedResponse, $mockClient->{$expectedMethod}('I-BW452GLLEP1G')); } - #[Test] + /** @test */ public function it_can_activate_a_subscription(): void { $expectedResponse = ''; @@ -78,7 +77,7 @@ public function it_can_activate_a_subscription(): void $this->assertEquals($expectedResponse, $mockClient->{$expectedMethod}('I-BW452GLLEP1G', 'Reactivating the subscription')); } - #[Test] + /** @test */ public function it_can_cancel_a_subscription(): void { $expectedResponse = ''; @@ -93,7 +92,7 @@ public function it_can_cancel_a_subscription(): void $this->assertEquals($expectedResponse, $mockClient->{$expectedMethod}('I-BW452GLLEP1G', 'Not satisfied with the service')); } - #[Test] + /** @test */ public function it_can_suspend_a_subscription(): void { $expectedResponse = ''; @@ -108,7 +107,7 @@ public function it_can_suspend_a_subscription(): void $this->assertEquals($expectedResponse, $mockClient->{$expectedMethod}('I-BW452GLLEP1G', 'Item out of stock')); } - #[Test] + /** @test */ public function it_can_capture_payment_for_a_subscription(): void { $expectedResponse = ''; @@ -123,7 +122,7 @@ public function it_can_capture_payment_for_a_subscription(): void $this->assertEquals($expectedResponse, $mockClient->{$expectedMethod}('I-BW452GLLEP1G', 'Charging as the balance reached the limit', 100)); } - #[Test] + /** @test */ public function it_can_update_quantity_or_product_for_a_subscription(): void { $expectedResponse = $this->mockUpdateSubscriptionItemsResponse(); @@ -140,7 +139,7 @@ public function it_can_update_quantity_or_product_for_a_subscription(): void $this->assertEquals($expectedResponse, $mockClient->{$expectedMethod}('I-BW452GLLEP1G', $expectedParams)); } - #[Test] + /** @test */ public function it_can_list_transactions_for_a_subscription(): void { $expectedResponse = $this->mockListSubscriptionTransactionsResponse(); diff --git a/tests/Unit/Adapter/TrackersTest.php b/tests/Unit/Adapter/TrackersTest.php index 4cc6ff76..ad2522df 100644 --- a/tests/Unit/Adapter/TrackersTest.php +++ b/tests/Unit/Adapter/TrackersTest.php @@ -2,7 +2,6 @@ namespace Srmklive\PayPal\Tests\Unit\Adapter; -use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use Srmklive\PayPal\Tests\MockClientClasses; use Srmklive\PayPal\Tests\MockRequestPayloads; @@ -14,7 +13,7 @@ class TrackersTest extends TestCase use MockRequestPayloads; use MockResponsePayloads; - #[Test] + /** @test */ public function it_can_get_tracking_details_for_tracking_id(): void { $expectedResponse = $this->mockGetTrackingDetailsResponse(); @@ -31,7 +30,7 @@ public function it_can_get_tracking_details_for_tracking_id(): void $this->assertEquals($expectedResponse, $mockClient->{$expectedMethod}($expectedParams)); } - #[Test] + /** @test */ public function it_can_update_tracking_details_for_tracking_id(): void { $expectedResponse = ''; @@ -50,7 +49,7 @@ public function it_can_update_tracking_details_for_tracking_id(): void $this->assertEquals($expectedResponse, $mockClient->{$expectedMethod}($expectedParams, $expectedData)); } - #[Test] + /** @test */ public function it_can_create_tracking_in_batches(): void { $expectedResponse = $this->mockCreateTrackinginBatchesResponse(); diff --git a/tests/Unit/Adapter/WebHooksEventsTest.php b/tests/Unit/Adapter/WebHooksEventsTest.php index 6490e5c6..4504dcba 100644 --- a/tests/Unit/Adapter/WebHooksEventsTest.php +++ b/tests/Unit/Adapter/WebHooksEventsTest.php @@ -2,7 +2,6 @@ namespace Srmklive\PayPal\Tests\Unit\Adapter; -use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use Srmklive\PayPal\Tests\MockClientClasses; use Srmklive\PayPal\Tests\MockResponsePayloads; @@ -12,7 +11,7 @@ class WebHooksEventsTest extends TestCase use MockClientClasses; use MockResponsePayloads; - #[Test] + /** @test */ public function it_can_list_web_hooks_event_types(): void { $expectedResponse = $this->mockListWebHookEventsTypesResponse(); @@ -27,7 +26,7 @@ public function it_can_list_web_hooks_event_types(): void $this->assertEquals($expectedResponse, $mockClient->{$expectedMethod}()); } - #[Test] + /** @test */ public function it_can_list_web_hooks_events(): void { $expectedResponse = $this->mockWebHookEventsListResponse(); @@ -42,7 +41,7 @@ public function it_can_list_web_hooks_events(): void $this->assertEquals($expectedResponse, $mockClient->{$expectedMethod}()); } - #[Test] + /** @test */ public function it_can_show_details_for_a_web_hooks_event(): void { $expectedResponse = $this->mockGetWebHookEventResponse(); @@ -57,7 +56,7 @@ public function it_can_show_details_for_a_web_hooks_event(): void $this->assertEquals($expectedResponse, $mockClient->{$expectedMethod}('8PT597110X687430LKGECATA')); } - #[Test] + /** @test */ public function it_can_resend_notification_for_a_web_hooks_event(): void { $expectedResponse = $this->mockResendWebHookEventNotificationResponse(); diff --git a/tests/Unit/Adapter/WebHooksTest.php b/tests/Unit/Adapter/WebHooksTest.php index 36b9535f..4bb41bf9 100644 --- a/tests/Unit/Adapter/WebHooksTest.php +++ b/tests/Unit/Adapter/WebHooksTest.php @@ -2,7 +2,6 @@ namespace Srmklive\PayPal\Tests\Unit\Adapter; -use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use Srmklive\PayPal\Tests\MockClientClasses; use Srmklive\PayPal\Tests\MockRequestPayloads; @@ -14,7 +13,7 @@ class WebHooksTest extends TestCase use MockRequestPayloads; use MockResponsePayloads; - #[Test] + /** @test */ public function it_can_create_a_web_hook(): void { $expectedResponse = $this->mockCreateWebHookResponse(); @@ -32,7 +31,7 @@ public function it_can_create_a_web_hook(): void )); } - #[Test] + /** @test */ public function it_can_list_web_hooks(): void { $expectedResponse = $this->mockListWebHookResponse(); @@ -47,7 +46,7 @@ public function it_can_list_web_hooks(): void $this->assertEquals($expectedResponse, $mockClient->{$expectedMethod}()); } - #[Test] + /** @test */ public function it_can_delete_a_web_hook(): void { $expectedResponse = ''; @@ -62,7 +61,7 @@ public function it_can_delete_a_web_hook(): void $this->assertEquals($expectedResponse, $mockClient->{$expectedMethod}('5GP028458E2496506')); } - #[Test] + /** @test */ public function it_can_update_a_web_hook(): void { $expectedResponse = $this->mockUpdateWebHookResponse(); @@ -79,7 +78,7 @@ public function it_can_update_a_web_hook(): void $this->assertEquals($expectedResponse, $mockClient->{$expectedMethod}('0EH40505U7160970P', $expectedParams)); } - #[Test] + /** @test */ public function it_can_show_details_for_a_web_hook(): void { $expectedResponse = $this->mockGetWebHookResponse(); @@ -94,7 +93,7 @@ public function it_can_show_details_for_a_web_hook(): void $this->assertEquals($expectedResponse, $mockClient->{$expectedMethod}('0EH40505U7160970P')); } - #[Test] + /** @test */ public function it_can_list_web_hooks_events(): void { $expectedResponse = $this->mockListWebHookEventsResponse(); diff --git a/tests/Unit/Adapter/WebHooksVerificationTest.php b/tests/Unit/Adapter/WebHooksVerificationTest.php index ac9132f1..43d4ff5a 100644 --- a/tests/Unit/Adapter/WebHooksVerificationTest.php +++ b/tests/Unit/Adapter/WebHooksVerificationTest.php @@ -2,7 +2,6 @@ namespace Srmklive\PayPal\Tests\Unit\Adapter; -use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use Srmklive\PayPal\Tests\MockClientClasses; use Srmklive\PayPal\Tests\MockRequestPayloads; @@ -14,7 +13,7 @@ class WebHooksVerificationTest extends TestCase use MockRequestPayloads; use MockResponsePayloads; - #[Test] + /** @test */ public function it_can_verify_web_hook_signature(): void { $expectedResponse = $this->mockVerifyWebHookSignatureResponse(); diff --git a/tests/Unit/AdapterTest.php b/tests/Unit/AdapterTest.php index dbda6e5a..09ebf95c 100644 --- a/tests/Unit/AdapterTest.php +++ b/tests/Unit/AdapterTest.php @@ -2,7 +2,6 @@ namespace Srmklive\PayPal\Tests\Unit; -use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use Srmklive\PayPal\Services\PayPal as PayPalClient; use Srmklive\PayPal\Tests\MockClientClasses; @@ -13,7 +12,7 @@ class AdapterTest extends TestCase use MockClientClasses; use MockResponsePayloads; - #[Test] + /** @test */ public function it_can_be_instantiated(): void { $client = new PayPalClient($this->getMockCredentials()); @@ -21,7 +20,7 @@ public function it_can_be_instantiated(): void $this->assertInstanceOf(PayPalClient::class, $client); } - #[Test] + /** @test */ public function it_throws_exception_if_invalid_credentials_are_provided(): void { $this->expectException(\RuntimeException::class); @@ -29,11 +28,11 @@ public function it_throws_exception_if_invalid_credentials_are_provided(): void $client = new PayPalClient(); } - #[Test] + /** @test */ public function it_throws_exception_if_invalid_mode_is_provided(): void { $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'] = ''; @@ -41,11 +40,11 @@ public function it_throws_exception_if_invalid_mode_is_provided(): void $client = new PayPalClient($credentials); } - #[Test] + /** @test */ public function it_throws_exception_if_empty_credentials_are_provided(): void { $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['sandbox'] = []; @@ -53,13 +52,13 @@ public function it_throws_exception_if_empty_credentials_are_provided(): void $client = new PayPalClient($credentials); } - #[Test] + /** @test */ public function it_throws_exception_if_credentials_items_are_not_provided(): void { $item = 'client_id'; $this->expectException(\RuntimeException::class); - // $this->expectErrorMessage("{$item} missing from the provided configuration. Please add your application {$item}."); + $this->expectExceptionMessage("{$item} missing from the provided configuration. Please add your application {$item}."); $credentials = $this->getMockCredentials(); $credentials['sandbox'][$item] = ''; @@ -67,7 +66,7 @@ public function it_throws_exception_if_credentials_items_are_not_provided(): voi $client = new PayPalClient($credentials); } - #[Test] + /** @test */ public function it_can_get_access_token(): void { $expectedResponse = $this->mockAccessTokenResponse(); diff --git a/tests/Unit/Client/BillingPlansTest.php b/tests/Unit/Client/BillingPlansTest.php index af10d1c6..f5d02e23 100644 --- a/tests/Unit/Client/BillingPlansTest.php +++ b/tests/Unit/Client/BillingPlansTest.php @@ -2,8 +2,6 @@ namespace Srmklive\PayPal\Tests\Unit\Client; -use GuzzleHttp\Utils; -use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use Srmklive\PayPal\Tests\MockClientClasses; use Srmklive\PayPal\Tests\MockRequestPayloads; @@ -15,7 +13,7 @@ class BillingPlansTest extends TestCase use MockRequestPayloads; use MockResponsePayloads; - #[Test] + /** @test */ public function it_can_create_a_billing_plan(): void { $expectedResponse = $this->mockCreatePlansResponse(); @@ -30,12 +28,12 @@ public function it_can_create_a_billing_plan(): void '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, Utils::jsonDecode($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); } - #[Test] + /** @test */ public function it_can_list_billing_plans(): void { $expectedResponse = $this->mockListPlansResponse(); @@ -49,12 +47,12 @@ public function it_can_list_billing_plans(): void ], ]; - $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, Utils::jsonDecode($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); } - #[Test] + /** @test */ public function it_can_update_a_billing_plan(): void { $expectedResponse = ''; @@ -69,12 +67,12 @@ public function it_can_update_a_billing_plan(): void '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, Utils::jsonDecode($mockHttpClient->patch($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->patch($expectedEndpoint, $expectedParams)->getBody(), true)); } - #[Test] + /** @test */ public function it_can_show_details_for_a_billing_plan(): void { $expectedResponse = $this->mockGetPlansResponse(); @@ -88,12 +86,12 @@ public function it_can_show_details_for_a_billing_plan(): void ], ]; - $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, Utils::jsonDecode($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); } - #[Test] + /** @test */ public function it_can_activate_a_billing_plan(): void { $expectedResponse = ''; @@ -107,12 +105,12 @@ public function it_can_activate_a_billing_plan(): void ], ]; - $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, Utils::jsonDecode($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); } - #[Test] + /** @test */ public function it_can_deactivate_a_billing_plan(): void { $expectedResponse = ''; @@ -126,12 +124,12 @@ public function it_can_deactivate_a_billing_plan(): void ], ]; - $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, Utils::jsonDecode($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); } - #[Test] + /** @test */ public function it_can_update_pricing_for_a_billing_plan(): void { $expectedResponse = ''; @@ -146,8 +144,8 @@ public function it_can_update_pricing_for_a_billing_plan(): void '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, 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 c1695847..6dc756b5 100644 --- a/tests/Unit/Client/CatalogProductsTest.php +++ b/tests/Unit/Client/CatalogProductsTest.php @@ -2,8 +2,6 @@ namespace Srmklive\PayPal\Tests\Unit\Client; -use GuzzleHttp\Utils; -use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use Srmklive\PayPal\Tests\MockClientClasses; use Srmklive\PayPal\Tests\MockRequestPayloads; @@ -15,7 +13,7 @@ class CatalogProductsTest extends TestCase use MockRequestPayloads; use MockResponsePayloads; - #[Test] + /** @test */ public function it_can_create_a_product(): void { $expectedResponse = $this->mockCreateCatalogProductsResponse(); @@ -30,12 +28,12 @@ public function it_can_create_a_product(): void '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, Utils::jsonDecode($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); } - #[Test] + /** @test */ public function it_can_list_products(): void { $expectedResponse = $this->mockListCatalogProductsResponse(); @@ -49,12 +47,12 @@ public function it_can_list_products(): void ], ]; - $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, Utils::jsonDecode($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); } - #[Test] + /** @test */ public function it_can_update_a_product(): void { $expectedResponse = ''; @@ -69,12 +67,12 @@ public function it_can_update_a_product(): void '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, Utils::jsonDecode($mockHttpClient->patch($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->patch($expectedEndpoint, $expectedParams)->getBody(), true)); } - #[Test] + /** @test */ public function it_can_get_details_for_a_product(): void { $expectedResponse = $this->mockGetCatalogProductsResponse(); @@ -88,8 +86,8 @@ public function it_can_get_details_for_a_product(): void ], ]; - $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, 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 a14454fb..53c18436 100644 --- a/tests/Unit/Client/DisputeActionsTest.php +++ b/tests/Unit/Client/DisputeActionsTest.php @@ -2,8 +2,6 @@ namespace Srmklive\PayPal\Tests\Unit\Client; -use GuzzleHttp\Utils; -use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use Srmklive\PayPal\Tests\MockClientClasses; use Srmklive\PayPal\Tests\MockRequestPayloads; @@ -15,7 +13,7 @@ class DisputeActionsTest extends TestCase use MockRequestPayloads; use MockResponsePayloads; - #[Test] + /** @test */ public function it_can_accept_dispute_claim(): void { $expectedResponse = $this->mockAcceptDisputesClaimResponse(); @@ -30,12 +28,12 @@ public function it_can_accept_dispute_claim(): void '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, Utils::jsonDecode($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); } - #[Test] + /** @test */ public function it_can_accept_dispute_offer_resolution(): void { $expectedResponse = $this->mockAcceptDisputesOfferResolutionResponse(); @@ -50,12 +48,12 @@ public function it_can_accept_dispute_offer_resolution(): void '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, Utils::jsonDecode($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); } - #[Test] + /** @test */ public function it_can_acknowledge_item_is_returned_for_raised_dispute(): void { $expectedResponse = $this->mockAcknowledgeItemReturnedResponse(); @@ -70,8 +68,8 @@ public function it_can_acknowledge_item_is_returned_for_raised_dispute(): void '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, 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 46b7d1cf..e88027cc 100644 --- a/tests/Unit/Client/DisputesTest.php +++ b/tests/Unit/Client/DisputesTest.php @@ -2,8 +2,6 @@ namespace Srmklive\PayPal\Tests\Unit\Client; -use GuzzleHttp\Utils; -use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use Srmklive\PayPal\Tests\MockClientClasses; use Srmklive\PayPal\Tests\MockRequestPayloads; @@ -15,7 +13,7 @@ class DisputesTest extends TestCase use MockRequestPayloads; use MockResponsePayloads; - #[Test] + /** @test */ public function it_can_list_disputes(): void { $expectedResponse = $this->mockListDisputesResponse(); @@ -29,12 +27,12 @@ public function it_can_list_disputes(): void ], ]; - $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, Utils::jsonDecode($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); } - #[Test] + /** @test */ public function it_can_partially_update_a_dispute(): void { $expectedResponse = ''; @@ -49,12 +47,12 @@ public function it_can_partially_update_a_dispute(): void '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, Utils::jsonDecode($mockHttpClient->patch($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->patch($expectedEndpoint, $expectedParams)->getBody(), true)); } - #[Test] + /** @test */ public function it_can_get_details_for_a_dispute(): void { $expectedResponse = $this->mockGetDisputesResponse(); @@ -68,8 +66,8 @@ public function it_can_get_details_for_a_dispute(): void ], ]; - $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, 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 805f70cd..d613a174 100644 --- a/tests/Unit/Client/IdentityTest.php +++ b/tests/Unit/Client/IdentityTest.php @@ -2,8 +2,6 @@ namespace Srmklive\PayPal\Tests\Unit\Client; -use GuzzleHttp\Utils; -use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use Srmklive\PayPal\Tests\MockClientClasses; use Srmklive\PayPal\Tests\MockRequestPayloads; @@ -15,7 +13,7 @@ class IdentityTest extends TestCase use MockRequestPayloads; use MockResponsePayloads; - #[Test] + /** @test */ public function it_can_user_profile_details(): void { $expectedResponse = $this->mockShowProfileInfoResponse(); @@ -29,8 +27,8 @@ public function it_can_user_profile_details(): void ], ]; - $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, 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 2097404c..fcf32793 100644 --- a/tests/Unit/Client/InvoicesSearchTest.php +++ b/tests/Unit/Client/InvoicesSearchTest.php @@ -2,8 +2,6 @@ namespace Srmklive\PayPal\Tests\Unit\Client; -use GuzzleHttp\Utils; -use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use Srmklive\PayPal\Tests\MockClientClasses; use Srmklive\PayPal\Tests\MockRequestPayloads; @@ -15,7 +13,7 @@ class InvoicesSearchTest extends TestCase use MockRequestPayloads; use MockResponsePayloads; - #[Test] + /** @test */ public function it_can_search_invoices(): void { $expectedResponse = $this->mockSearchInvoicesResponse(); @@ -30,8 +28,8 @@ public function it_can_search_invoices(): void '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, 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 144bcd95..c7461a56 100644 --- a/tests/Unit/Client/InvoicesTemplatesTest.php +++ b/tests/Unit/Client/InvoicesTemplatesTest.php @@ -2,8 +2,6 @@ namespace Srmklive\PayPal\Tests\Unit\Client; -use GuzzleHttp\Utils; -use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use Srmklive\PayPal\Tests\MockClientClasses; use Srmklive\PayPal\Tests\MockRequestPayloads; @@ -15,7 +13,7 @@ class InvoicesTemplatesTest extends TestCase use MockRequestPayloads; use MockResponsePayloads; - #[Test] + /** @test */ public function it_can_create_invoice_template(): void { $expectedResponse = $this->mockCreateInvoiceTemplateResponse(); @@ -30,12 +28,12 @@ public function it_can_create_invoice_template(): void '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, Utils::jsonDecode($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); } - #[Test] + /** @test */ public function it_can_list_invoice_templates(): void { $expectedResponse = $this->mockListInvoiceTemplateResponse(); @@ -49,12 +47,12 @@ public function it_can_list_invoice_templates(): void ], ]; - $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, Utils::jsonDecode($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); } - #[Test] + /** @test */ public function it_can_delete_an_invoice_template(): void { $expectedResponse = ''; @@ -68,12 +66,12 @@ public function it_can_delete_an_invoice_template(): void ], ]; - $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, Utils::jsonDecode($mockHttpClient->delete($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->delete($expectedEndpoint, $expectedParams)->getBody(), true)); } - #[Test] + /** @test */ public function it_can_update_an_invoice_template(): void { $expectedResponse = $this->mockUpdateInvoiceTemplateResponse(); @@ -88,12 +86,12 @@ public function it_can_update_an_invoice_template(): void '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, Utils::jsonDecode($mockHttpClient->put($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->put($expectedEndpoint, $expectedParams)->getBody(), true)); } - #[Test] + /** @test */ public function it_can_get_details_for_an_invoice_template(): void { $expectedResponse = $this->mockGetInvoiceTemplateResponse(); @@ -107,8 +105,8 @@ public function it_can_get_details_for_an_invoice_template(): void ], ]; - $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, 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 9ff17edc..9ea02f76 100644 --- a/tests/Unit/Client/InvoicesTest.php +++ b/tests/Unit/Client/InvoicesTest.php @@ -2,8 +2,6 @@ namespace Srmklive\PayPal\Tests\Unit\Client; -use GuzzleHttp\Utils; -use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use Srmklive\PayPal\Tests\MockClientClasses; use Srmklive\PayPal\Tests\MockRequestPayloads; @@ -15,7 +13,7 @@ class InvoicesTest extends TestCase use MockRequestPayloads; use MockResponsePayloads; - #[Test] + /** @test */ public function it_can_generate_unique_invoice_number(): void { $expectedResponse = $this->mockGenerateInvoiceNumberResponse(); @@ -29,12 +27,12 @@ public function it_can_generate_unique_invoice_number(): void ], ]; - $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, Utils::jsonDecode($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); } - #[Test] + /** @test */ public function it_can_create_a_draft_invoice(): void { $expectedResponse = $this->mockCreateInvoicesResponse(); @@ -49,12 +47,12 @@ public function it_can_create_a_draft_invoice(): void '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, Utils::jsonDecode($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); } - #[Test] + /** @test */ public function it_can_list_current_invoices(): void { $expectedResponse = $this->mockListInvoicesResponse(); @@ -68,12 +66,12 @@ public function it_can_list_current_invoices(): void ], ]; - $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, Utils::jsonDecode($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); } - #[Test] + /** @test */ public function it_can_delete_an_invoice(): void { $expectedResponse = ''; @@ -87,12 +85,12 @@ public function it_can_delete_an_invoice(): void ], ]; - $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, Utils::jsonDecode($mockHttpClient->delete($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->delete($expectedEndpoint, $expectedParams)->getBody(), true)); } - #[Test] + /** @test */ public function it_can_update_an_invoice(): void { $expectedResponse = $this->mockUpdateInvoicesResponse(); @@ -107,12 +105,12 @@ public function it_can_update_an_invoice(): void '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, Utils::jsonDecode($mockHttpClient->put($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->put($expectedEndpoint, $expectedParams)->getBody(), true)); } - #[Test] + /** @test */ public function it_can_show_details_for_an_invoice(): void { $expectedResponse = $this->mockGetInvoicesResponse(); @@ -126,12 +124,12 @@ public function it_can_show_details_for_an_invoice(): void ], ]; - $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, Utils::jsonDecode($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); } - #[Test] + /** @test */ public function it_can_cancel_an_invoice(): void { $expectedResponse = ''; @@ -146,12 +144,12 @@ public function it_can_cancel_an_invoice(): void '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, Utils::jsonDecode($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); } - #[Test] + /** @test */ public function it_can_generate_qr_code_for_invoice(): void { $expectedResponse = $this->mockGenerateInvoiceNumberResponse(); @@ -166,12 +164,12 @@ public function it_can_generate_qr_code_for_invoice(): void '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, Utils::jsonDecode($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); } - #[Test] + /** @test */ public function it_can_register_payment_for_invoice(): void { $expectedResponse = $this->mockInvoiceRegisterPaymentResponse(); @@ -186,12 +184,12 @@ public function it_can_register_payment_for_invoice(): void '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, Utils::jsonDecode($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); } - #[Test] + /** @test */ public function it_can_delete_payment_for_invoice(): void { $expectedResponse = ''; @@ -205,12 +203,12 @@ public function it_can_delete_payment_for_invoice(): void ], ]; - $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, Utils::jsonDecode($mockHttpClient->delete($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->delete($expectedEndpoint, $expectedParams)->getBody(), true)); } - #[Test] + /** @test */ public function it_can_refund_payment_for_invoice(): void { $expectedResponse = $this->mockInvoiceRefundPaymentResponse(); @@ -225,12 +223,12 @@ public function it_can_refund_payment_for_invoice(): void '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, Utils::jsonDecode($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); } - #[Test] + /** @test */ public function it_can_delete_refund_for_invoice(): void { $expectedResponse = ''; @@ -244,12 +242,12 @@ public function it_can_delete_refund_for_invoice(): void ], ]; - $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, Utils::jsonDecode($mockHttpClient->delete($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->delete($expectedEndpoint, $expectedParams)->getBody(), true)); } - #[Test] + /** @test */ public function it_can_send_an_invoice(): void { $expectedResponse = ''; @@ -264,12 +262,12 @@ public function it_can_send_an_invoice(): void '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, Utils::jsonDecode($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); } - #[Test] + /** @test */ public function it_can_send_reminder_for_an_invoice(): void { $expectedResponse = ''; @@ -284,8 +282,8 @@ public function it_can_send_reminder_for_an_invoice(): void '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, 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 b8ff33b8..85ef6c54 100644 --- a/tests/Unit/Client/OrdersTest.php +++ b/tests/Unit/Client/OrdersTest.php @@ -2,8 +2,6 @@ namespace Srmklive\PayPal\Tests\Unit\Client; -use GuzzleHttp\Utils; -use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use Srmklive\PayPal\Tests\MockClientClasses; use Srmklive\PayPal\Tests\MockRequestPayloads; @@ -15,7 +13,7 @@ class OrdersTest extends TestCase use MockRequestPayloads; use MockResponsePayloads; - #[Test] + /** @test */ public function it_can_create_an_order(): void { $expectedResponse = $this->mockCreateOrdersResponse(); @@ -30,8 +28,8 @@ public function it_can_create_an_order(): void '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, 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 6e961a0a..4c2d05f8 100644 --- a/tests/Unit/Client/PartnerReferralsTest.php +++ b/tests/Unit/Client/PartnerReferralsTest.php @@ -2,8 +2,6 @@ namespace Srmklive\PayPal\Tests\Unit\Client; -use GuzzleHttp\Utils; -use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use Srmklive\PayPal\Tests\MockClientClasses; use Srmklive\PayPal\Tests\MockRequestPayloads; @@ -15,7 +13,7 @@ class PartnerReferralsTest extends TestCase use MockRequestPayloads; use MockResponsePayloads; - #[Test] + /** @test */ public function it_can_create_partner_referral(): void { $expectedResponse = $this->mockCreatePartnerReferralsResponse(); @@ -30,12 +28,12 @@ public function it_can_create_partner_referral(): void '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, Utils::jsonDecode($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); } - #[Test] + /** @test */ public function it_can_get_referral_details(): void { $expectedResponse = $this->mockShowReferralDataResponse(); @@ -49,8 +47,8 @@ public function it_can_get_referral_details(): void ], ]; - $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, 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 a151ed9b..c03ab32e 100644 --- a/tests/Unit/Client/PaymentAuthorizationsTest.php +++ b/tests/Unit/Client/PaymentAuthorizationsTest.php @@ -2,8 +2,6 @@ namespace Srmklive\PayPal\Tests\Unit\Client; -use GuzzleHttp\Utils; -use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use Srmklive\PayPal\Tests\MockClientClasses; use Srmklive\PayPal\Tests\MockRequestPayloads; @@ -15,7 +13,7 @@ class PaymentAuthorizationsTest extends TestCase use MockRequestPayloads; use MockResponsePayloads; - #[Test] + /** @test */ public function it_can_show_details_for_an_authorized_payment(): void { $expectedResponse = $this->mockGetAuthorizedPaymentDetailsResponse(); @@ -29,12 +27,12 @@ public function it_can_show_details_for_an_authorized_payment(): void ], ]; - $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, Utils::jsonDecode($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); } - #[Test] + /** @test */ public function it_can_capture_an_authorized_payment(): void { $expectedResponse = $this->mockCaptureAuthorizedPaymentResponse(); @@ -49,12 +47,12 @@ public function it_can_capture_an_authorized_payment(): void '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, Utils::jsonDecode($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); } - #[Test] + /** @test */ public function it_can_reauthorize_an_authorized_payment(): void { $expectedResponse = $this->mockReAuthorizeAuthorizedPaymentResponse(); @@ -69,12 +67,12 @@ public function it_can_reauthorize_an_authorized_payment(): void '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, Utils::jsonDecode($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); } - #[Test] + /** @test */ public function it_can_void_an_authorized_payment(): void { $expectedResponse = ''; @@ -88,8 +86,8 @@ public function it_can_void_an_authorized_payment(): void ], ]; - $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, 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 b8b58bda..63070aba 100644 --- a/tests/Unit/Client/PaymentCapturesTest.php +++ b/tests/Unit/Client/PaymentCapturesTest.php @@ -2,8 +2,6 @@ namespace Srmklive\PayPal\Tests\Unit\Client; -use GuzzleHttp\Utils; -use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use Srmklive\PayPal\Tests\MockClientClasses; use Srmklive\PayPal\Tests\MockRequestPayloads; @@ -15,7 +13,7 @@ class PaymentCapturesTest extends TestCase use MockRequestPayloads; use MockResponsePayloads; - #[Test] + /** @test */ public function it_can_show_details_for_a_captured_payment(): void { $expectedResponse = $this->mockGetCapturedPaymentDetailsResponse(); @@ -29,12 +27,12 @@ public function it_can_show_details_for_a_captured_payment(): void ], ]; - $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, Utils::jsonDecode($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); } - #[Test] + /** @test */ public function it_can_refund_a_captured_payment(): void { $expectedResponse = $this->mockRefundCapturedPaymentResponse(); @@ -49,8 +47,8 @@ public function it_can_refund_a_captured_payment(): void '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, 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 0f31fe6a..45c0f39b 100644 --- a/tests/Unit/Client/PaymentExperienceWebProfilesTest.php +++ b/tests/Unit/Client/PaymentExperienceWebProfilesTest.php @@ -2,8 +2,6 @@ namespace Srmklive\PayPal\Tests\Unit\Client; -use GuzzleHttp\Utils; -use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use Srmklive\PayPal\Tests\MockClientClasses; use Srmklive\PayPal\Tests\MockRequestPayloads; @@ -15,7 +13,7 @@ class PaymentExperienceWebProfilesTest extends TestCase use MockRequestPayloads; use MockResponsePayloads; - #[Test] + /** @test */ public function it_can_list_web_experience_profiles(): void { $expectedResponse = $this->mockListWebProfilesResponse(); @@ -29,12 +27,12 @@ public function it_can_list_web_experience_profiles(): void ], ]; - $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, Utils::jsonDecode($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); } - #[Test] + /** @test */ public function it_can_create_web_experience_profile(): void { $expectedResponse = $this->mockWebProfileResponse(); @@ -50,12 +48,12 @@ public function it_can_create_web_experience_profile(): void '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, Utils::jsonDecode($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); } - #[Test] + /** @test */ public function it_can_delete_web_experience_profile(): void { $expectedResponse = ''; @@ -69,12 +67,12 @@ public function it_can_delete_web_experience_profile(): void ], ]; - $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, Utils::jsonDecode($mockHttpClient->delete($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->delete($expectedEndpoint, $expectedParams)->getBody(), true)); } - #[Test] + /** @test */ public function it_can_partially_update_web_experience_profile(): void { $expectedResponse = ''; @@ -89,12 +87,12 @@ public function it_can_partially_update_web_experience_profile(): void '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, Utils::jsonDecode($mockHttpClient->patch($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->patch($expectedEndpoint, $expectedParams)->getBody(), true)); } - #[Test] + /** @test */ public function it_can_fully_update_web_experience_profile(): void { $expectedResponse = ''; @@ -109,12 +107,12 @@ public function it_can_fully_update_web_experience_profile(): void '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, Utils::jsonDecode($mockHttpClient->patch($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->patch($expectedEndpoint, $expectedParams)->getBody(), true)); } - #[Test] + /** @test */ public function it_can_get_web_experience_profile_details(): void { $expectedResponse = $this->mockWebProfileResponse(); @@ -128,8 +126,8 @@ public function it_can_get_web_experience_profile_details(): void ], ]; - $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, 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 fcbe3375..5abc2efd 100644 --- a/tests/Unit/Client/PaymentRefundsTest.php +++ b/tests/Unit/Client/PaymentRefundsTest.php @@ -2,8 +2,6 @@ namespace Srmklive\PayPal\Tests\Unit\Client; -use GuzzleHttp\Utils; -use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use Srmklive\PayPal\Tests\MockClientClasses; use Srmklive\PayPal\Tests\MockResponsePayloads; @@ -13,7 +11,7 @@ class PaymentRefundsTest extends TestCase use MockClientClasses; use MockResponsePayloads; - #[Test] + /** @test */ public function it_can_show_details_for_a_refund(): void { $expectedResponse = $this->mockGetRefundDetailsResponse(); @@ -27,8 +25,8 @@ public function it_can_show_details_for_a_refund(): void ], ]; - $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, 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 5678c44b..b1b2ecbb 100644 --- a/tests/Unit/Client/PayoutsTest.php +++ b/tests/Unit/Client/PayoutsTest.php @@ -2,8 +2,6 @@ namespace Srmklive\PayPal\Tests\Unit\Client; -use GuzzleHttp\Utils; -use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use Srmklive\PayPal\Tests\MockClientClasses; use Srmklive\PayPal\Tests\MockRequestPayloads; @@ -15,7 +13,7 @@ class PayoutsTest extends TestCase use MockRequestPayloads; use MockResponsePayloads; - #[Test] + /** @test */ public function it_can_create_batch_payout(): void { $expectedResponse = $this->mockCreateBatchPayoutResponse(); @@ -30,12 +28,12 @@ public function it_can_create_batch_payout(): void '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, Utils::jsonDecode($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); } - #[Test] + /** @test */ public function it_can_show_batch_payout_details(): void { $expectedResponse = $this->showBatchPayoutResponse(); @@ -49,12 +47,12 @@ public function it_can_show_batch_payout_details(): void ], ]; - $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, Utils::jsonDecode($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); } - #[Test] + /** @test */ public function it_can_show_batch_payout_item_details(): void { $expectedResponse = $this->showBatchPayoutItemResponse(); @@ -68,12 +66,12 @@ public function it_can_show_batch_payout_item_details(): void ], ]; - $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, Utils::jsonDecode($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); } - #[Test] + /** @test */ public function it_can_cancel_unclaimed_batch_payout_item(): void { $expectedResponse = $this->mockCancelUnclaimedBatchItemResponse(); @@ -87,8 +85,8 @@ public function it_can_cancel_unclaimed_batch_payout_item(): void ], ]; - $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, 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 17995ac2..f135d13f 100644 --- a/tests/Unit/Client/ReferencedPayoutsTest.php +++ b/tests/Unit/Client/ReferencedPayoutsTest.php @@ -2,8 +2,6 @@ namespace Srmklive\PayPal\Tests\Unit\Client; -use GuzzleHttp\Utils; -use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use Srmklive\PayPal\Tests\MockClientClasses; use Srmklive\PayPal\Tests\MockRequestPayloads; @@ -15,7 +13,7 @@ class ReferencedPayoutsTest extends TestCase use MockRequestPayloads; use MockResponsePayloads; - #[Test] + /** @test */ public function it_can_create_referenced_batch_payout(): void { $expectedResponse = $this->mockCreateReferencedBatchPayoutResponse(); @@ -32,12 +30,12 @@ public function it_can_create_referenced_batch_payout(): void '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, Utils::jsonDecode($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); } - #[Test] + /** @test */ public function it_can_list_items_referenced_in_batch_payout(): void { $expectedResponse = $this->mockShowReferencedBatchPayoutResponse(); @@ -51,12 +49,12 @@ public function it_can_list_items_referenced_in_batch_payout(): void ], ]; - $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, Utils::jsonDecode($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); } - #[Test] + /** @test */ public function it_can_create_referenced_batch_payout_item(): void { $expectedResponse = $this->mockCreateReferencedBatchPayoutItemResponse(); @@ -73,12 +71,12 @@ public function it_can_create_referenced_batch_payout_item(): void '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, Utils::jsonDecode($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); } - #[Test] + /** @test */ public function it_can_show_referenced_payout_item_details(): void { $expectedResponse = $this->mockShowReferencedBatchPayoutItemResponse(); @@ -95,8 +93,8 @@ public function it_can_show_referenced_payout_item_details(): void '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, 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 80597a16..5f6143af 100644 --- a/tests/Unit/Client/ReportingTest.php +++ b/tests/Unit/Client/ReportingTest.php @@ -2,8 +2,6 @@ namespace Srmklive\PayPal\Tests\Unit\Client; -use GuzzleHttp\Utils; -use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use Srmklive\PayPal\Tests\MockClientClasses; use Srmklive\PayPal\Tests\MockRequestPayloads; @@ -15,7 +13,7 @@ class ReportingTest extends TestCase use MockRequestPayloads; use MockResponsePayloads; - #[Test] + /** @test */ public function it_can_list_transactions(): void { $expectedResponse = $this->mockListTransactionsResponse(); @@ -29,13 +27,13 @@ public function it_can_list_transactions(): void ], ]; - $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', Utils::jsonDecode($mockResponse, true)); + $this->assertArrayHasKey('transaction_details', $this->jsonDecodeFunction()($mockResponse, true)); } - #[Test] + /** @test */ public function it_can_list_balances(): void { $expectedResponse = $this->mockListBalancesResponse(); @@ -49,8 +47,8 @@ public function it_can_list_balances(): void ], ]; - $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, 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 dc8264fc..9940ad77 100644 --- a/tests/Unit/Client/SubscriptionsTest.php +++ b/tests/Unit/Client/SubscriptionsTest.php @@ -2,8 +2,6 @@ namespace Srmklive\PayPal\Tests\Unit\Client; -use GuzzleHttp\Utils; -use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use Srmklive\PayPal\Tests\MockClientClasses; use Srmklive\PayPal\Tests\MockRequestPayloads; @@ -15,7 +13,7 @@ class SubscriptionsTest extends TestCase use MockRequestPayloads; use MockResponsePayloads; - #[Test] + /** @test */ public function it_can_create_a_subscription(): void { $expectedResponse = $this->mockCreateSubscriptionResponse(); @@ -30,12 +28,12 @@ public function it_can_create_a_subscription(): void '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, Utils::jsonDecode($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); } - #[Test] + /** @test */ public function it_can_update_a_subscription(): void { $expectedResponse = ''; @@ -50,12 +48,12 @@ public function it_can_update_a_subscription(): void '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, Utils::jsonDecode($mockHttpClient->patch($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->patch($expectedEndpoint, $expectedParams)->getBody(), true)); } - #[Test] + /** @test */ public function it_can_show_details_for_a_subscription(): void { $expectedResponse = $this->mockGetSubscriptionDetailsResponse(); @@ -69,12 +67,12 @@ public function it_can_show_details_for_a_subscription(): void ], ]; - $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, Utils::jsonDecode($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); } - #[Test] + /** @test */ public function it_can_activate_a_subscription(): void { $expectedResponse = ''; @@ -89,12 +87,12 @@ public function it_can_activate_a_subscription(): void '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, Utils::jsonDecode($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); } - #[Test] + /** @test */ public function it_can_cancel_a_subscription(): void { $expectedResponse = ''; @@ -109,12 +107,12 @@ public function it_can_cancel_a_subscription(): void '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, Utils::jsonDecode($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); } - #[Test] + /** @test */ public function it_can_suspend_a_subscription(): void { $expectedResponse = ''; @@ -129,12 +127,12 @@ public function it_can_suspend_a_subscription(): void '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, Utils::jsonDecode($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); } - #[Test] + /** @test */ public function it_can_capture_payment_for_a_subscription(): void { $expectedResponse = ''; @@ -149,12 +147,12 @@ public function it_can_capture_payment_for_a_subscription(): void '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, Utils::jsonDecode($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); } - #[Test] + /** @test */ public function it_can_update_quantity_or_product_for_a_subscription(): void { $expectedResponse = $this->mockUpdateSubscriptionItemsResponse(); @@ -169,12 +167,12 @@ public function it_can_update_quantity_or_product_for_a_subscription(): void '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, Utils::jsonDecode($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); } - #[Test] + /** @test */ public function it_can_list_transactions_for_a_subscription(): void { $expectedResponse = $this->mockListSubscriptionTransactionsResponse(); @@ -188,8 +186,8 @@ public function it_can_list_transactions_for_a_subscription(): void ], ]; - $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, 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 1862fa14..312ee5fe 100644 --- a/tests/Unit/Client/TrackersTest.php +++ b/tests/Unit/Client/TrackersTest.php @@ -2,8 +2,6 @@ namespace Srmklive\PayPal\Tests\Unit\Client; -use GuzzleHttp\Utils; -use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use Srmklive\PayPal\Tests\MockClientClasses; use Srmklive\PayPal\Tests\MockRequestPayloads; @@ -15,7 +13,7 @@ class TrackersTest extends TestCase use MockRequestPayloads; use MockResponsePayloads; - #[Test] + /** @test */ public function it_can_get_tracking_details_for_tracking_id(): void { $expectedResponse = $this->mockGetTrackingDetailsResponse(); @@ -29,12 +27,12 @@ public function it_can_get_tracking_details_for_tracking_id(): void ], ]; - $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, Utils::jsonDecode($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); } - #[Test] + /** @test */ public function it_can_update_tracking_details_for_tracking_id(): void { $expectedResponse = ''; @@ -49,12 +47,12 @@ public function it_can_update_tracking_details_for_tracking_id(): void '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, Utils::jsonDecode($mockHttpClient->put($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->put($expectedEndpoint, $expectedParams)->getBody(), true)); } - #[Test] + /** @test */ public function it_can_create_tracking_in_batches(): void { $expectedResponse = $this->mockCreateTrackinginBatchesResponse(); @@ -69,8 +67,8 @@ public function it_can_create_tracking_in_batches(): void '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, 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 e861e5a4..c4496d39 100644 --- a/tests/Unit/Client/WebHooksEventsTest.php +++ b/tests/Unit/Client/WebHooksEventsTest.php @@ -2,8 +2,6 @@ namespace Srmklive\PayPal\Tests\Unit\Client; -use GuzzleHttp\Utils; -use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use Srmklive\PayPal\Tests\MockClientClasses; use Srmklive\PayPal\Tests\MockRequestPayloads; @@ -15,7 +13,7 @@ class WebHooksEventsTest extends TestCase use MockRequestPayloads; use MockResponsePayloads; - #[Test] + /** @test */ public function it_can_list_web_hooks_event_types(): void { $expectedResponse = $this->mockListWebHookEventsTypesResponse(); @@ -29,12 +27,12 @@ public function it_can_list_web_hooks_event_types(): void ], ]; - $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, Utils::jsonDecode($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); } - #[Test] + /** @test */ public function it_can_list_web_hooks_events(): void { $expectedResponse = $this->mockWebHookEventsListResponse(); @@ -48,12 +46,12 @@ public function it_can_list_web_hooks_events(): void ], ]; - $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, Utils::jsonDecode($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); } - #[Test] + /** @test */ public function it_can_show_details_for_a_web_hooks_event(): void { $expectedResponse = $this->mockGetWebHookEventResponse(); @@ -67,12 +65,12 @@ public function it_can_show_details_for_a_web_hooks_event(): void ], ]; - $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, Utils::jsonDecode($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); } - #[Test] + /** @test */ public function it_can_resend_notification_for_a_web_hooks_event(): void { $expectedResponse = $this->mockResendWebHookEventNotificationResponse(); @@ -87,8 +85,8 @@ public function it_can_resend_notification_for_a_web_hooks_event(): void '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, 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 9f52a48c..4b563a46 100644 --- a/tests/Unit/Client/WebHooksTest.php +++ b/tests/Unit/Client/WebHooksTest.php @@ -2,8 +2,6 @@ namespace Srmklive\PayPal\Tests\Unit\Client; -use GuzzleHttp\Utils; -use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use Srmklive\PayPal\Tests\MockClientClasses; use Srmklive\PayPal\Tests\MockRequestPayloads; @@ -15,7 +13,7 @@ class WebHooksTest extends TestCase use MockRequestPayloads; use MockResponsePayloads; - #[Test] + /** @test */ public function it_can_create_a_web_hook(): void { $expectedResponse = $this->mockCreateWebHookResponse(); @@ -30,12 +28,12 @@ public function it_can_create_a_web_hook(): void '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, Utils::jsonDecode($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); } - #[Test] + /** @test */ public function it_can_list_web_hooks(): void { $expectedResponse = $this->mockListWebHookResponse(); @@ -49,12 +47,12 @@ public function it_can_list_web_hooks(): void ], ]; - $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, Utils::jsonDecode($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); } - #[Test] + /** @test */ public function it_can_delete_a_web_hook(): void { $expectedResponse = ''; @@ -68,12 +66,12 @@ public function it_can_delete_a_web_hook(): void ], ]; - $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, Utils::jsonDecode($mockHttpClient->delete($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->delete($expectedEndpoint, $expectedParams)->getBody(), true)); } - #[Test] + /** @test */ public function it_can_update_a_web_hook(): void { $expectedResponse = $this->mockUpdateWebHookResponse(); @@ -88,12 +86,12 @@ public function it_can_update_a_web_hook(): void '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, Utils::jsonDecode($mockHttpClient->patch($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->patch($expectedEndpoint, $expectedParams)->getBody(), true)); } - #[Test] + /** @test */ public function it_can_show_details_for_a_web_hook(): void { $expectedResponse = $this->mockGetWebHookResponse(); @@ -107,12 +105,12 @@ public function it_can_show_details_for_a_web_hook(): void ], ]; - $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, Utils::jsonDecode($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->get($expectedEndpoint, $expectedParams)->getBody(), true)); } - #[Test] + /** @test */ public function it_can_list_web_hooks_events(): void { $expectedResponse = $this->mockListWebHookEventsResponse(); @@ -126,8 +124,8 @@ public function it_can_list_web_hooks_events(): void ], ]; - $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, 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 84cbc722..dc23b995 100644 --- a/tests/Unit/Client/WebHooksVerificationTest.php +++ b/tests/Unit/Client/WebHooksVerificationTest.php @@ -2,8 +2,6 @@ namespace Srmklive\PayPal\Tests\Unit\Client; -use GuzzleHttp\Utils; -use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use Srmklive\PayPal\Tests\MockClientClasses; use Srmklive\PayPal\Tests\MockRequestPayloads; @@ -15,7 +13,7 @@ class WebHooksVerificationTest extends TestCase use MockRequestPayloads; use MockResponsePayloads; - #[Test] + /** @test */ public function it_can_verify_web_hook_signature(): void { $expectedResponse = $this->mockVerifyWebHookSignatureResponse(); @@ -30,8 +28,8 @@ public function it_can_verify_web_hook_signature(): void '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, 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 be60255c..926270c1 100644 --- a/tests/Unit/ClientTest.php +++ b/tests/Unit/ClientTest.php @@ -4,7 +4,6 @@ use GuzzleHttp\Client as HttpClient; use GuzzleHttp\Utils; -use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use Srmklive\PayPal\Tests\MockClientClasses; use Srmklive\PayPal\Tests\MockResponsePayloads; @@ -14,14 +13,14 @@ class ClientTest extends TestCase use MockClientClasses; use MockResponsePayloads; - #[Test] + /** @test */ public function it_can_be_instantiated(): void { $client = new HttpClient(); $this->assertInstanceOf(HttpClient::class, $client); } - #[Test] + /** @test */ public function it_can_get_access_token(): void { $expectedResponse = $this->mockAccessTokenResponse(); @@ -35,8 +34,8 @@ public function it_can_get_access_token(): void '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, Utils::jsonDecode($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); + $this->assertEquals($expectedResponse, $this->jsonDecodeFunction()($mockHttpClient->post($expectedEndpoint, $expectedParams)->getBody(), true)); } }