diff --git a/UPGRADE.md b/UPGRADE.md index 5f361c4a..4f08c99e 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -49,11 +49,11 @@ use Psr\Http\Message\StreamFactoryInterface; public function __construct( - - private readonly GuzzleClientInterface $client, - + private readonly GuzzleClientInterface|ClientInterface $client, - private readonly string $baseUrl, - + private readonly ?RequestFactoryInterface $requestFactory = null, - + private readonly ?StreamFactoryInterface $streamFactory = null, + - private readonly GuzzleClientInterface $client, + + private readonly GuzzleClientInterface|ClientInterface $client, + private readonly string $baseUrl, + + private readonly ?RequestFactoryInterface $requestFactory = null, + + private readonly ?StreamFactoryInterface $streamFactory = null, ) ``` diff --git a/ecs.php b/ecs.php index 9c0762aa..d7e0bd85 100644 --- a/ecs.php +++ b/ecs.php @@ -8,9 +8,12 @@ return static function (ECSConfig $config): void { $config->paths([ - __DIR__ . '/src', - __DIR__ . '/tests/Behat', - __DIR__ . '/ecs.php', + 'src', + 'spec', + 'tests/Behat', + 'tests/Functional', + 'tests/Service', + 'tests/Unit', ]); $config->import('vendor/sylius-labs/coding-standard/ecs.php'); diff --git a/spec/Api/CacheAuthorizeClientApiSpec.php b/spec/Api/CacheAuthorizeClientApiSpec.php index 9ef7fb4d..2d71607c 100644 --- a/spec/Api/CacheAuthorizeClientApiSpec.php +++ b/spec/Api/CacheAuthorizeClientApiSpec.php @@ -30,13 +30,13 @@ function let( ObjectManager $payPalCredentialsManager, ObjectRepository $payPalCredentialsRepository, AuthorizeClientApiInterface $authorizeClientApi, - UuidProviderInterface $uuidProvider + UuidProviderInterface $uuidProvider, ): void { $this->beConstructedWith( $payPalCredentialsManager, $payPalCredentialsRepository, $authorizeClientApi, - $uuidProvider + $uuidProvider, ); } @@ -48,7 +48,7 @@ function it_implements_cache_authorize_client_api_interface(): void function it_returns_cached_access_token_if_it_is_not_expired( ObjectRepository $payPalCredentialsRepository, PayPalCredentialsInterface $payPalCredentials, - PaymentMethodInterface $paymentMethod + PaymentMethodInterface $paymentMethod, ): void { $payPalCredentialsRepository->findOneBy(['paymentMethod' => $paymentMethod])->willReturn($payPalCredentials); @@ -64,7 +64,7 @@ function it_gets_access_token_from_api_caches_and_returns_it( AuthorizeClientApiInterface $authorizeClientApi, PaymentMethodInterface $paymentMethod, GatewayConfigInterface $gatewayConfig, - UuidProviderInterface $uuidProvider + UuidProviderInterface $uuidProvider, ): void { $payPalCredentialsRepository->findOneBy(['paymentMethod' => $paymentMethod])->willReturn(null); @@ -98,7 +98,7 @@ function it_returns_expired_token_and_ask_for_a_new_one( PaymentMethodInterface $paymentMethod, GatewayConfigInterface $gatewayConfig, PayPalCredentialsInterface $payPalCredentials, - UuidProviderInterface $uuidProvider + UuidProviderInterface $uuidProvider, ): void { $payPalCredentialsRepository->findOneBy(['paymentMethod' => $paymentMethod])->willReturn($payPalCredentials); $payPalCredentials->isExpired()->willReturn(true); diff --git a/spec/Api/CompleteOrderApiSpec.php b/spec/Api/CompleteOrderApiSpec.php index aa686f88..543f659d 100644 --- a/spec/Api/CompleteOrderApiSpec.php +++ b/spec/Api/CompleteOrderApiSpec.php @@ -34,7 +34,7 @@ function it_implements_complete_order_api_interface(): void function it_completes_pay_pal_order_with_given_id( PayPalClientInterface $client, PaymentInterface $payment, - OrderInterface $order + OrderInterface $order, ): void { $payment->getOrder()->willReturn($order); $payment->getAmount()->willReturn(10000); diff --git a/spec/Api/CreateOrderApiSpec.php b/spec/Api/CreateOrderApiSpec.php index 4474ba67..3e98da12 100644 --- a/spec/Api/CreateOrderApiSpec.php +++ b/spec/Api/CreateOrderApiSpec.php @@ -30,7 +30,7 @@ final class CreateOrderApiSpec extends ObjectBehavior function let( PayPalClientInterface $client, PaymentReferenceNumberProviderInterface $paymentReferenceNumberProvider, - PayPalItemDataProviderInterface $payPalItemDataProvider + PayPalItemDataProviderInterface $payPalItemDataProvider, ): void { $this->beConstructedWith($client, $paymentReferenceNumberProvider, $payPalItemDataProvider); } @@ -47,7 +47,7 @@ function it_creates_pay_pal_order_based_on_given_payment( OrderInterface $order, PaymentMethodInterface $paymentMethod, GatewayConfigInterface $gatewayConfig, - PayPalItemDataProviderInterface $payPalItemDataProvider + PayPalItemDataProviderInterface $payPalItemDataProvider, ): void { $payment->getOrder()->willReturn($order); $payment->getAmount()->willReturn(10000); @@ -83,7 +83,7 @@ function it_creates_pay_pal_order_based_on_given_payment( $paymentReferenceNumberProvider->provide($payment)->willReturn('REFERENCE-NUMBER'); $gatewayConfig->getConfig()->willReturn( - ['merchant_id' => 'merchant-id', 'sylius_merchant_id' => 'sylius-merchant-id'] + ['merchant_id' => 'merchant-id', 'sylius_merchant_id' => 'sylius-merchant-id'], ); $client->post( @@ -102,7 +102,7 @@ function it_creates_pay_pal_order_based_on_given_payment( $data['purchase_units'][0]['items'][0]['unit_amount']['value'] === '90.00' && $data['purchase_units'][0]['items'][0]['unit_amount']['currency_code'] === 'PLN' ; - }) + }), )->willReturn(['status' => 'CREATED', 'id' => 123]); $this->create('TOKEN', $payment, 'REFERENCE_ID')->shouldReturn(['status' => 'CREATED', 'id' => 123]); @@ -116,7 +116,7 @@ function it_creates_pay_pal_order_with_shipping_address_based_on_given_payment( PaymentMethodInterface $paymentMethod, GatewayConfigInterface $gatewayConfig, AddressInterface $shippingAddress, - PayPalItemDataProviderInterface $payPalItemDataProvider + PayPalItemDataProviderInterface $payPalItemDataProvider, ): void { $payment->getOrder()->willReturn($order); $payment->getAmount()->willReturn(10000); @@ -158,7 +158,7 @@ function it_creates_pay_pal_order_with_shipping_address_based_on_given_payment( $paymentReferenceNumberProvider->provide($payment)->willReturn('REFERENCE-NUMBER'); $gatewayConfig->getConfig()->willReturn( - ['merchant_id' => 'merchant-id', 'sylius_merchant_id' => 'sylius-merchant-id'] + ['merchant_id' => 'merchant-id', 'sylius_merchant_id' => 'sylius-merchant-id'], ); $client->post( @@ -180,7 +180,7 @@ function it_creates_pay_pal_order_with_shipping_address_based_on_given_payment( $data['purchase_units'][0]['items'][0]['unit_amount']['value'] === '90.00' && $data['purchase_units'][0]['items'][0]['unit_amount']['currency_code'] === 'PLN' ; - }) + }), )->willReturn(['status' => 'CREATED', 'id' => 123]); $this->create('TOKEN', $payment, 'REFERENCE_ID')->shouldReturn(['status' => 'CREATED', 'id' => 123]); @@ -194,7 +194,7 @@ function it_creates_pay_pal_order_with_more_than_one_product( GatewayConfigInterface $gatewayConfig, AddressInterface $shippingAddress, PaymentReferenceNumberProviderInterface $paymentReferenceNumberProvider, - PayPalItemDataProviderInterface $payPalItemDataProvider + PayPalItemDataProviderInterface $payPalItemDataProvider, ): void { $payment->getOrder()->willReturn($order); $payment->getAmount()->willReturn(20000); @@ -246,7 +246,7 @@ function it_creates_pay_pal_order_with_more_than_one_product( $paymentMethod->getGatewayConfig()->willReturn($gatewayConfig); $gatewayConfig->getConfig()->willReturn( - ['merchant_id' => 'merchant-id', 'sylius_merchant_id' => 'sylius-merchant-id'] + ['merchant_id' => 'merchant-id', 'sylius_merchant_id' => 'sylius-merchant-id'], ); $paymentReferenceNumberProvider->provide($payment)->willReturn('REFERENCE-NUMBER'); @@ -273,7 +273,7 @@ function it_creates_pay_pal_order_with_more_than_one_product( $data['purchase_units'][0]['items'][1]['unit_amount']['value'] === '40.00' && $data['purchase_units'][0]['items'][1]['unit_amount']['currency_code'] === 'PLN' ; - }) + }), )->willReturn(['status' => 'CREATED', 'id' => 123]); $this->create('TOKEN', $payment, 'REFERENCE_ID')->shouldReturn(['status' => 'CREATED', 'id' => 123]); @@ -287,7 +287,7 @@ function it_creates_pay_pal_order_with_non_neutral_tax_and_changed_quantity( GatewayConfigInterface $gatewayConfig, AddressInterface $shippingAddress, PaymentReferenceNumberProviderInterface $paymentReferenceNumberProvider, - PayPalItemDataProviderInterface $payPalItemDataProvider + PayPalItemDataProviderInterface $payPalItemDataProvider, ): void { $payment->getOrder()->willReturn($order); $payment->getAmount()->willReturn(13000); @@ -339,7 +339,7 @@ function it_creates_pay_pal_order_with_non_neutral_tax_and_changed_quantity( $paymentMethod->getGatewayConfig()->willReturn($gatewayConfig); $gatewayConfig->getConfig()->willReturn( - ['merchant_id' => 'merchant-id', 'sylius_merchant_id' => 'sylius-merchant-id'] + ['merchant_id' => 'merchant-id', 'sylius_merchant_id' => 'sylius-merchant-id'], ); $paymentReferenceNumberProvider->provide($payment)->willReturn('REFERENCE-NUMBER'); @@ -370,7 +370,7 @@ function it_creates_pay_pal_order_with_non_neutral_tax_and_changed_quantity( $data['purchase_units'][0]['items'][1]['tax']['value'] === '10.00' && $data['purchase_units'][0]['items'][1]['tax']['currency_code'] === 'PLN' ; - }) + }), )->willReturn(['status' => 'CREATED', 'id' => 123]); $this->create('TOKEN', $payment, 'REFERENCE_ID')->shouldReturn(['status' => 'CREATED', 'id' => 123]); @@ -384,7 +384,7 @@ function it_creates_pay_pal_order_with_more_than_one_product_with_different_tax_ GatewayConfigInterface $gatewayConfig, AddressInterface $shippingAddress, PaymentReferenceNumberProviderInterface $paymentReferenceNumberProvider, - PayPalItemDataProviderInterface $payPalItemDataProvider + PayPalItemDataProviderInterface $payPalItemDataProvider, ): void { $payment->getOrder()->willReturn($order); $payment->getAmount()->willReturn(20400); @@ -448,7 +448,7 @@ function it_creates_pay_pal_order_with_more_than_one_product_with_different_tax_ $paymentMethod->getGatewayConfig()->willReturn($gatewayConfig); $gatewayConfig->getConfig()->willReturn( - ['merchant_id' => 'merchant-id', 'sylius_merchant_id' => 'sylius-merchant-id'] + ['merchant_id' => 'merchant-id', 'sylius_merchant_id' => 'sylius-merchant-id'], ); $paymentReferenceNumberProvider->provide($payment)->willReturn('REFERENCE-NUMBER'); @@ -485,7 +485,7 @@ function it_creates_pay_pal_order_with_more_than_one_product_with_different_tax_ $data['purchase_units'][0]['items'][2]['tax']['value'] === '1.00' && $data['purchase_units'][0]['items'][2]['tax']['currency_code'] === 'PLN' ; - }) + }), )->willReturn(['status' => 'CREATED', 'id' => 123]); $this->create('TOKEN', $payment, 'REFERENCE_ID')->shouldReturn(['status' => 'CREATED', 'id' => 123]); @@ -499,7 +499,7 @@ function it_allows_to_create_digital_order( GatewayConfigInterface $gatewayConfig, AddressInterface $shippingAddress, PaymentReferenceNumberProviderInterface $paymentReferenceNumberProvider, - PayPalItemDataProviderInterface $payPalItemDataProvider + PayPalItemDataProviderInterface $payPalItemDataProvider, ): void { $payment->getOrder()->willReturn($order); $payment->getAmount()->willReturn(20000); @@ -533,7 +533,7 @@ function it_allows_to_create_digital_order( $paymentMethod->getGatewayConfig()->willReturn($gatewayConfig); $gatewayConfig->getConfig()->willReturn( - ['merchant_id' => 'merchant-id', 'sylius_merchant_id' => 'sylius-merchant-id'] + ['merchant_id' => 'merchant-id', 'sylius_merchant_id' => 'sylius-merchant-id'], ); $order->setShippingAddress(Argument::any())->shouldNotBeCalled(); @@ -550,7 +550,7 @@ function it_allows_to_create_digital_order( $data['purchase_units'][0]['amount']['currency_code'] === 'PLN' && $data['application_context']['shipping_preference'] === 'NO_SHIPPING' ; - }) + }), )->willReturn(['status' => 'CREATED', 'id' => 123]); $this->create('TOKEN', $payment, 'REFERENCE_ID')->shouldReturn(['status' => 'CREATED', 'id' => 123]); @@ -563,7 +563,7 @@ function it_creates_pay_pal_order_with_promotion( OrderInterface $order, PaymentMethodInterface $paymentMethod, GatewayConfigInterface $gatewayConfig, - PayPalItemDataProviderInterface $payPalItemDataProvider + PayPalItemDataProviderInterface $payPalItemDataProvider, ): void { $payment->getOrder()->willReturn($order); $payment->getAmount()->willReturn(2999); @@ -599,7 +599,7 @@ function it_creates_pay_pal_order_with_promotion( $paymentReferenceNumberProvider->provide($payment)->willReturn('REFERENCE-NUMBER'); $gatewayConfig->getConfig()->willReturn( - ['merchant_id' => 'merchant-id', 'sylius_merchant_id' => 'sylius-merchant-id'] + ['merchant_id' => 'merchant-id', 'sylius_merchant_id' => 'sylius-merchant-id'], ); $client->post( @@ -621,8 +621,8 @@ function it_creates_pay_pal_order_with_promotion( $data['purchase_units'][0]['items'][0]['quantity'] === 1 && $data['purchase_units'][0]['items'][0]['unit_amount']['value'] === '25.00' && $data['purchase_units'][0]['items'][0]['unit_amount']['currency_code'] === 'PLN' - ; - }) + ; + }), )->willReturn(['status' => 'CREATED', 'id' => 123]); $this->create('TOKEN', $payment, 'REFERENCE_ID')->shouldReturn(['status' => 'CREATED', 'id' => 123]); diff --git a/spec/Api/GenericApiSpec.php b/spec/Api/GenericApiSpec.php index 6ccec70d..105039ca 100644 --- a/spec/Api/GenericApiSpec.php +++ b/spec/Api/GenericApiSpec.php @@ -13,9 +13,9 @@ namespace spec\Sylius\PayPalPlugin\Api; +use GuzzleHttp\ClientInterface as GuzzleClientInterface; use PhpSpec\ObjectBehavior; use Psr\Http\Client\ClientInterface; -use GuzzleHttp\ClientInterface as GuzzleClientInterface; use Psr\Http\Message\RequestFactoryInterface; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\ResponseInterface; @@ -39,9 +39,8 @@ function it_calls_api_by_url( RequestFactoryInterface $requestFactory, RequestInterface $request, ResponseInterface $response, - StreamInterface $body + StreamInterface $body, ): void { - $requestFactory->createRequest('GET', 'http://url.com/')->willReturn($request); $request->withHeader('Authorization', 'Bearer TOKEN')->willReturn($request); @@ -58,7 +57,7 @@ function it_calls_api_by_url( function it_calls_api_by_url_using_guzzle_client( GuzzleClientInterface $client, ResponseInterface $response, - StreamInterface $body + StreamInterface $body, ): void { $this->beConstructedWith($client); diff --git a/spec/Api/RefundPaymentApiSpec.php b/spec/Api/RefundPaymentApiSpec.php index fe476144..cc7e2581 100644 --- a/spec/Api/RefundPaymentApiSpec.php +++ b/spec/Api/RefundPaymentApiSpec.php @@ -36,7 +36,7 @@ function it_refunds_pay_pal_payment_with_given_id(PayPalClientInterface $client) 'v2/payments/captures/123123/refund', 'TOKEN', ['amount' => ['value' => '10.99', 'currency_code' => 'USD'], 'invoice_number' => '123-11-11-2010'], - ['PayPal-Auth-Assertion' => 'PAY-PAL-AUTH-ASSERTION'] + ['PayPal-Auth-Assertion' => 'PAY-PAL-AUTH-ASSERTION'], ) ->willReturn(['status' => 'COMPLETED', 'id' => '123123']) ; diff --git a/spec/Api/UpdateOrderApiSpec.php b/spec/Api/UpdateOrderApiSpec.php index c4fb767d..3a99725f 100644 --- a/spec/Api/UpdateOrderApiSpec.php +++ b/spec/Api/UpdateOrderApiSpec.php @@ -28,7 +28,7 @@ final class UpdateOrderApiSpec extends ObjectBehavior function let( PayPalClientInterface $client, PaymentReferenceNumberProviderInterface $paymentReferenceNumberProvider, - PayPalItemDataProviderInterface $payPalItemsDataProvider + PayPalItemDataProviderInterface $payPalItemsDataProvider, ): void { $this->beConstructedWith($client, $paymentReferenceNumberProvider, $payPalItemsDataProvider); } @@ -44,7 +44,7 @@ function it_updates_pay_pal_order_with_given_new_total( PayPalItemDataProviderInterface $payPalItemsDataProvider, PaymentInterface $payment, OrderInterface $order, - AddressInterface $shippingAddress + AddressInterface $shippingAddress, ): void { $payment->getOrder()->willReturn($order); $order->getShippingAddress()->willReturn($shippingAddress); @@ -92,7 +92,7 @@ function it_updates_pay_pal_order_with_given_new_total( $data[0]['value']['shipping']['address']['country_code'] === 'US' && $data[0]['value']['items'] === ['data'] ; - }) + }), )->shouldBeCalled(); $this->update('TOKEN', 'ORDER-ID', $payment, 'REFERENCE-ID', 'MERCHANT-ID'); @@ -104,7 +104,7 @@ function it_updates_digital_order( PayPalItemDataProviderInterface $payPalItemsDataProvider, PaymentInterface $payment, OrderInterface $order, - AddressInterface $shippingAddress + AddressInterface $shippingAddress, ): void { $payment->getOrder()->willReturn($order); $order->getShippingAddress()->willReturn($shippingAddress); @@ -141,7 +141,7 @@ function it_updates_digital_order( $data[0]['value']['payee']['merchant_id'] === 'MERCHANT-ID' && $data[0]['value']['items'] === ['data'] ; - }) + }), )->shouldBeCalled(); $this->update('TOKEN', 'ORDER-ID', $payment, 'REFERENCE-ID', 'MERCHANT-ID'); diff --git a/spec/Api/WebhookApiSpec.php b/spec/Api/WebhookApiSpec.php index 25df480a..15d12876 100644 --- a/spec/Api/WebhookApiSpec.php +++ b/spec/Api/WebhookApiSpec.php @@ -4,10 +4,10 @@ namespace spec\Sylius\PayPalPlugin\Api; +use GuzzleHttp\ClientInterface as GuzzleClientInterface; use PhpSpec\ObjectBehavior; use Prophecy\Argument; use Psr\Http\Client\ClientInterface; -use GuzzleHttp\ClientInterface as GuzzleClientInterface; use Psr\Http\Message\RequestFactoryInterface; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\ResponseInterface; @@ -21,7 +21,7 @@ function let( RequestFactoryInterface $requestFactory, StreamFactoryInterface $streamFactory, StreamInterface $stream, - RequestInterface $request + RequestInterface $request, ): void { $this->beConstructedWith($client, 'http://base-url.com/', $requestFactory, $streamFactory); $request->withHeader(Argument::any(), Argument::any())->willReturn($request); @@ -34,11 +34,10 @@ function it_registers_webhook( RequestFactoryInterface $requestFactory, RequestInterface $request, ResponseInterface $response, - StreamInterface $body + StreamInterface $body, ): void { - $requestFactory - ->createRequest('POST','http://base-url.com/v1/notifications/webhooks') + ->createRequest('POST', 'http://base-url.com/v1/notifications/webhooks') ->willReturn($request); $client->sendRequest($request)->willReturn($response); @@ -51,7 +50,7 @@ function it_registers_webhook( function it_registers_webhook_using_guzzle_client( GuzzleClientInterface $client, ResponseInterface $response, - StreamInterface $body + StreamInterface $body, ): void { $this->beConstructedWith($client, 'http://base-url.com/'); @@ -70,7 +69,7 @@ function it_registers_webhook_using_guzzle_client( ['name' => 'PAYMENT.CAPTURE.REFUNDED'], ], ], - ] + ], )->willReturn($response); $response->getBody()->willReturn($body); $body->getContents()->willReturn('{ "status": "CREATED" }'); @@ -83,9 +82,9 @@ function it_registers_webhook_without_https( RequestFactoryInterface $requestFactory, RequestInterface $request, ResponseInterface $response, - StreamInterface $body + StreamInterface $body, ): void { - $requestFactory->createRequest('POST','http://base-url.com/v1/notifications/webhooks') + $requestFactory->createRequest('POST', 'http://base-url.com/v1/notifications/webhooks') ->willReturn($request); $client->sendRequest($request)->willReturn($response); @@ -98,7 +97,7 @@ function it_registers_webhook_without_https( function it_registers_webhook_without_https_using_guzzle_client( GuzzleClientInterface $client, ResponseInterface $response, - StreamInterface $body + StreamInterface $body, ): void { $this->beConstructedWith($client, 'http://base-url.com/'); @@ -117,7 +116,7 @@ function it_registers_webhook_without_https_using_guzzle_client( ['name' => 'PAYMENT.CAPTURE.REFUNDED'], ], ], - ] + ], )->willReturn($response); $response->getBody()->willReturn($body); $body->getContents()->willReturn('{ "status": "CREATED" }'); diff --git a/spec/ApiPlatform/PayPalPaymentSpec.php b/spec/ApiPlatform/PayPalPaymentSpec.php index 6aaf6ce7..4e3fef27 100644 --- a/spec/ApiPlatform/PayPalPaymentSpec.php +++ b/spec/ApiPlatform/PayPalPaymentSpec.php @@ -31,7 +31,7 @@ function let(RouterInterface $router, AvailableCountriesProviderInterface $avail function it_supports_paypal_payment_method( PaymentMethodInterface $paymentMethod, - GatewayConfigInterface $gatewayConfig + GatewayConfigInterface $gatewayConfig, ): void { $paymentMethod->getGatewayConfig()->willReturn($gatewayConfig); @@ -46,7 +46,7 @@ function it_provides_proper_paypal_configuration( OrderInterface $order, GatewayConfigInterface $gatewayConfig, AvailableCountriesProviderInterface $availableCountriesProvider, - RouterInterface $router + RouterInterface $router, ): void { $payment->getMethod()->willReturn($paymentMethod); @@ -55,7 +55,7 @@ function it_provides_proper_paypal_configuration( [ 'client_id' => 'CLIENT-ID', 'partner_attribution_id' => 'PARTNER-ATTRIBUTION-ID', - ] + ], ); $payment->getOrder()->willReturn($order); @@ -70,25 +70,25 @@ function it_provides_proper_paypal_configuration( $router->generate( 'sylius_paypal_plugin_complete_paypal_order', ['token' => 'TOKEN'], - UrlGeneratorInterface::ABSOLUTE_URL + UrlGeneratorInterface::ABSOLUTE_URL, )->willReturn('https://path-to-complete/TOKEN'); $router->generate( 'sylius_paypal_plugin_create_paypal_order', ['token' => 'TOKEN'], - UrlGeneratorInterface::ABSOLUTE_URL + UrlGeneratorInterface::ABSOLUTE_URL, )->willReturn('https://path-to-create/TOKEN'); $router->generate( 'sylius_paypal_plugin_cancel_payment', [], - UrlGeneratorInterface::ABSOLUTE_URL + UrlGeneratorInterface::ABSOLUTE_URL, )->willReturn('https://path-to-cancel'); $router->generate( 'sylius_paypal_plugin_payment_error', [], - UrlGeneratorInterface::ABSOLUTE_URL + UrlGeneratorInterface::ABSOLUTE_URL, )->willReturn('https://path-to-error'); $this->provideConfiguration($payment)->shouldReturn( @@ -104,7 +104,7 @@ function it_provides_proper_paypal_configuration( 'orderToken' => 'TOKEN', 'errorPayPalPaymentUrl' => 'https://path-to-error', 'available_countries' => ['PL', 'US'], - ] + ], ); } } diff --git a/spec/Client/PayPalClientSpec.php b/spec/Client/PayPalClientSpec.php index 3bc8e272..1efd41b0 100644 --- a/spec/Client/PayPalClientSpec.php +++ b/spec/Client/PayPalClientSpec.php @@ -13,12 +13,12 @@ namespace spec\Sylius\PayPalPlugin\Client; +use GuzzleHttp\ClientInterface as GuzzleClientInterface; use GuzzleHttp\Exception\ConnectException; use GuzzleHttp\Exception\RequestException; use PhpSpec\ObjectBehavior; use Prophecy\Argument; use Psr\Http\Client\ClientInterface; -use GuzzleHttp\ClientInterface as GuzzleClientInterface; use Psr\Http\Message\RequestFactoryInterface; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\ResponseInterface; @@ -76,7 +76,7 @@ function it_returns_auth_token_for_given_client_data( RequestFactoryInterface $requestFactory, RequestInterface $request, ResponseInterface $response, - StreamInterface $body + StreamInterface $body, ): void { $requestFactory->createRequest('POST', 'https://test-api.paypal.com/v1/oauth2/token')->willReturn($request); $request->withHeader(Argument::any(), Argument::any())->willReturn($request); @@ -96,7 +96,7 @@ function it_returns_auth_token_for_given_client_data_using_guzzle_client( PayPalConfigurationProviderInterface $payPalConfigurationProvider, ChannelContextInterface $channelContext, ResponseInterface $response, - StreamInterface $body + StreamInterface $body, ): void { $this->beConstructedWith( $client, @@ -115,7 +115,7 @@ function it_returns_auth_token_for_given_client_data_using_guzzle_client( [ 'auth' => ['CLIENT_ID', 'CLIENT_SECRET'], 'form_params' => ['grant_type' => 'client_credentials'], - ] + ], )->willReturn($response); $response->getStatusCode()->willReturn(200); $response->getBody()->willReturn($body); @@ -128,10 +128,10 @@ function it_throws_an_exception_if_client_could_not_be_authorized( ClientInterface $client, RequestFactoryInterface $requestFactory, RequestInterface $request, - ResponseInterface $response + ResponseInterface $response, ): void { - $requestFactory->createRequest('POST', 'https://test-api.paypal.com/v1/oauth2/token')->willReturn($request); - $client->sendRequest($request)->willReturn($response); + $requestFactory->createRequest('POST', 'https://test-api.paypal.com/v1/oauth2/token')->willReturn($request); + $client->sendRequest($request)->willReturn($response); $response->getStatusCode()->willReturn(401); @@ -147,7 +147,7 @@ function it_throws_an_exception_if_client_could_not_be_authorized_using_guzzle_c UuidProviderInterface $uuidProvider, PayPalConfigurationProviderInterface $payPalConfigurationProvider, ChannelContextInterface $channelContext, - ResponseInterface $response + ResponseInterface $response, ): void { $this->beConstructedWith( $client, @@ -166,7 +166,7 @@ function it_throws_an_exception_if_client_could_not_be_authorized_using_guzzle_c [ 'auth' => ['CLIENT_ID', 'CLIENT_SECRET'], 'form_params' => ['grant_type' => 'client_credentials'], - ] + ], )->willReturn($response); $response->getStatusCode()->willReturn(401); @@ -183,7 +183,7 @@ function it_calls_get_request_on_paypal_api( PayPalConfigurationProviderInterface $payPalConfigurationProvider, ChannelInterface $channel, ResponseInterface $response, - StreamInterface $body + StreamInterface $body, ): void { $payPalConfigurationProvider->getPartnerAttributionId($channel)->willReturn('TRACKING-ID'); @@ -205,7 +205,7 @@ function it_calls_get_request_on_paypal_api_using_guzzle_client( ChannelContextInterface $channelContext, ChannelInterface $channel, ResponseInterface $response, - StreamInterface $body + StreamInterface $body, ): void { $this->beConstructedWith( $client, @@ -230,7 +230,7 @@ function it_calls_get_request_on_paypal_api_using_guzzle_client( 'Accept' => 'application/json', 'PayPal-Partner-Attribution-Id' => 'TRACKING-ID', ], - ] + ], )->willReturn($response); $response->getStatusCode()->willReturn(200); $response->getBody()->willReturn($body); @@ -250,7 +250,7 @@ function it_logs_all_requests_if_logging_level_is_increased( ChannelContextInterface $channelContext, ChannelInterface $channel, ResponseInterface $response, - StreamInterface $body + StreamInterface $body, ): void { $this->beConstructedWith( $client, @@ -291,7 +291,7 @@ function it_logs_all_requests_if_logging_level_is_increased_using_guzzle_client( ChannelContextInterface $channelContext, ChannelInterface $channel, ResponseInterface $response, - StreamInterface $body + StreamInterface $body, ): void { $this->beConstructedWith( $client, @@ -317,7 +317,7 @@ function it_logs_all_requests_if_logging_level_is_increased_using_guzzle_client( 'Accept' => 'application/json', 'PayPal-Partner-Attribution-Id' => 'TRACKING-ID', ], - ] + ], )->willReturn($response); $response->getStatusCode()->willReturn(200); @@ -341,7 +341,7 @@ function it_logs_debug_id_from_failed_get_request( ChannelInterface $channel, RequestException $exception, ResponseInterface $response, - StreamInterface $body + StreamInterface $body, ): void { $payPalConfigurationProvider->getPartnerAttributionId($channel)->willReturn('TRACKING-ID'); @@ -370,7 +370,7 @@ function it_logs_debug_id_from_failed_get_request_using_guzzle_client( ChannelInterface $channel, RequestException $exception, ResponseInterface $response, - StreamInterface $body + StreamInterface $body, ): void { $this->beConstructedWith( $client, @@ -395,7 +395,7 @@ function it_logs_debug_id_from_failed_get_request_using_guzzle_client( 'Accept' => 'application/json', 'PayPal-Partner-Attribution-Id' => 'TRACKING-ID', ], - ] + ], )->willThrow($exception->getWrappedObject()); $exception->getResponse()->willReturn($response); @@ -419,7 +419,7 @@ function it_calls_post_request_on_paypal_api( StreamInterface $body, UuidProviderInterface $uuidProvider, PayPalConfigurationProviderInterface $payPalConfigurationProvider, - ChannelInterface $channel + ChannelInterface $channel, ): void { $uuidProvider->provide()->willReturn('REQUEST-ID'); $payPalConfigurationProvider->getPartnerAttributionId($channel)->willReturn('TRACKING-ID'); @@ -445,7 +445,7 @@ function it_calls_post_request_on_paypal_api_using_guzzle_client( ChannelContextInterface $channelContext, ResponseInterface $response, StreamInterface $body, - ChannelInterface $channel + ChannelInterface $channel, ): void { $this->beConstructedWith( $client, @@ -473,7 +473,7 @@ function it_calls_post_request_on_paypal_api_using_guzzle_client( 'PayPal-Request-Id' => 'REQUEST-ID', ], 'json' => ['parameter' => 'value', 'another_parameter' => 'another_value'], - ] + ], )->willReturn($response); $response->getStatusCode()->willReturn(200); @@ -495,7 +495,7 @@ function it_calls_post_request_on_paypal_api_with_extra_headers( StreamInterface $body, UuidProviderInterface $uuidProvider, PayPalConfigurationProviderInterface $payPalConfigurationProvider, - ChannelInterface $channel + ChannelInterface $channel, ): void { $uuidProvider->provide()->willReturn('REQUEST-ID'); $payPalConfigurationProvider->getPartnerAttributionId($channel)->willReturn('TRACKING-ID'); @@ -524,7 +524,7 @@ function it_calls_post_request_on_paypal_api_with_extra_headers_using_guzzle_cli ChannelContextInterface $channelContext, ResponseInterface $response, StreamInterface $body, - ChannelInterface $channel + ChannelInterface $channel, ): void { $this->beConstructedWith( $client, @@ -553,7 +553,7 @@ function it_calls_post_request_on_paypal_api_with_extra_headers_using_guzzle_cli 'CUSTOM_HEADER' => 'header', ], 'json' => ['parameter' => 'value', 'another_parameter' => 'another_value'], - ] + ], )->willReturn($response); $response->getStatusCode()->willReturn(200); @@ -576,7 +576,7 @@ function it_logs_debug_id_from_failed_post_request( StreamInterface $body, UuidProviderInterface $uuidProvider, PayPalConfigurationProviderInterface $payPalConfigurationProvider, - ChannelInterface $channel + ChannelInterface $channel, ): void { $uuidProvider->provide()->willReturn('REQUEST-ID'); $payPalConfigurationProvider->getPartnerAttributionId($channel)->willReturn('TRACKING-ID'); @@ -609,7 +609,7 @@ function it_logs_debug_id_from_failed_post_request_using_guzzle_client( RequestException $exception, ResponseInterface $response, StreamInterface $body, - ChannelInterface $channel + ChannelInterface $channel, ): void { $this->beConstructedWith( $client, @@ -637,7 +637,7 @@ function it_logs_debug_id_from_failed_post_request_using_guzzle_client( 'PayPal-Request-Id' => 'REQUEST-ID', ], 'json' => ['parameter' => 'value', 'another_parameter' => 'another_value'], - ] + ], )->willThrow($exception->getWrappedObject()); $exception->getResponse()->willReturn($response); @@ -663,7 +663,7 @@ function it_calls_patch_request_on_paypal_api( ResponseInterface $response, StreamInterface $body, PayPalConfigurationProviderInterface $payPalConfigurationProvider, - ChannelInterface $channel + ChannelInterface $channel, ): void { $payPalConfigurationProvider->getPartnerAttributionId($channel)->willReturn('TRACKING-ID'); $requestFactory->createRequest('PATCH', 'https://test-api.paypal.com/v2/patch-request/123123')->willReturn($request); @@ -686,7 +686,7 @@ function it_calls_patch_request_on_paypal_api_using_guzzle_client( ChannelContextInterface $channelContext, ResponseInterface $response, StreamInterface $body, - ChannelInterface $channel + ChannelInterface $channel, ): void { $this->beConstructedWith( $client, @@ -711,7 +711,7 @@ function it_calls_patch_request_on_paypal_api_using_guzzle_client( 'PayPal-Partner-Attribution-Id' => 'TRACKING-ID', ], 'json' => ['parameter' => 'value', 'another_parameter' => 'another_value'], - ] + ], )->willReturn($response); $response->getStatusCode()->willReturn(200); $response->getBody()->willReturn($body); @@ -732,7 +732,7 @@ function it_logs_debug_id_from_failed_patch_request( ResponseInterface $response, StreamInterface $body, PayPalConfigurationProviderInterface $payPalConfigurationProvider, - ChannelInterface $channel + ChannelInterface $channel, ): void { $payPalConfigurationProvider->getPartnerAttributionId($channel)->willReturn('TRACKING-ID'); @@ -764,7 +764,7 @@ function it_logs_debug_id_from_failed_patch_request_using_guzzle_client( RequestException $exception, ResponseInterface $response, StreamInterface $body, - ChannelInterface $channel + ChannelInterface $channel, ): void { $this->beConstructedWith( $client, @@ -790,7 +790,7 @@ function it_logs_debug_id_from_failed_patch_request_using_guzzle_client( 'PayPal-Partner-Attribution-Id' => 'TRACKING-ID', ], 'json' => ['parameter' => 'value', 'another_parameter' => 'another_value'], - ] + ], )->willThrow($exception->getWrappedObject()); $exception->getResponse()->willReturn($response); @@ -814,7 +814,7 @@ function it_throws_exception_if_the_timeout_has_been_reached_the_specified_amoun RequestFactoryInterface $requestFactory, RequestInterface $request, PayPalConfigurationProviderInterface $payPalConfigurationProvider, - ChannelInterface $channel + ChannelInterface $channel, ): void { $payPalConfigurationProvider->getPartnerAttributionId($channel)->willReturn('TRACKING-ID'); @@ -833,7 +833,7 @@ function it_throws_exception_if_the_timeout_has_been_reached_the_specified_amoun UuidProviderInterface $uuidProvider, PayPalConfigurationProviderInterface $payPalConfigurationProvider, ChannelContextInterface $channelContext, - ChannelInterface $channel + ChannelInterface $channel, ): void { $this->beConstructedWith( $client, @@ -858,7 +858,7 @@ function it_throws_exception_if_the_timeout_has_been_reached_the_specified_amoun 'Accept' => 'application/json', 'PayPal-Partner-Attribution-Id' => 'TRACKING-ID', ], - ] + ], )->willThrow(ConnectException::class); $this diff --git a/spec/Downloader/SftpPayoutsReportDownloaderSpec.php b/spec/Downloader/SftpPayoutsReportDownloaderSpec.php index de4cd8b6..2d21fe1b 100644 --- a/spec/Downloader/SftpPayoutsReportDownloaderSpec.php +++ b/spec/Downloader/SftpPayoutsReportDownloaderSpec.php @@ -36,7 +36,7 @@ function it_implements_payouts_report_downloader_interface(): void function it_returns_content_of_the_latest_pyt_report_from_pay_pal_sftp_server( SFTP $sftp, PaymentMethodInterface $paymentMethod, - GatewayConfigInterface $gatewayConfig + GatewayConfigInterface $gatewayConfig, ): void { $paymentMethod->getGatewayConfig()->willReturn($gatewayConfig); $gatewayConfig->getConfig()->willReturn( @@ -44,7 +44,7 @@ function it_returns_content_of_the_latest_pyt_report_from_pay_pal_sftp_server( 'partner_attribution_id' => 'PARTNER-ID', 'reports_sftp_username' => 'SFTP-USERNAME', 'reports_sftp_password' => 'SFTP-PASSWORD', - ] + ], ); $sftp->login('SFTP-USERNAME', 'SFTP-PASSWORD')->willReturn(true); @@ -64,7 +64,7 @@ function it_returns_content_of_the_latest_pyt_report_from_pay_pal_sftp_server( function it_throws_an_exception_if_payment_method_has_no_partner_attribution_id( SFTP $sftp, PaymentMethodInterface $paymentMethod, - GatewayConfigInterface $gatewayConfig + GatewayConfigInterface $gatewayConfig, ): void { $paymentMethod->getGatewayConfig()->willReturn($gatewayConfig); $gatewayConfig->getConfig()->willReturn([]); @@ -78,7 +78,7 @@ function it_throws_an_exception_if_payment_method_has_no_partner_attribution_id( function it_throws_an_exception_if_credentials_are_invalid( SFTP $sftp, PaymentMethodInterface $paymentMethod, - GatewayConfigInterface $gatewayConfig + GatewayConfigInterface $gatewayConfig, ): void { $paymentMethod->getGatewayConfig()->willReturn($gatewayConfig); $gatewayConfig->getConfig()->willReturn( @@ -86,7 +86,7 @@ function it_throws_an_exception_if_credentials_are_invalid( 'partner_attribution_id' => 'PARTNER-ID', 'reports_sftp_username' => 'SFTP-USERNAME', 'reports_sftp_password' => 'SFTP-PASSWORD', - ] + ], ); $sftp->login('SFTP-USERNAME', 'SFTP-PASSWORD')->willReturn(false); @@ -100,7 +100,7 @@ function it_throws_an_exception_if_credentials_are_invalid( function it_throws_an_exception_if_there_is_no_report_with_given_name( SFTP $sftp, PaymentMethodInterface $paymentMethod, - GatewayConfigInterface $gatewayConfig + GatewayConfigInterface $gatewayConfig, ): void { $paymentMethod->getGatewayConfig()->willReturn($gatewayConfig); $gatewayConfig->getConfig()->willReturn( @@ -108,7 +108,7 @@ function it_throws_an_exception_if_there_is_no_report_with_given_name( 'partner_attribution_id' => 'PARTNER-ID', 'reports_sftp_username' => 'SFTP-USERNAME', 'reports_sftp_password' => 'SFTP-PASSWORD', - ] + ], ); $sftp->login('SFTP-USERNAME', 'SFTP-PASSWORD')->willReturn(true); diff --git a/spec/Enabler/PayPalPaymentMethodEnablerSpec.php b/spec/Enabler/PayPalPaymentMethodEnablerSpec.php index 7a5c46f1..954ff09d 100644 --- a/spec/Enabler/PayPalPaymentMethodEnablerSpec.php +++ b/spec/Enabler/PayPalPaymentMethodEnablerSpec.php @@ -14,10 +14,10 @@ namespace spec\Sylius\PayPalPlugin\Enabler; use Doctrine\Persistence\ObjectManager; +use GuzzleHttp\ClientInterface as GuzzleClientInterface; use Payum\Core\Model\GatewayConfigInterface; use PhpSpec\ObjectBehavior; use Psr\Http\Client\ClientInterface; -use GuzzleHttp\ClientInterface as GuzzleClientInterface; use Psr\Http\Message\RequestFactoryInterface; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\ResponseInterface; @@ -33,10 +33,14 @@ function let( ClientInterface $client, RequestFactoryInterface $requestFactory, ObjectManager $paymentMethodManager, - SellerWebhookRegistrarInterface $sellerWebhookRegistrar + SellerWebhookRegistrarInterface $sellerWebhookRegistrar, ): void { $this->beConstructedWith( - $client, 'http://base-url.com', $paymentMethodManager, $sellerWebhookRegistrar, $requestFactory + $client, + 'http://base-url.com', + $paymentMethodManager, + $sellerWebhookRegistrar, + $requestFactory, ); } @@ -54,7 +58,7 @@ function it_enables_payment_method_if_it_has_proper_credentials_and_webhook_are_ PaymentMethodInterface $paymentMethod, GatewayConfigInterface $gatewayConfig, ResponseInterface $response, - StreamInterface $body + StreamInterface $body, ): void { $paymentMethod->getGatewayConfig()->willReturn($gatewayConfig); $gatewayConfig->getConfig()->willReturn(['merchant_id' => '123123', 'client_id' => 'CLIENT-ID', 'client_secret' => 'SECRET']); @@ -80,7 +84,7 @@ function it_enables_payment_method_if_it_has_proper_credentials_and_webhook_are_ PaymentMethodInterface $paymentMethod, GatewayConfigInterface $gatewayConfig, ResponseInterface $response, - StreamInterface $body + StreamInterface $body, ): void { $this->beConstructedWith( $client, @@ -113,7 +117,7 @@ function it_throws_exception_if_payment_method_credentials_are_not_granted( PaymentMethodInterface $paymentMethod, GatewayConfigInterface $gatewayConfig, ResponseInterface $response, - StreamInterface $body + StreamInterface $body, ): void { $paymentMethod->getGatewayConfig()->willReturn($gatewayConfig); $gatewayConfig->getConfig()->willReturn(['merchant_id' => '123123', 'client_id' => 'CLIENT-ID', 'client_secret' => 'SECRET']); @@ -143,7 +147,7 @@ function it_throws_exception_if_payment_method_credentials_are_not_granted_using PaymentMethodInterface $paymentMethod, GatewayConfigInterface $gatewayConfig, ResponseInterface $response, - StreamInterface $body + StreamInterface $body, ): void { $this->beConstructedWith( $client, diff --git a/spec/Generator/PayPalAuthAssertionGeneratorSpec.php b/spec/Generator/PayPalAuthAssertionGeneratorSpec.php index 658d512a..5ec3cc4b 100644 --- a/spec/Generator/PayPalAuthAssertionGeneratorSpec.php +++ b/spec/Generator/PayPalAuthAssertionGeneratorSpec.php @@ -27,7 +27,7 @@ function it_implements_pay_pal_auth_assertion_generator_interface(): void function it_generates_auth_assertion_based_on_payment_method_config( PaymentMethodInterface $paymentMethod, - GatewayConfigInterface $gatewayConfig + GatewayConfigInterface $gatewayConfig, ): void { $paymentMethod->getGatewayConfig()->willReturn($gatewayConfig); $gatewayConfig->getConfig()->willReturn(['client_id' => 'CLIENT_ID', 'merchant_id' => 'MERCHANT_ID']); @@ -40,7 +40,7 @@ function it_generates_auth_assertion_based_on_payment_method_config( function it_throws_an_exception_if_gateway_config_does_not_have_proper_values_set( PaymentMethodInterface $paymentMethod, - GatewayConfigInterface $gatewayConfig + GatewayConfigInterface $gatewayConfig, ): void { $paymentMethod->getGatewayConfig()->willReturn($gatewayConfig, $gatewayConfig); $gatewayConfig->getConfig()->willReturn(['merchant_id' => 'MERCHANT_ID'], ['client_id' => 'CLIENT_ID']); diff --git a/spec/Listener/PayPalPaymentMethodListenerSpec.php b/spec/Listener/PayPalPaymentMethodListenerSpec.php index d32ca09f..22a9417f 100644 --- a/spec/Listener/PayPalPaymentMethodListenerSpec.php +++ b/spec/Listener/PayPalPaymentMethodListenerSpec.php @@ -22,13 +22,13 @@ function let( OnboardingInitiatorInterface $onboardingInitiator, UrlGeneratorInterface $urlGenerator, FlashBagInterface $flashBag, - PayPalPaymentMethodProviderInterface $payPalPaymentMethodProvider + PayPalPaymentMethodProviderInterface $payPalPaymentMethodProvider, ): void { $this->beConstructedWith( $onboardingInitiator, $urlGenerator, $flashBag, - $payPalPaymentMethodProvider + $payPalPaymentMethodProvider, ); } @@ -37,7 +37,7 @@ function it_initiates_onboarding_when_creating_a_supported_payment_method( PayPalPaymentMethodProviderInterface $payPalPaymentMethodProvider, ResourceControllerEvent $event, PaymentMethodInterface $paymentMethod, - GatewayConfigInterface $gatewayConfig + GatewayConfigInterface $gatewayConfig, ): void { $event->getSubject()->willReturn($paymentMethod); $paymentMethod->getGatewayConfig()->willReturn($gatewayConfig); @@ -71,7 +71,7 @@ function it_redirects_with_error_if_the_pay_pal_payment_method_already_exists( FlashBagInterface $flashBag, ResourceControllerEvent $event, PaymentMethodInterface $paymentMethod, - GatewayConfigInterface $gatewayConfig + GatewayConfigInterface $gatewayConfig, ): void { $event->getSubject()->willReturn($paymentMethod); $payPalPaymentMethodProvider->provide()->willReturn($paymentMethod); @@ -95,7 +95,7 @@ function it_does_nothing_when_creating_an_unsupported_payment_method( PayPalPaymentMethodProviderInterface $payPalPaymentMethodProvider, ResourceControllerEvent $event, PaymentMethodInterface $paymentMethod, - GatewayConfigInterface $gatewayConfig + GatewayConfigInterface $gatewayConfig, ): void { $event->getSubject()->willReturn($paymentMethod); $paymentMethod->getGatewayConfig()->willReturn($gatewayConfig); @@ -112,7 +112,7 @@ function it_does_nothing_when_creating_an_unsupported_payment_method( function it_does_nothing_if_payment_method_is_not_pay_pal( ResourceControllerEvent $event, PaymentMethodInterface $paymentMethod, - GatewayConfigInterface $gatewayConfig + GatewayConfigInterface $gatewayConfig, ): void { $event->getSubject()->willReturn($paymentMethod); $paymentMethod->getGatewayConfig()->willReturn($gatewayConfig); diff --git a/spec/Manager/PaymentStateManagerSpec.php b/spec/Manager/PaymentStateManagerSpec.php index 28ab1d42..f6caad5a 100644 --- a/spec/Manager/PaymentStateManagerSpec.php +++ b/spec/Manager/PaymentStateManagerSpec.php @@ -19,7 +19,7 @@ final class PaymentStateManagerSpec extends ObjectBehavior function let( FactoryInterface $stateMachineFactory, ObjectManager $paymentManager, - PaymentCompleteProcessorInterface $paymentCompleteProcessor + PaymentCompleteProcessorInterface $paymentCompleteProcessor, ): void { $this->beConstructedWith($stateMachineFactory, $paymentManager, $paymentCompleteProcessor); } @@ -33,7 +33,7 @@ function it_creates_payment( FactoryInterface $stateMachineFactory, ObjectManager $paymentManager, PaymentInterface $payment, - StateMachineInterface $stateMachine + StateMachineInterface $stateMachine, ): void { $stateMachineFactory->get($payment, PaymentTransitions::GRAPH)->willReturn($stateMachine); $stateMachine->apply(PaymentTransitions::TRANSITION_CREATE)->shouldBeCalled(); @@ -47,7 +47,7 @@ function it_completes_payment_if_its_completed_in_paypal( ObjectManager $paymentManager, PaymentCompleteProcessorInterface $paymentCompleteProcessor, PaymentInterface $payment, - StateMachineInterface $stateMachine + StateMachineInterface $stateMachine, ): void { $paymentCompleteProcessor->completePayment($payment); $payment->getDetails()->willReturn(['status' => StatusAction::STATUS_COMPLETED]); @@ -64,7 +64,7 @@ function it_processes_payment_if_its_processing_in_paypal_and_not_processing_in_ ObjectManager $paymentManager, PaymentCompleteProcessorInterface $paymentCompleteProcessor, PaymentInterface $payment, - StateMachineInterface $stateMachine + StateMachineInterface $stateMachine, ): void { $paymentCompleteProcessor->completePayment($payment); $payment->getDetails()->willReturn(['status' => StatusAction::STATUS_PROCESSING]); @@ -80,7 +80,7 @@ function it_processes_payment_if_its_processing_in_paypal_and_not_processing_in_ function it_does_nothing_if_payment_is_processing_in_paypal_but_already_processing_in_sylius( FactoryInterface $stateMachineFactory, PaymentCompleteProcessorInterface $paymentCompleteProcessor, - PaymentInterface $payment + PaymentInterface $payment, ): void { $paymentCompleteProcessor->completePayment($payment); $payment->getDetails()->willReturn(['status' => StatusAction::STATUS_PROCESSING]); @@ -95,7 +95,7 @@ function it_processes_payment( FactoryInterface $stateMachineFactory, ObjectManager $paymentManager, PaymentInterface $payment, - StateMachineInterface $stateMachine + StateMachineInterface $stateMachine, ): void { $stateMachineFactory->get($payment, PaymentTransitions::GRAPH)->willReturn($stateMachine); $stateMachine->apply(PaymentTransitions::TRANSITION_PROCESS)->shouldBeCalled(); @@ -108,7 +108,7 @@ function it_cancels_payment( FactoryInterface $stateMachineFactory, ObjectManager $paymentManager, PaymentInterface $payment, - StateMachineInterface $stateMachine + StateMachineInterface $stateMachine, ): void { $stateMachineFactory->get($payment, PaymentTransitions::GRAPH)->willReturn($stateMachine); $stateMachine->apply(PaymentTransitions::TRANSITION_CANCEL)->shouldBeCalled(); diff --git a/spec/Model/PayPalOrderSpec.php b/spec/Model/PayPalOrderSpec.php index cfa4a32b..37bc35b2 100644 --- a/spec/Model/PayPalOrderSpec.php +++ b/spec/Model/PayPalOrderSpec.php @@ -28,7 +28,7 @@ function let(OrderInterface $order, PayPalPurchaseUnit $payPalPurchaseUnit): voi public function it_returns_full_paypal_order_data( OrderInterface $order, PayPalPurchaseUnit $payPalPurchaseUnit, - AddressInterface $shippingAddress + AddressInterface $shippingAddress, ): void { $order->isShippingRequired()->willReturn(true); $order->getShippingAddress()->willReturn($shippingAddress); @@ -64,18 +64,18 @@ public function it_returns_full_paypal_order_data( ], 'soft_descriptor' => 'DESCRIPTION', 'items' => [ - ['test_item'] + ['test_item'], ], 'shipping' => [ 'name' => [ - 'full_name' => 'Gandalf The Grey' + 'full_name' => 'Gandalf The Grey', ], 'address' => [ 'address_line_1' => 'Hobbit St. 123', 'admin_area_2' => 'Minas Tirith', 'postal_code' => '000', - 'country_code' => 'US' - ] + 'country_code' => 'US', + ], ], ], ); @@ -114,31 +114,31 @@ public function it_returns_full_paypal_order_data( ], 'soft_descriptor' => 'DESCRIPTION', 'items' => [ - ['test_item'] + ['test_item'], ], 'shipping' => [ 'name' => [ - 'full_name' => 'Gandalf The Grey' + 'full_name' => 'Gandalf The Grey', ], 'address' => [ 'address_line_1' => 'Hobbit St. 123', 'admin_area_2' => 'Minas Tirith', 'postal_code' => '000', - 'country_code' => 'US' - ] + 'country_code' => 'US', + ], ], ], ], 'application_context' => [ - 'shipping_preference' => 'SET_PROVIDED_ADDRESS' - ] - ] + 'shipping_preference' => 'SET_PROVIDED_ADDRESS', + ], + ], ); } public function it_returns_paypal_order_data_without_shipping_address( OrderInterface $order, - PayPalPurchaseUnit $payPalPurchaseUnit + PayPalPurchaseUnit $payPalPurchaseUnit, ): void { $order->isShippingRequired()->willReturn(true); $order->getShippingAddress()->willReturn(null); @@ -174,7 +174,7 @@ public function it_returns_paypal_order_data_without_shipping_address( ], 'soft_descriptor' => 'DESCRIPTION', 'items' => [ - ['test_item'] + ['test_item'], ], ], ); @@ -213,20 +213,20 @@ public function it_returns_paypal_order_data_without_shipping_address( ], 'soft_descriptor' => 'DESCRIPTION', 'items' => [ - ['test_item'] + ['test_item'], ], ], ], 'application_context' => [ - 'shipping_preference' => 'GET_FROM_FILE' - ] - ] + 'shipping_preference' => 'GET_FROM_FILE', + ], + ], ); } public function it_returns_paypal_order_data_if_shipping_is_not_required( OrderInterface $order, - PayPalPurchaseUnit $payPalPurchaseUnit + PayPalPurchaseUnit $payPalPurchaseUnit, ): void { $order->isShippingRequired()->willReturn(false); $order->getShippingAddress()->shouldNotBeCalled(); @@ -262,7 +262,7 @@ public function it_returns_paypal_order_data_if_shipping_is_not_required( ], 'soft_descriptor' => 'DESCRIPTION', 'items' => [ - ['test_item'] + ['test_item'], ], ], ); @@ -301,14 +301,14 @@ public function it_returns_paypal_order_data_if_shipping_is_not_required( ], 'soft_descriptor' => 'DESCRIPTION', 'items' => [ - ['test_item'] + ['test_item'], ], ], ], 'application_context' => [ - 'shipping_preference' => 'NO_SHIPPING' - ] - ] + 'shipping_preference' => 'NO_SHIPPING', + ], + ], ); } } diff --git a/spec/Model/PayPalPurchaseUnitSpec.php b/spec/Model/PayPalPurchaseUnitSpec.php index a5227954..5b4c0daf 100644 --- a/spec/Model/PayPalPurchaseUnitSpec.php +++ b/spec/Model/PayPalPurchaseUnitSpec.php @@ -33,7 +33,7 @@ function let(AddressInterface $shippingAddress): void [['test_item']], true, $shippingAddress, - 'DESCRIPTION' + 'DESCRIPTION', ); } @@ -76,18 +76,18 @@ function it_returns_proper_paypal_purchase_unit(AddressInterface $shippingAddres ], 'soft_descriptor' => 'DESCRIPTION', 'items' => [ - ['test_item'] + ['test_item'], ], 'shipping' => [ 'name' => [ - 'full_name' => 'Gandalf The Grey' + 'full_name' => 'Gandalf The Grey', ], 'address' => [ 'address_line_1' => 'Hobbit St. 123', 'admin_area_2' => 'Minas Tirith', 'postal_code' => '000', - 'country_code' => 'US' - ] + 'country_code' => 'US', + ], ], ], ); @@ -107,7 +107,7 @@ function it_returns_proper_paypal_purchase_unit_if_shipping_is_not_required(Addr 'MERCHANT_ID', [['test_item']], false, - $shippingAddress + $shippingAddress, ); $this->toArray()->shouldReturn( @@ -141,7 +141,7 @@ function it_returns_proper_paypal_purchase_unit_if_shipping_is_not_required(Addr ], 'soft_descriptor' => 'Sylius PayPal Payment', 'items' => [ - ['test_item'] + ['test_item'], ], ], ); @@ -161,7 +161,7 @@ function it_returns_proper_paypal_purchase_unit_if_shipping_is_not_set(): void 'MERCHANT_ID', [['test_item']], false, - null + null, ); $this->toArray()->shouldReturn( @@ -195,7 +195,7 @@ function it_returns_proper_paypal_purchase_unit_if_shipping_is_not_set(): void ], 'soft_descriptor' => 'Sylius PayPal Payment', 'items' => [ - ['test_item'] + ['test_item'], ], ], ); diff --git a/spec/Onboarding/Initiator/OnboardingInitiatorSpec.php b/spec/Onboarding/Initiator/OnboardingInitiatorSpec.php index 73d6a041..5ddd772f 100644 --- a/spec/Onboarding/Initiator/OnboardingInitiatorSpec.php +++ b/spec/Onboarding/Initiator/OnboardingInitiatorSpec.php @@ -25,7 +25,7 @@ function it_implements_onboarding_initiator_interface(): void } function it_throws_an_exception_during_initialization_if_payment_method_is_not_supported( - PaymentMethodInterface $paymentMethod + PaymentMethodInterface $paymentMethod, ): void { $paymentMethod->getGatewayConfig()->willReturn(null); @@ -37,7 +37,7 @@ function it_throws_an_exception_during_initialization_if_payment_method_is_not_s function it_supports_paypal_payment_method_without_client_id_set( PaymentMethodInterface $paymentMethod, - GatewayConfigInterface $gatewayConfig + GatewayConfigInterface $gatewayConfig, ): void { $paymentMethod->getGatewayConfig()->willReturn($gatewayConfig); $gatewayConfig->getFactoryName()->willReturn('sylius.pay_pal'); @@ -48,7 +48,7 @@ function it_supports_paypal_payment_method_without_client_id_set( function it_does_not_support_paypal_payment_method_with_client_id_set( PaymentMethodInterface $paymentMethod, - GatewayConfigInterface $gatewayConfig + GatewayConfigInterface $gatewayConfig, ): void { $paymentMethod->getGatewayConfig()->willReturn($gatewayConfig); $gatewayConfig->getFactoryName()->willReturn('sylius.pay_pal'); @@ -59,7 +59,7 @@ function it_does_not_support_paypal_payment_method_with_client_id_set( function it_does_not_support_payment_method_with_invalid_gateway_factory_name( PaymentMethodInterface $paymentMethod, - GatewayConfigInterface $gatewayConfig + GatewayConfigInterface $gatewayConfig, ): void { $paymentMethod->getGatewayConfig()->willReturn($gatewayConfig); $gatewayConfig->getFactoryName()->willReturn('offline'); @@ -68,7 +68,7 @@ function it_does_not_support_payment_method_with_invalid_gateway_factory_name( } function it_does_not_support_payment_method_without_gateway_config( - PaymentMethodInterface $paymentMethod + PaymentMethodInterface $paymentMethod, ): void { $paymentMethod->getGatewayConfig()->willReturn(null); @@ -80,7 +80,7 @@ function it_returns_url_when_payment_is_valid( GatewayConfigInterface $gatewayConfig, Security $security, AdminUserInterface $adminUser, - UrlGeneratorInterface $urlGenerator + UrlGeneratorInterface $urlGenerator, ): void { $paymentMethod->getGatewayConfig()->willReturn($gatewayConfig); @@ -96,7 +96,7 @@ function it_returns_url_when_payment_is_valid( ; $this->initiate($paymentMethod)->shouldReturn( - 'https://paypal-url/partner-referrals/create?email=sylius%40sylius.com&return_url=%2Fadmin%2Fpayment-methods%2Fnew%2Fsylius.pay_pal' + 'https://paypal-url/partner-referrals/create?email=sylius%40sylius.com&return_url=%2Fadmin%2Fpayment-methods%2Fnew%2Fsylius.pay_pal', ); } } diff --git a/spec/Onboarding/Processor/BasicOnboardingProcessorSpec.php b/spec/Onboarding/Processor/BasicOnboardingProcessorSpec.php index 055e0232..4e575667 100644 --- a/spec/Onboarding/Processor/BasicOnboardingProcessorSpec.php +++ b/spec/Onboarding/Processor/BasicOnboardingProcessorSpec.php @@ -4,11 +4,11 @@ namespace spec\Sylius\PayPalPlugin\Onboarding\Processor; +use GuzzleHttp\ClientInterface as GuzzleClientInterface; use Payum\Core\Model\GatewayConfigInterface; use PhpSpec\ObjectBehavior; use Prophecy\Argument; use Psr\Http\Client\ClientInterface; -use GuzzleHttp\ClientInterface as GuzzleClientInterface; use Psr\Http\Message\RequestFactoryInterface; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\ResponseInterface; @@ -48,7 +48,7 @@ function it_processes_onboarding_for_supported_payment_method_and_request( StreamInterface $body, GatewayConfigInterface $gatewayConfig, PaymentMethodInterface $paymentMethod, - Request $request + Request $request, ): void { $gatewayConfig->getFactoryName()->willReturn('sylius.pay_pal'); $gatewayConfig->getConfig()->willReturn( @@ -57,7 +57,7 @@ function it_processes_onboarding_for_supported_payment_method_and_request( 'client_secret' => 'CLIENT-SECRET', 'sylius_merchant_id' => 'SYLIUS-MERCHANT-ID', 'merchant_id' => 'MERCHANT-ID', - ] + ], ); $gatewayConfig->setConfig( @@ -68,7 +68,7 @@ function it_processes_onboarding_for_supported_payment_method_and_request( 'sylius_merchant_id' => 'SYLIUS-MERCHANT-ID', 'merchant_id' => 'MERCHANT-ID', 'partner_attribution_id' => 'ATTRIBUTION-ID', - ] + ], )->shouldBeCalled(); $paymentMethod->getGatewayConfig()->willReturn($gatewayConfig); @@ -77,7 +77,7 @@ function it_processes_onboarding_for_supported_payment_method_and_request( $requestFactory->createRequest( 'GET', - 'https://paypal.facilitator.com/partner-referrals/check/ONBOARDING-ID' + 'https://paypal.facilitator.com/partner-referrals/check/ONBOARDING-ID', )->willReturn($apiRequest); $httpClient->sendRequest($apiRequest)->willReturn($response); @@ -87,7 +87,7 @@ function it_processes_onboarding_for_supported_payment_method_and_request( "client_secret":"CLIENT-SECRET", "sylius_merchant_id":"SYLIUS-MERCHANT-ID", "merchant_id":"MERCHANT-ID", - "partner_attribution_id":"ATTRIBUTION-ID"}' + "partner_attribution_id":"ATTRIBUTION-ID"}', ); $sellerWebhookRegistrar->register($paymentMethod)->shouldBeCalled(); @@ -102,7 +102,7 @@ function it_processes_onboarding_for_supported_payment_method_and_request_using_ StreamInterface $body, GatewayConfigInterface $gatewayConfig, PaymentMethodInterface $paymentMethod, - Request $request + Request $request, ): void { $this->beConstructedWith( $httpClient, @@ -117,7 +117,7 @@ function it_processes_onboarding_for_supported_payment_method_and_request_using_ 'client_secret' => 'CLIENT-SECRET', 'sylius_merchant_id' => 'SYLIUS-MERCHANT-ID', 'merchant_id' => 'MERCHANT-ID', - ] + ], ); $gatewayConfig->setConfig( @@ -128,7 +128,7 @@ function it_processes_onboarding_for_supported_payment_method_and_request_using_ 'sylius_merchant_id' => 'SYLIUS-MERCHANT-ID', 'merchant_id' => 'MERCHANT-ID', 'partner_attribution_id' => 'ATTRIBUTION-ID', - ] + ], )->shouldBeCalled(); $paymentMethod->getGatewayConfig()->willReturn($gatewayConfig); @@ -144,7 +144,7 @@ function it_processes_onboarding_for_supported_payment_method_and_request_using_ 'Content-Type' => 'application/json', 'Accept' => 'application/json', ], - ] + ], ) ->willReturn($response) ; @@ -155,7 +155,7 @@ function it_processes_onboarding_for_supported_payment_method_and_request_using_ "client_secret":"CLIENT-SECRET", "sylius_merchant_id":"SYLIUS-MERCHANT-ID", "merchant_id":"MERCHANT-ID", - "partner_attribution_id":"ATTRIBUTION-ID"}' + "partner_attribution_id":"ATTRIBUTION-ID"}', ); $sellerWebhookRegistrar->register($paymentMethod)->shouldBeCalled(); @@ -172,7 +172,7 @@ function it_processes_onboarding_for_supported_payment_method_with_not_granted_p StreamInterface $body, GatewayConfigInterface $gatewayConfig, PaymentMethodInterface $paymentMethod, - Request $request + Request $request, ): void { $gatewayConfig->getFactoryName()->willReturn('sylius.pay_pal'); $gatewayConfig->getConfig()->willReturn( @@ -181,7 +181,7 @@ function it_processes_onboarding_for_supported_payment_method_with_not_granted_p 'client_secret' => 'CLIENT-SECRET', 'sylius_merchant_id' => 'SYLIUS-MERCHANT-ID', 'merchant_id' => 'MERCHANT-ID', - ] + ], ); $paymentMethod->getGatewayConfig()->willReturn($gatewayConfig); @@ -190,7 +190,7 @@ function it_processes_onboarding_for_supported_payment_method_with_not_granted_p $requestFactory->createRequest( 'GET', - 'https://paypal.facilitator.com/partner-referrals/check/ONBOARDING-ID' + 'https://paypal.facilitator.com/partner-referrals/check/ONBOARDING-ID', )->willReturn($apiRequest); $httpClient->sendRequest($apiRequest)->willReturn($response); @@ -200,7 +200,7 @@ function it_processes_onboarding_for_supported_payment_method_with_not_granted_p "client_secret":"CLIENT-SECRET", "sylius_merchant_id":"SYLIUS-MERCHANT-ID", "merchant_id":"MERCHANT-ID", - "partner_attribution_id":"ATTRIBUTION-ID"}' + "partner_attribution_id":"ATTRIBUTION-ID"}', ); $paymentMethod->setEnabled(false)->shouldBeCalled(); @@ -212,7 +212,7 @@ function it_processes_onboarding_for_supported_payment_method_with_not_granted_p 'sylius_merchant_id' => 'SYLIUS-MERCHANT-ID', 'merchant_id' => 'MERCHANT-ID', 'partner_attribution_id' => 'ATTRIBUTION-ID', - ] + ], )->shouldBeCalled(); $sellerWebhookRegistrar->register($paymentMethod)->shouldBeCalled(); @@ -229,7 +229,7 @@ function it_processes_onboarding_for_supported_payment_method_with_not_granted_p StreamInterface $body, GatewayConfigInterface $gatewayConfig, PaymentMethodInterface $paymentMethod, - Request $request + Request $request, ): void { $this->beConstructedWith( $httpClient, @@ -244,7 +244,7 @@ function it_processes_onboarding_for_supported_payment_method_with_not_granted_p 'client_secret' => 'CLIENT-SECRET', 'sylius_merchant_id' => 'SYLIUS-MERCHANT-ID', 'merchant_id' => 'MERCHANT-ID', - ] + ], ); $paymentMethod->getGatewayConfig()->willReturn($gatewayConfig); @@ -260,7 +260,7 @@ function it_processes_onboarding_for_supported_payment_method_with_not_granted_p 'Content-Type' => 'application/json', 'Accept' => 'application/json', ], - ] + ], ) ->willReturn($response) ; @@ -271,7 +271,7 @@ function it_processes_onboarding_for_supported_payment_method_with_not_granted_p "client_secret":"CLIENT-SECRET", "sylius_merchant_id":"SYLIUS-MERCHANT-ID", "merchant_id":"MERCHANT-ID", - "partner_attribution_id":"ATTRIBUTION-ID"}' + "partner_attribution_id":"ATTRIBUTION-ID"}', ); $paymentMethod->setEnabled(false)->shouldBeCalled(); @@ -283,7 +283,7 @@ function it_processes_onboarding_for_supported_payment_method_with_not_granted_p 'sylius_merchant_id' => 'SYLIUS-MERCHANT-ID', 'merchant_id' => 'MERCHANT-ID', 'partner_attribution_id' => 'ATTRIBUTION-ID', - ] + ], )->shouldBeCalled(); $sellerWebhookRegistrar->register($paymentMethod)->shouldBeCalled(); @@ -300,7 +300,7 @@ function it_processes_onboarding_for_supported_payment_method_with_not_granted_p StreamInterface $body, GatewayConfigInterface $gatewayConfig, PaymentMethodInterface $paymentMethod, - Request $request + Request $request, ): void { $gatewayConfig->getFactoryName()->willReturn('sylius.pay_pal'); $gatewayConfig->getConfig()->willReturn( @@ -309,7 +309,7 @@ function it_processes_onboarding_for_supported_payment_method_with_not_granted_p 'client_secret' => 'CLIENT-SECRET', 'sylius_merchant_id' => 'SYLIUS-MERCHANT-ID', 'merchant_id' => 'MERCHANT-ID', - ] + ], ); $paymentMethod->getGatewayConfig()->willReturn($gatewayConfig); @@ -318,18 +318,17 @@ function it_processes_onboarding_for_supported_payment_method_with_not_granted_p $requestFactory->createRequest( 'GET', - 'https://paypal.facilitator.com/partner-referrals/check/ONBOARDING-ID' + 'https://paypal.facilitator.com/partner-referrals/check/ONBOARDING-ID', )->willReturn($apiRequest); $httpClient->sendRequest($apiRequest)->willReturn($response); - $response->getBody()->willReturn($body); $body->getContents()->willReturn( '{"client_id":"CLIENT-ID", "client_secret":"CLIENT-SECRET", "sylius_merchant_id":"SYLIUS-MERCHANT-ID", "merchant_id":"MERCHANT-ID", - "partner_attribution_id":"ATTRIBUTION-ID"}' + "partner_attribution_id":"ATTRIBUTION-ID"}', ); $paymentMethod->setEnabled(false)->shouldBeCalled(); @@ -341,7 +340,7 @@ function it_processes_onboarding_for_supported_payment_method_with_not_granted_p 'sylius_merchant_id' => 'SYLIUS-MERCHANT-ID', 'merchant_id' => 'MERCHANT-ID', 'partner_attribution_id' => 'ATTRIBUTION-ID', - ] + ], )->shouldBeCalled(); $sellerWebhookRegistrar->register($paymentMethod)->willThrow(PayPalWebhookUrlNotValidException::class); @@ -357,7 +356,7 @@ function it_processes_onboarding_for_supported_payment_method_with_not_granted_p StreamInterface $body, GatewayConfigInterface $gatewayConfig, PaymentMethodInterface $paymentMethod, - Request $request + Request $request, ): void { $this->beConstructedWith( $httpClient, @@ -372,7 +371,7 @@ function it_processes_onboarding_for_supported_payment_method_with_not_granted_p 'client_secret' => 'CLIENT-SECRET', 'sylius_merchant_id' => 'SYLIUS-MERCHANT-ID', 'merchant_id' => 'MERCHANT-ID', - ] + ], ); $paymentMethod->getGatewayConfig()->willReturn($gatewayConfig); @@ -388,7 +387,7 @@ function it_processes_onboarding_for_supported_payment_method_with_not_granted_p 'Content-Type' => 'application/json', 'Accept' => 'application/json', ], - ] + ], ) ->willReturn($response) ; @@ -399,7 +398,7 @@ function it_processes_onboarding_for_supported_payment_method_with_not_granted_p "client_secret":"CLIENT-SECRET", "sylius_merchant_id":"SYLIUS-MERCHANT-ID", "merchant_id":"MERCHANT-ID", - "partner_attribution_id":"ATTRIBUTION-ID"}' + "partner_attribution_id":"ATTRIBUTION-ID"}', ); $paymentMethod->setEnabled(false)->shouldBeCalled(); @@ -411,7 +410,7 @@ function it_processes_onboarding_for_supported_payment_method_with_not_granted_p 'sylius_merchant_id' => 'SYLIUS-MERCHANT-ID', 'merchant_id' => 'MERCHANT-ID', 'partner_attribution_id' => 'ATTRIBUTION-ID', - ] + ], )->shouldBeCalled(); $sellerWebhookRegistrar->register($paymentMethod)->willThrow(PayPalWebhookUrlNotValidException::class); @@ -422,7 +421,7 @@ function it_processes_onboarding_for_supported_payment_method_with_not_granted_p function it_throws_an_exception_when_trying_to_process_onboarding_for_unsupported_payment_method_or_request( PaymentMethodInterface $paymentMethod, - Request $request + Request $request, ): void { $this ->shouldThrow(\DomainException::class) @@ -434,7 +433,7 @@ function it_throws_an_exception_when_trying_to_process_onboarding_for_unsupporte GuzzleClientInterface $httpClient, SellerWebhookRegistrarInterface $sellerWebhookRegistrar, PaymentMethodInterface $paymentMethod, - Request $request + Request $request, ): void { $this->beConstructedWith( $httpClient, @@ -451,7 +450,7 @@ function it_throws_an_exception_when_trying_to_process_onboarding_for_unsupporte function it_supports_paypal_payment_method_with_request_containing_id( GatewayConfigInterface $gatewayConfig, PaymentMethod $paymentMethod, - Request $request + Request $request, ): void { $paymentMethod->getGatewayConfig()->willReturn($gatewayConfig); $gatewayConfig->getFactoryName()->willReturn('sylius.pay_pal'); @@ -466,7 +465,7 @@ function it_supports_paypal_payment_method_with_request_containing_id_using_guzz SellerWebhookRegistrarInterface $sellerWebhookRegistrar, GatewayConfigInterface $gatewayConfig, PaymentMethod $paymentMethod, - Request $request + Request $request, ): void { $this->beConstructedWith( $httpClient, @@ -484,7 +483,7 @@ function it_supports_paypal_payment_method_with_request_containing_id_using_guzz function it_does_not_support_payment_method_that_has_no_gateway_config( PaymentMethodInterface $paymentMethod, - Request $request + Request $request, ): void { $this->supports($paymentMethod, $request)->shouldReturn(false); } @@ -492,7 +491,7 @@ function it_does_not_support_payment_method_that_has_no_gateway_config( function it_does_not_support_payment_method_that_does_not_have_paypal_as_a_gateway_factory( GatewayConfigInterface $gatewayConfig, PaymentMethodInterface $paymentMethod, - Request $request + Request $request, ): void { $gatewayConfig->getFactoryName()->willReturn('random'); @@ -503,7 +502,7 @@ function it_does_not_support_payment_method_that_does_not_have_paypal_as_a_gatew function it_does_not_support_payment_method_that_has_client_id_is_not_set_on_request( GatewayConfigInterface $gatewayConfig, - PaymentMethodInterface $paymentMethod + PaymentMethodInterface $paymentMethod, ): void { $gatewayConfig->getFactoryName()->willReturn('sylius.pay_pal'); @@ -520,7 +519,7 @@ function it_throws_error_if_facilitator_data_is_not_loaded( StreamInterface $body, GatewayConfigInterface $gatewayConfig, PaymentMethodInterface $paymentMethod, - Request $request + Request $request, ): void { $gatewayConfig->getFactoryName()->willReturn('sylius.pay_pal'); @@ -530,7 +529,7 @@ function it_throws_error_if_facilitator_data_is_not_loaded( $requestFactory->createRequest( 'GET', - 'https://paypal.facilitator.com/partner-referrals/check/ONBOARDING-ID' + 'https://paypal.facilitator.com/partner-referrals/check/ONBOARDING-ID', )->willReturn($apiRequest); $httpClient->sendRequest($apiRequest)->willReturn($response); @@ -552,7 +551,7 @@ function it_throws_error_if_facilitator_data_is_not_loaded_using_guzzle_client( StreamInterface $body, GatewayConfigInterface $gatewayConfig, PaymentMethodInterface $paymentMethod, - Request $request + Request $request, ): void { $this->beConstructedWith( $httpClient, @@ -575,7 +574,7 @@ function it_throws_error_if_facilitator_data_is_not_loaded_using_guzzle_client( 'Content-Type' => 'application/json', 'Accept' => 'application/json', ], - ] + ], ) ->willReturn($response) ; diff --git a/spec/Payum/Action/AuthorizeActionSpec.php b/spec/Payum/Action/AuthorizeActionSpec.php index fdc34be8..1fbedcd5 100644 --- a/spec/Payum/Action/AuthorizeActionSpec.php +++ b/spec/Payum/Action/AuthorizeActionSpec.php @@ -31,7 +31,7 @@ function it_implements_action_interface(): void function it_marks_payment_as_created( Authorize $request, - PaymentInterface $payment + PaymentInterface $payment, ): void { $request->getModel()->willReturn($payment); $payment->setDetails(['status' => StatusAction::STATUS_CREATED])->shouldBeCalled(); @@ -49,7 +49,7 @@ function it_throws_an_exception_if_request_type_is_invalid(GetStatus $request): function it_supports_authorize_request_with_payment_as_first_model( Authorize $request, - PaymentInterface $payment + PaymentInterface $payment, ): void { $request->getModel()->willReturn($payment); diff --git a/spec/Payum/Action/CaptureActionSpec.php b/spec/Payum/Action/CaptureActionSpec.php index 750db99b..f274529a 100644 --- a/spec/Payum/Action/CaptureActionSpec.php +++ b/spec/Payum/Action/CaptureActionSpec.php @@ -31,7 +31,7 @@ final class CaptureActionSpec extends ObjectBehavior function let( CacheAuthorizeClientApiInterface $authorizeClientApi, CreateOrderApiInterface $createOrderApi, - UuidProviderInterface $uuidProvider + UuidProviderInterface $uuidProvider, ): void { $this->beConstructedWith($authorizeClientApi, $createOrderApi, $uuidProvider); } @@ -48,7 +48,7 @@ function it_authorizes_seller_send_create_order_request_and_sets_order_response_ OrderInterface $order, PaymentInterface $payment, PaymentMethodInterface $paymentMethod, - UuidProviderInterface $uuidProvider + UuidProviderInterface $uuidProvider, ): void { $request->getModel()->willReturn($payment); $payment->getMethod()->willReturn($paymentMethod); @@ -81,7 +81,7 @@ function it_throws_an_exception_if_request_type_is_invalid(GetStatus $request): function it_supports_capture_request_with_payment_as_first_model( Capture $request, - PaymentInterface $payment + PaymentInterface $payment, ): void { $request->getModel()->willReturn($payment); diff --git a/spec/Payum/Action/CompleteOrderActionSpec.php b/spec/Payum/Action/CompleteOrderActionSpec.php index f743bc39..7d7b36f5 100644 --- a/spec/Payum/Action/CompleteOrderActionSpec.php +++ b/spec/Payum/Action/CompleteOrderActionSpec.php @@ -39,7 +39,7 @@ function let( PayPalAddressProcessorInterface $payPalAddressProcessor, PaymentUpdaterInterface $payPalPaymentUpdater, StateResolverInterface $orderPaymentStateResolver, - PayPalItemDataProviderInterface $payPalItemsDataProvider + PayPalItemDataProviderInterface $payPalItemsDataProvider, ): void { $this->beConstructedWith( $authorizeClientApi, @@ -49,7 +49,7 @@ function let( $payPalAddressProcessor, $payPalPaymentUpdater, $orderPaymentStateResolver, - $payPalItemsDataProvider + $payPalItemsDataProvider, ); } @@ -65,7 +65,7 @@ function it_completes_order( CompleteOrder $request, PaymentInterface $payment, PaymentMethodInterface $paymentMethod, - OrderInterface $order + OrderInterface $order, ): void { $request->getModel()->willReturn($payment); $payment->getMethod()->willReturn($paymentMethod); @@ -76,7 +76,7 @@ function it_completes_order( $request->getOrderId()->willReturn('123123'); - $payment->getAmount()->willReturn(1000);; + $payment->getAmount()->willReturn(1000); $order->getTotal()->willReturn(1000); $completeOrderApi->complete('TOKEN', '123123')->shouldBeCalled(); @@ -84,8 +84,8 @@ function it_completes_order( 'status' => 'COMPLETED', 'id' => '123123', 'purchase_units' => [ - ['reference_id' => 'REFERENCE_ID'] - ] + ['reference_id' => 'REFERENCE_ID'], + ], ]); $payment->setDetails([ @@ -106,7 +106,7 @@ function it_completes_order_and_saves_transaction_id( CompleteOrder $request, PaymentInterface $payment, PaymentMethodInterface $paymentMethod, - OrderInterface $order + OrderInterface $order, ): void { $request->getModel()->willReturn($payment); $payment->getMethod()->willReturn($paymentMethod); @@ -117,7 +117,7 @@ function it_completes_order_and_saves_transaction_id( $request->getOrderId()->willReturn('123123'); - $payment->getAmount()->willReturn(1000);; + $payment->getAmount()->willReturn(1000); $order->getTotal()->willReturn(1000); $completeOrderApi->complete('TOKEN', '123123')->shouldBeCalled(); @@ -128,8 +128,8 @@ function it_completes_order_and_saves_transaction_id( [ 'reference_id' => 'REFERENCE_ID', 'payments' => ['captures' => [['id' => 'TRANSACTION_ID']]], - ] - ] + ], + ], ]); $payment->setDetails([ diff --git a/spec/Payum/Action/ResolveNextRouteActionSpec.php b/spec/Payum/Action/ResolveNextRouteActionSpec.php index 99a8ec61..6ab680e5 100644 --- a/spec/Payum/Action/ResolveNextRouteActionSpec.php +++ b/spec/Payum/Action/ResolveNextRouteActionSpec.php @@ -19,7 +19,7 @@ function it_executes_resolve_next_route_request_with_processing_payment( PaymentInterface $payment, OrderInterface $order, PaymentMethodInterface $paymentMethod, - GatewayConfigInterface $gatewayConfig + GatewayConfigInterface $gatewayConfig, ): void { $request->getFirstModel()->willReturn($payment); @@ -43,7 +43,7 @@ function it_executes_resolve_next_route_request_with_completed_payment( PaymentInterface $payment, OrderInterface $order, PaymentMethodInterface $paymentMethod, - GatewayConfigInterface $gatewayConfig + GatewayConfigInterface $gatewayConfig, ): void { $request->getFirstModel()->willReturn($payment); $payment->getOrder()->willReturn($order); @@ -63,7 +63,7 @@ function it_executes_resolve_next_route_request_with_some_other_payment( PaymentInterface $payment, OrderInterface $order, PaymentMethodInterface $paymentMethod, - GatewayConfigInterface $gatewayConfig + GatewayConfigInterface $gatewayConfig, ): void { $request->getFirstModel()->willReturn($payment); @@ -85,7 +85,7 @@ function it_supports_resolve_next_route_request_with_payment_as_first_model( ResolveNextRoute $request, PaymentInterface $payment, PaymentMethodInterface $paymentMethod, - GatewayConfigInterface $gatewayConfig + GatewayConfigInterface $gatewayConfig, ): void { $request->getFirstModel()->willReturn($payment); $payment->getMethod()->willReturn($paymentMethod); @@ -99,7 +99,7 @@ function it_does_not_support_payment_with_other_factory_name_than_pay_pal( ResolveNextRoute $request, PaymentInterface $payment, PaymentMethodInterface $paymentMethod, - GatewayConfigInterface $gatewayConfig + GatewayConfigInterface $gatewayConfig, ): void { $request->getFirstModel()->willReturn($payment); $payment->getMethod()->willReturn($paymentMethod); diff --git a/spec/Payum/Action/StatusActionSpec.php b/spec/Payum/Action/StatusActionSpec.php index 7bd5d8e8..fd6fd373 100644 --- a/spec/Payum/Action/StatusActionSpec.php +++ b/spec/Payum/Action/StatusActionSpec.php @@ -68,7 +68,7 @@ function it_throws_an_exception_if_request_is_not_supported(Capture $request): v function it_supports_get_status_request_with_payment_as_first_model( GetStatus $request, - PaymentInterface $payment + PaymentInterface $payment, ): void { $request->getFirstModel()->willReturn($payment); diff --git a/spec/Processor/AfterCheckoutOrderPaymentProcessorSpec.php b/spec/Processor/AfterCheckoutOrderPaymentProcessorSpec.php index 7a07975b..907e50bf 100644 --- a/spec/Processor/AfterCheckoutOrderPaymentProcessorSpec.php +++ b/spec/Processor/AfterCheckoutOrderPaymentProcessorSpec.php @@ -32,7 +32,7 @@ function it_implements_order_processor_interface(): void function it_does_nothing_if_order_is_not_completed( OrderProcessorInterface $baseOrderPaymentProcessor, - OrderInterface $order + OrderInterface $order, ): void { $order->getCheckoutState()->willReturn(OrderCheckoutStates::STATE_ADDRESSED); @@ -43,7 +43,7 @@ function it_does_nothing_if_order_is_not_completed( function it_uses_processor_if_order_is_completed( OrderProcessorInterface $baseOrderPaymentProcessor, - OrderInterface $order + OrderInterface $order, ): void { $order->getCheckoutState()->willReturn(OrderCheckoutStates::STATE_COMPLETED); diff --git a/spec/Processor/OrderPaymentProcessorSpec.php b/spec/Processor/OrderPaymentProcessorSpec.php index 9c588fe5..920ec679 100644 --- a/spec/Processor/OrderPaymentProcessorSpec.php +++ b/spec/Processor/OrderPaymentProcessorSpec.php @@ -41,7 +41,7 @@ function it_does_nothing_if_there_is_a_pay_pal_processing_captured_payment( OrderInterface $order, PaymentInterface $payment, PaymentMethodInterface $paymentMethod, - GatewayConfigInterface $gatewayConfig + GatewayConfigInterface $gatewayConfig, ): void { $order->getLastPayment(PaymentInterface::STATE_PROCESSING)->willReturn($payment); $payment->getDetails()->willReturn(['status' => 'CAPTURED']); @@ -56,7 +56,7 @@ function it_does_nothing_if_there_is_a_pay_pal_processing_captured_payment( function it_processes_order_if_there_is_no_processing_payment( OrderProcessorInterface $baseOrderProcessor, - OrderInterface $order + OrderInterface $order, ): void { $order->getLastPayment(PaymentInterface::STATE_PROCESSING)->willReturn(null); @@ -70,7 +70,7 @@ function it_processes_order_if_the_processing_payment_is_not_captured( OrderInterface $order, PaymentInterface $payment, PaymentMethodInterface $paymentMethod, - GatewayConfigInterface $gatewayConfig + GatewayConfigInterface $gatewayConfig, ): void { $order->getLastPayment(PaymentInterface::STATE_PROCESSING)->willReturn($payment); $payment->getDetails()->willReturn(['status' => 'CANCELLED']); @@ -91,7 +91,7 @@ function it_cancels_payment_and_processes_order_if_the_processing_payment_has_me PaymentInterface $payment, PaymentMethodInterface $paymentMethod, GatewayConfigInterface $gatewayConfig, - StateMachineInterface $stateMachine + StateMachineInterface $stateMachine, ): void { $order->getLastPayment(PaymentInterface::STATE_PROCESSING)->willReturn($payment); $payment->getDetails()->willReturn(['status' => 'CANCELLED']); diff --git a/spec/Processor/PayPalAddressProcessorSpec.php b/spec/Processor/PayPalAddressProcessorSpec.php index 5bd3cf24..b8e82cbe 100644 --- a/spec/Processor/PayPalAddressProcessorSpec.php +++ b/spec/Processor/PayPalAddressProcessorSpec.php @@ -25,7 +25,7 @@ function it_implements_pay_pal_address_processor_interface(): void function it_updates_order_address( OrderInterface $order, AddressInterface $orderAddress, - ObjectManager $objectManager + ObjectManager $objectManager, ): void { $order->getShippingAddress()->willReturn($orderAddress); @@ -43,14 +43,14 @@ function it_updates_order_address( 'postal_code' => '10001', 'country_code' => 'US', ], - $order + $order, ); } function it_updates_order_address_with_two_address_lines( OrderInterface $order, AddressInterface $orderAddress, - ObjectManager $objectManager + ObjectManager $objectManager, ): void { $order->getShippingAddress()->willReturn($orderAddress); @@ -69,14 +69,14 @@ function it_updates_order_address_with_two_address_lines( 'postal_code' => '10001', 'country_code' => 'US', ], - $order + $order, ); } function it_throws_an_exception_if_address_data_is_missing( OrderInterface $order, AddressInterface $orderAddress, - ObjectManager $objectManager + ObjectManager $objectManager, ): void { $order->getShippingAddress()->willReturn($orderAddress); diff --git a/spec/Processor/PayPalOrderCompleteProcessorSpec.php b/spec/Processor/PayPalOrderCompleteProcessorSpec.php index 6ed54bdb..234fdb2e 100644 --- a/spec/Processor/PayPalOrderCompleteProcessorSpec.php +++ b/spec/Processor/PayPalOrderCompleteProcessorSpec.php @@ -33,7 +33,7 @@ function it_completes_pay_pal_order( OrderInterface $order, PaymentInterface $payment, PaymentMethodInterface $paymentMethod, - GatewayConfigInterface $gatewayConfig + GatewayConfigInterface $gatewayConfig, ): void { $order->getLastPayment(PaymentInterface::STATE_PROCESSING)->willReturn($payment); @@ -51,7 +51,7 @@ function it_does_nothing_if_processing_payment_is_not_pay_pal( OrderInterface $order, PaymentInterface $payment, PaymentMethodInterface $paymentMethod, - GatewayConfigInterface $gatewayConfig + GatewayConfigInterface $gatewayConfig, ): void { $order->getLastPayment(PaymentInterface::STATE_PROCESSING)->willReturn($payment); @@ -66,7 +66,7 @@ function it_does_nothing_if_processing_payment_is_not_pay_pal( function it_does_nothing_if_there_is_no_processing_payment_for_the_order( PaymentStateManagerInterface $paymentStateManager, - OrderInterface $order + OrderInterface $order, ): void { $order->getLastPayment(PaymentInterface::STATE_PROCESSING)->willReturn(null); diff --git a/spec/Processor/PayPalPaymentCompleteProcessorSpec.php b/spec/Processor/PayPalPaymentCompleteProcessorSpec.php index 2e4302cc..e22a2f43 100644 --- a/spec/Processor/PayPalPaymentCompleteProcessorSpec.php +++ b/spec/Processor/PayPalPaymentCompleteProcessorSpec.php @@ -42,7 +42,7 @@ function it_completes_payment_in_pay_pal( PaymentMethodInterface $paymentMethod, GatewayConfigInterface $gatewayConfig, GatewayInterface $gateway, - CompleteOrderPaymentResolverInterface $completeOrderPaymentResolver + CompleteOrderPaymentResolverInterface $completeOrderPaymentResolver, ): void { $payment->getDetails()->willReturn(['paypal_order_id' => '123123']); @@ -61,7 +61,7 @@ function it_completes_payment_in_pay_pal( function it_does_nothing_if_payment_has_no_pay_pal_order_id_set( Payum $payum, PaymentInterface $payment, - GatewayInterface $gateway + GatewayInterface $gateway, ): void { $payment->getDetails()->willReturn([]); diff --git a/spec/Processor/PayPalPaymentRefundProcessorSpec.php b/spec/Processor/PayPalPaymentRefundProcessorSpec.php index 075695b6..aeaf9cf7 100644 --- a/spec/Processor/PayPalPaymentRefundProcessorSpec.php +++ b/spec/Processor/PayPalPaymentRefundProcessorSpec.php @@ -35,14 +35,14 @@ function let( OrderDetailsApiInterface $orderDetailsApi, RefundPaymentApiInterface $refundOrderApi, PayPalAuthAssertionGeneratorInterface $payPalAuthAssertionGenerator, - RefundReferenceNumberProviderInterface $refundReferenceNumberProvider + RefundReferenceNumberProviderInterface $refundReferenceNumberProvider, ): void { $this->beConstructedWith( $authorizeClientApi, $orderDetailsApi, $refundOrderApi, $payPalAuthAssertionGenerator, - $refundReferenceNumberProvider + $refundReferenceNumberProvider, ); } @@ -60,7 +60,7 @@ function it_fully_refunds_payment_in_pay_pal( PaymentInterface $payment, PaymentMethodInterface $paymentMethod, GatewayConfigInterface $gatewayConfig, - OrderInterface $order + OrderInterface $order, ): void { $payment->getMethod()->willReturn($paymentMethod); $paymentMethod->getGatewayConfig()->willReturn($gatewayConfig); @@ -92,7 +92,7 @@ function it_does_nothing_if_payment_is_not_pay_pal( RefundPaymentApiInterface $refundOrderApi, PaymentInterface $payment, PaymentMethodInterface $paymentMethod, - GatewayConfigInterface $gatewayConfig + GatewayConfigInterface $gatewayConfig, ): void { $payment->getMethod()->willReturn($paymentMethod); $paymentMethod->getGatewayConfig()->willReturn($gatewayConfig); @@ -108,7 +108,7 @@ function it_does_nothing_if_payment_is_payment_has_not_pay_pal_order_id( RefundPaymentApiInterface $refundOrderApi, PaymentInterface $payment, PaymentMethodInterface $paymentMethod, - GatewayConfigInterface $gatewayConfig + GatewayConfigInterface $gatewayConfig, ): void { $payment->getMethod()->willReturn($paymentMethod); $paymentMethod->getGatewayConfig()->willReturn($gatewayConfig); @@ -130,7 +130,7 @@ function it_throws_exception_if_something_went_wrong_during_refunding_payment( PaymentInterface $payment, PaymentMethodInterface $paymentMethod, GatewayConfigInterface $gatewayConfig, - OrderInterface $order + OrderInterface $order, ): void { $payment->getMethod()->willReturn($paymentMethod); $paymentMethod->getGatewayConfig()->willReturn($gatewayConfig); diff --git a/spec/Processor/UiPayPalPaymentRefundProcessorSpec.php b/spec/Processor/UiPayPalPaymentRefundProcessorSpec.php index 657323dd..41232c18 100644 --- a/spec/Processor/UiPayPalPaymentRefundProcessorSpec.php +++ b/spec/Processor/UiPayPalPaymentRefundProcessorSpec.php @@ -33,7 +33,7 @@ function it_implements_payment_refund_processor_interface(): void function it_throws_exception_if_refund_has_fails( PaymentRefundProcessorInterface $paymentRefundProcessor, - PaymentInterface $payment + PaymentInterface $payment, ): void { $paymentRefundProcessor->refund($payment)->willThrow(PayPalOrderRefundException::class); @@ -42,7 +42,7 @@ function it_throws_exception_if_refund_has_fails( function it_does_nothing_if_refund_was_successful( PaymentRefundProcessorInterface $paymentRefundProcessor, - PaymentInterface $payment + PaymentInterface $payment, ): void { $paymentRefundProcessor->refund($payment)->shouldBeCalled(); diff --git a/spec/Provider/AvailableCountriesProviderSpec.php b/spec/Provider/AvailableCountriesProviderSpec.php index 9d39f09b..a2fb8807 100644 --- a/spec/Provider/AvailableCountriesProviderSpec.php +++ b/spec/Provider/AvailableCountriesProviderSpec.php @@ -25,7 +25,7 @@ function it_provides_available_countries_if_channel_does_not_have_any( RepositoryInterface $countryRepository, ChannelContextInterface $channelContext, ChannelInterface $channel, - Collection $collection + Collection $collection, ): void { $channel->getCountries()->willReturn($collection); @@ -46,7 +46,7 @@ function it_provides_available_countries_if_channel_contains_countries( RepositoryInterface $countryRepository, ChannelContextInterface $channelContext, ChannelInterface $channel, - Collection $collection + Collection $collection, ): void { $channel->getCountries()->willReturn($collection); $collection->toArray()->willReturn([$countryOne, $countryTwo]); diff --git a/spec/Provider/OrderItemNonNeutralTaxesProviderSpec.php b/spec/Provider/OrderItemNonNeutralTaxesProviderSpec.php index f5aabc88..fe15cc05 100644 --- a/spec/Provider/OrderItemNonNeutralTaxesProviderSpec.php +++ b/spec/Provider/OrderItemNonNeutralTaxesProviderSpec.php @@ -16,7 +16,7 @@ function it_provides_non_neutral_tax_based_on_given_order_item( OrderItemInterface $orderItem, AdjustmentInterface $adjustment, OrderItemUnitInterface $orderItemUnit, - AdjustmentInterface $unitAdjustment + AdjustmentInterface $unitAdjustment, ): void { $orderItem->getAdjustments(AdjustmentInterface::TAX_ADJUSTMENT) ->willReturn(new ArrayCollection([$adjustment->getWrappedObject()])); diff --git a/spec/Provider/OrderProviderSpec.php b/spec/Provider/OrderProviderSpec.php index 76cebbd6..f261dbe5 100644 --- a/spec/Provider/OrderProviderSpec.php +++ b/spec/Provider/OrderProviderSpec.php @@ -24,7 +24,7 @@ function it_is_an_order_provider(): void function it_provides_order_by_given_id( OrderRepositoryInterface $orderRepository, - OrderInterface $order + OrderInterface $order, ): void { $orderRepository->find(420)->willReturn($order); @@ -33,7 +33,7 @@ function it_provides_order_by_given_id( function it_provides_order_by_given_token( OrderRepositoryInterface $orderRepository, - OrderInterface $order + OrderInterface $order, ): void { $orderRepository->findOneByTokenValue('token-str')->willReturn($order); @@ -41,7 +41,7 @@ function it_provides_order_by_given_token( } function it_throws_error_if_order_is_not_found_by_id( - OrderRepositoryInterface $orderRepository + OrderRepositoryInterface $orderRepository, ): void { $orderRepository->find(123)->willReturn(null); @@ -49,7 +49,7 @@ function it_throws_error_if_order_is_not_found_by_id( } function it_throws_error_if_order_is_not_found_by_token( - OrderRepositoryInterface $orderRepository + OrderRepositoryInterface $orderRepository, ): void { $orderRepository->findOneByTokenValue('token')->willReturn(null); diff --git a/spec/Provider/PayPalConfigurationProviderSpec.php b/spec/Provider/PayPalConfigurationProviderSpec.php index d4191937..644bacf7 100644 --- a/spec/Provider/PayPalConfigurationProviderSpec.php +++ b/spec/Provider/PayPalConfigurationProviderSpec.php @@ -38,7 +38,7 @@ function it_returns_client_id_from_payment_method_config( PaymentMethodInterface $otherPaymentMethod, GatewayConfigInterface $payPalGatewayConfig, GatewayConfigInterface $otherGatewayConfig, - ChannelInterface $channel + ChannelInterface $channel, ): void { $paymentMethodRepository ->findEnabledForChannel($channel) @@ -62,7 +62,7 @@ function it_returns_partner_attribution_id_from_payment_method_config( PaymentMethodInterface $otherPaymentMethod, GatewayConfigInterface $payPalGatewayConfig, GatewayConfigInterface $otherGatewayConfig, - ChannelInterface $channel + ChannelInterface $channel, ): void { $paymentMethodRepository ->findEnabledForChannel($channel) @@ -84,7 +84,7 @@ function it_throws_an_exception_if_there_is_no_pay_pal_payment_method_defined( PaymentMethodRepositoryInterface $paymentMethodRepository, PaymentMethodInterface $otherPaymentMethod, GatewayConfigInterface $otherGatewayConfig, - ChannelInterface $channel + ChannelInterface $channel, ): void { $paymentMethodRepository->findEnabledForChannel($channel)->willReturn([$otherPaymentMethod]); $otherPaymentMethod->getGatewayConfig()->willReturn($otherGatewayConfig); @@ -107,7 +107,7 @@ function it_throws_an_exception_if_there_is_no_client_id_on_pay_pal_payment_meth PaymentMethodInterface $otherPaymentMethod, GatewayConfigInterface $payPalGatewayConfig, GatewayConfigInterface $otherGatewayConfig, - ChannelInterface $channel + ChannelInterface $channel, ): void { $paymentMethodRepository ->findEnabledForChannel($channel) @@ -134,7 +134,7 @@ function it_throws_an_exception_if_there_is_no_partner_attribution_id_on_pay_pal PaymentMethodInterface $otherPaymentMethod, GatewayConfigInterface $payPalGatewayConfig, GatewayConfigInterface $otherGatewayConfig, - ChannelInterface $channel + ChannelInterface $channel, ): void { $paymentMethodRepository ->findEnabledForChannel($channel) diff --git a/spec/Provider/PayPalItemDataProviderSpec.php b/spec/Provider/PayPalItemDataProviderSpec.php index d4e0430e..daf980f1 100644 --- a/spec/Provider/PayPalItemDataProviderSpec.php +++ b/spec/Provider/PayPalItemDataProviderSpec.php @@ -20,7 +20,7 @@ function let(OrderItemNonNeutralTaxesProviderInterface $orderItemNonNeutralTaxes function it_returns_array_of_items_with_tax( OrderInterface $order, OrderItemInterface $orderItem, - OrderItemNonNeutralTaxesProviderInterface $orderItemNonNeutralTaxesProvider + OrderItemNonNeutralTaxesProviderInterface $orderItemNonNeutralTaxesProvider, ): void { $order->getItems()->willReturn(new ArrayCollection([$orderItem->getWrappedObject()])); $orderItem->getProductName()->willReturn('PRODUCT_ONE'); @@ -49,14 +49,14 @@ function it_returns_array_of_items_with_tax( ], 'total_item_value' => '20.00', 'total_tax' => '2.00', - ] + ], ); } function it_returns_array_of_items_with_different_quantities_with_tax( OrderInterface $order, OrderItemInterface $orderItem, - OrderItemNonNeutralTaxesProviderInterface $orderItemNonNeutralTaxesProvider + OrderItemNonNeutralTaxesProviderInterface $orderItemNonNeutralTaxesProvider, ): void { $order->getItems()->willReturn(new ArrayCollection([$orderItem->getWrappedObject()])); $orderItem->getProductName()->willReturn('PRODUCT_ONE'); @@ -116,7 +116,7 @@ function it_returns_array_of_items_with_different_quantities_with_tax( function it_returns_array_of_items_with_different_quantities_without_tax( OrderInterface $order, OrderItemInterface $orderItem, - OrderItemNonNeutralTaxesProviderInterface $orderItemNonNeutralTaxesProvider + OrderItemNonNeutralTaxesProviderInterface $orderItemNonNeutralTaxesProvider, ): void { $order->getItems()->willReturn(new ArrayCollection([$orderItem->getWrappedObject()])); $orderItem->getProductName()->willReturn('PRODUCT_ONE'); @@ -153,7 +153,7 @@ function it_returns_array_of_different_items_with_different_quantities_without_t OrderInterface $order, OrderItemInterface $orderItemOne, OrderItemInterface $orderItemTwo, - OrderItemNonNeutralTaxesProviderInterface $orderItemNonNeutralTaxesProvider + OrderItemNonNeutralTaxesProviderInterface $orderItemNonNeutralTaxesProvider, ): void { $order->getItems() ->willReturn(new ArrayCollection([$orderItemOne->getWrappedObject(), $orderItemTwo->getWrappedObject()])); @@ -208,7 +208,7 @@ function it_returns_array_of_different_items_with_different_quantities_with_tax( OrderInterface $order, OrderItemInterface $orderItemOne, OrderItemInterface $orderItemTwo, - OrderItemNonNeutralTaxesProviderInterface $orderItemNonNeutralTaxesProvider + OrderItemNonNeutralTaxesProviderInterface $orderItemNonNeutralTaxesProvider, ): void { $order->getItems()->willReturn(new ArrayCollection([$orderItemOne->getWrappedObject(), $orderItemTwo->getWrappedObject()])); $orderItemOne->getProductName()->willReturn('PRODUCT_ONE'); diff --git a/spec/Provider/PayPalRefundDataProviderSpec.php b/spec/Provider/PayPalRefundDataProviderSpec.php index 2686019c..e5c470c3 100644 --- a/spec/Provider/PayPalRefundDataProviderSpec.php +++ b/spec/Provider/PayPalRefundDataProviderSpec.php @@ -16,7 +16,7 @@ final class PayPalRefundDataProviderSpec extends ObjectBehavior public function let( CacheAuthorizeClientApiInterface $authorizeClientApi, GenericApiInterface $genericApi, - PayPalPaymentMethodProviderInterface $payPalPaymentMethodProvider + PayPalPaymentMethodProviderInterface $payPalPaymentMethodProvider, ) { $this->beConstructedWith($authorizeClientApi, $genericApi, $payPalPaymentMethodProvider); } @@ -25,7 +25,7 @@ public function it_provides_data_from_provided_url( PayPalPaymentMethodProviderInterface $payPalPaymentMethodProvider, PaymentMethodInterface $paymentMethod, CacheAuthorizeClientApiInterface $authorizeClientApi, - GenericApiInterface $genericApi + GenericApiInterface $genericApi, ): void { $payPalPaymentMethodProvider->provide()->willReturn($paymentMethod); $authorizeClientApi->authorize($paymentMethod)->willReturn('TOKEN'); @@ -47,7 +47,7 @@ public function it_throws_error_if_paypal_data_doesnt_contain_url( PayPalPaymentMethodProviderInterface $payPalPaymentMethodProvider, PaymentMethodInterface $paymentMethod, CacheAuthorizeClientApiInterface $authorizeClientApi, - GenericApiInterface $genericApi + GenericApiInterface $genericApi, ): void { $payPalPaymentMethodProvider->provide()->willReturn($paymentMethod); $authorizeClientApi->authorize($paymentMethod)->willReturn('TOKEN'); diff --git a/spec/Provider/PaymentProviderSpec.php b/spec/Provider/PaymentProviderSpec.php index 128ea4dc..91fc3ee3 100644 --- a/spec/Provider/PaymentProviderSpec.php +++ b/spec/Provider/PaymentProviderSpec.php @@ -35,7 +35,7 @@ function it_returns_payment_for_given_pay_pal_order_id( PaymentRepositoryInterface $paymentRepository, PaymentInterface $firstPayment, PaymentInterface $secondPayment, - PaymentInterface $thirdPayment + PaymentInterface $thirdPayment, ): void { $paymentRepository->findAll()->willReturn([$firstPayment, $secondPayment, $thirdPayment]); @@ -50,7 +50,7 @@ function it_throws_exception_if_there_is_no_payment_with_given_paypal_order_id( PaymentRepositoryInterface $paymentRepository, PaymentInterface $firstPayment, PaymentInterface $secondPayment, - PaymentInterface $thirdPayment + PaymentInterface $thirdPayment, ): void { $paymentRepository->findAll()->willReturn([$firstPayment, $secondPayment, $thirdPayment]); diff --git a/spec/Registrar/SellerWebhookRegistrarSpec.php b/spec/Registrar/SellerWebhookRegistrarSpec.php index 8f8a0792..1a386aed 100644 --- a/spec/Registrar/SellerWebhookRegistrarSpec.php +++ b/spec/Registrar/SellerWebhookRegistrarSpec.php @@ -27,7 +27,7 @@ final class SellerWebhookRegistrarSpec extends ObjectBehavior function let( AuthorizeClientApiInterface $authorizeClientApi, UrlGeneratorInterface $urlGenerator, - WebhookApiInterface $webhookApi + WebhookApiInterface $webhookApi, ): void { $this->beConstructedWith($authorizeClientApi, $urlGenerator, $webhookApi); } @@ -42,7 +42,7 @@ function it_registers_sellers_webhook( UrlGeneratorInterface $urlGenerator, WebhookApiInterface $webhookApi, PaymentMethodInterface $paymentMethod, - GatewayConfigInterface $gatewayConfig + GatewayConfigInterface $gatewayConfig, ): void { $paymentMethod->getGatewayConfig()->willReturn($gatewayConfig); $gatewayConfig->getConfig()->willReturn(['client_id' => 'CLIENT_ID', 'client_secret' => 'CLIENT_SECRET']); @@ -63,7 +63,7 @@ function it_throws_exception_if_webhook_could_not_be_registered( UrlGeneratorInterface $urlGenerator, WebhookApiInterface $webhookApi, PaymentMethodInterface $paymentMethod, - GatewayConfigInterface $gatewayConfig + GatewayConfigInterface $gatewayConfig, ): void { $paymentMethod->getGatewayConfig()->willReturn($gatewayConfig); $gatewayConfig->getConfig()->willReturn(['client_id' => 'CLIENT_ID', 'client_secret' => 'CLIENT_SECRET']); diff --git a/spec/Resolver/CapturePaymentResolverSpec.php b/spec/Resolver/CapturePaymentResolverSpec.php index b46f2930..1665779f 100644 --- a/spec/Resolver/CapturePaymentResolverSpec.php +++ b/spec/Resolver/CapturePaymentResolverSpec.php @@ -31,7 +31,7 @@ function it_executes_capture_action_on_payment( PaymentMethodInterface $paymentMethod, GatewayConfigInterface $gatewayConfig, GatewayInterface $gateway, - Payum $payum + Payum $payum, ): void { $payment->getMethod()->willReturn($paymentMethod); diff --git a/spec/Resolver/CompleteOrderPaymentResolverSpec.php b/spec/Resolver/CompleteOrderPaymentResolverSpec.php index 27f04446..0ac64e9d 100644 --- a/spec/Resolver/CompleteOrderPaymentResolverSpec.php +++ b/spec/Resolver/CompleteOrderPaymentResolverSpec.php @@ -31,7 +31,7 @@ function it_executes_complete_order_action_on_payment( PaymentMethodInterface $paymentMethod, GatewayConfigInterface $gatewayConfig, GatewayInterface $gateway, - Payum $payum + Payum $payum, ): void { $payment->getMethod()->willReturn($paymentMethod); @@ -41,13 +41,15 @@ function it_executes_complete_order_action_on_payment( $payum->getGateway('gateway-12')->willReturn($gateway); $gateway->execute( - Argument::that(function (CompleteOrder $request) use ($payment): bool { - return - $request->getModel() === $payment->getWrappedObject() && - $request->getOrderId() === 'paypal-order-id' - ; - }, - ))->shouldBeCalled(); + Argument::that( + function (CompleteOrder $request) use ($payment): bool { + return + $request->getModel() === $payment->getWrappedObject() && + $request->getOrderId() === 'paypal-order-id' + ; + }, + ), + )->shouldBeCalled(); $this->resolve($payment, 'paypal-order-id'); } diff --git a/spec/Resolver/PayPalDefaultPaymentMethodResolverSpec.php b/spec/Resolver/PayPalDefaultPaymentMethodResolverSpec.php index 38f43c45..e9aad5f6 100644 --- a/spec/Resolver/PayPalDefaultPaymentMethodResolverSpec.php +++ b/spec/Resolver/PayPalDefaultPaymentMethodResolverSpec.php @@ -43,7 +43,7 @@ function it_returns_prioritised_payment_method_for_channel( GatewayConfigInterface $firstGatewayConfig, GatewayConfigInterface $secondGatewayConfig, PaymentInterface $subject, - OrderInterface $order + OrderInterface $order, ): void { $firstPayment->getGatewayConfig()->willReturn($firstGatewayConfig); $firstGatewayConfig->getFactoryName()->willReturn('new.payment'); @@ -67,7 +67,7 @@ function it_returns_first_available_payment_method_if_priotitised_payment_method GatewayConfigInterface $firstGatewayConfig, GatewayConfigInterface $secondGatewayConfig, PaymentInterface $subject, - OrderInterface $order + OrderInterface $order, ): void { $firstPayment->getGatewayConfig()->willReturn($firstGatewayConfig); $firstGatewayConfig->getFactoryName()->willReturn('payment1'); @@ -87,7 +87,7 @@ function it_throws_error_if_there_is_no_available_payment( PaymentMethodRepositoryInterface $paymentMethodRepository, ChannelInterface $channel, PaymentInterface $subject, - OrderInterface $order + OrderInterface $order, ): void { $paymentMethodRepository->findEnabledForChannel($channel)->willReturn([]); diff --git a/spec/Resolver/PayPalPrioritisingPaymentMethodsResolverSpec.php b/spec/Resolver/PayPalPrioritisingPaymentMethodsResolverSpec.php index 9d6126e8..1c50f9f7 100644 --- a/spec/Resolver/PayPalPrioritisingPaymentMethodsResolverSpec.php +++ b/spec/Resolver/PayPalPrioritisingPaymentMethodsResolverSpec.php @@ -30,7 +30,7 @@ function it_prioritizes_payment_method( PaymentMethodInterface $thirdPayment, GatewayConfigInterface $firstGatewayConfig, GatewayConfigInterface $secondGatewayConfig, - GatewayConfigInterface $thirdGatewayConfig + GatewayConfigInterface $thirdGatewayConfig, ): void { $firstPayment->getGatewayConfig()->willReturn($firstGatewayConfig); $firstGatewayConfig->getFactoryName()->willReturn('payment1'); @@ -44,7 +44,7 @@ function it_prioritizes_payment_method( $paymentMethodsResolver->getSupportedMethods($payment)->willReturn([$firstPayment, $secondPayment, $thirdPayment]); $this->getSupportedMethods($payment)->shouldReturn( - [$thirdPayment, $firstPayment, $secondPayment] + [$thirdPayment, $firstPayment, $secondPayment], ); } @@ -56,7 +56,7 @@ function it_does_nothing_if_prioritized_payment_is_not_available( PaymentMethodInterface $thirdPayment, GatewayConfigInterface $firstGatewayConfig, GatewayConfigInterface $secondGatewayConfig, - GatewayConfigInterface $thirdGatewayConfig + GatewayConfigInterface $thirdGatewayConfig, ): void { $firstPayment->getGatewayConfig()->willReturn($firstGatewayConfig); $firstGatewayConfig->getFactoryName()->willReturn('payment1'); @@ -70,7 +70,7 @@ function it_does_nothing_if_prioritized_payment_is_not_available( $paymentMethodsResolver->getSupportedMethods($payment)->willReturn([$firstPayment, $secondPayment, $thirdPayment]); $this->getSupportedMethods($payment)->shouldReturn( - [$firstPayment, $secondPayment, $thirdPayment] + [$firstPayment, $secondPayment, $thirdPayment], ); } } diff --git a/spec/Updater/PayPalPaymentUpdaterSpec.php b/spec/Updater/PayPalPaymentUpdaterSpec.php index a2dc15a4..1eab6aef 100644 --- a/spec/Updater/PayPalPaymentUpdaterSpec.php +++ b/spec/Updater/PayPalPaymentUpdaterSpec.php @@ -32,7 +32,7 @@ function it_implements_payment_updater_interface(): void function it_updates_payment_amount( ObjectManager $paymentManager, - PaymentInterface $payment + PaymentInterface $payment, ): void { $payment->setAmount(1000)->shouldBeCalled(); $paymentManager->flush(); diff --git a/tests/Functional/CreatePayPalOrderActionTest.php b/tests/Functional/CreatePayPalOrderActionTest.php index f05cb13a..47ec9952 100644 --- a/tests/Functional/CreatePayPalOrderActionTest.php +++ b/tests/Functional/CreatePayPalOrderActionTest.php @@ -9,7 +9,7 @@ final class CreatePayPalOrderActionTest extends JsonApiTestCase { /** @test */ - function it_creates_pay_pal_order_and_returns_its_data(): void + public function it_creates_pay_pal_order_and_returns_its_data(): void { $this->loadFixturesFromFiles(['resources/shop.yaml', 'resources/new_order.yaml']); diff --git a/tests/Functional/CreatePayPalOrderFromCartActionTest.php b/tests/Functional/CreatePayPalOrderFromCartActionTest.php index e70ed642..aa5a0b0a 100644 --- a/tests/Functional/CreatePayPalOrderFromCartActionTest.php +++ b/tests/Functional/CreatePayPalOrderFromCartActionTest.php @@ -9,7 +9,7 @@ final class CreatePayPalOrderFromCartActionTest extends JsonApiTestCase { /** @test */ - function it_creates_pay_pal_order_from_cart_and_returns_its_data(): void + public function it_creates_pay_pal_order_from_cart_and_returns_its_data(): void { $order = $this->loadFixturesFromFiles(['resources/shop.yaml', 'resources/new_cart.yaml']); /** @var int $orderId */ diff --git a/tests/Functional/CreatePayPalOrderFromPaymentPageActionTest.php b/tests/Functional/CreatePayPalOrderFromPaymentPageActionTest.php index 35ec88c2..32a28f0d 100644 --- a/tests/Functional/CreatePayPalOrderFromPaymentPageActionTest.php +++ b/tests/Functional/CreatePayPalOrderFromPaymentPageActionTest.php @@ -9,7 +9,7 @@ final class CreatePayPalOrderFromPaymentPageActionTest extends JsonApiTestCase { /** @test */ - function it_creates_pay_pal_order_from_payment_page_and_returns_its_data(): void + public function it_creates_pay_pal_order_from_payment_page_and_returns_its_data(): void { $order = $this->loadFixturesFromFiles(['resources/shop.yaml', 'resources/new_cart.yaml']); /** @var int $orderId */ diff --git a/tests/Service/DummyRefundPaymentApi.php b/tests/Service/DummyRefundPaymentApi.php index 6a22b9c0..37e97868 100644 --- a/tests/Service/DummyRefundPaymentApi.php +++ b/tests/Service/DummyRefundPaymentApi.php @@ -14,7 +14,7 @@ public function refund( string $payPalAuthAssertion, string $invoiceNumber, string $amount, - string $currencyCode + string $currencyCode, ): array { return ['status' => 'COMPLETED', 'id' => $paymentId]; } diff --git a/tests/Unit/PayPalGatewayFactoryTest.php b/tests/Unit/PayPalGatewayFactoryTest.php index 8ce3f603..73ba8c13 100644 --- a/tests/Unit/PayPalGatewayFactoryTest.php +++ b/tests/Unit/PayPalGatewayFactoryTest.php @@ -13,11 +13,9 @@ namespace Tests\Sylius\PayPalPlugin\Unit; -use Payum\Core\Bridge\Spl\ArrayObject; use PHPUnit\Framework\TestCase; use Sylius\PayPalPlugin\Payum\Action\StatusAction; use Sylius\PayPalPlugin\Payum\Factory\PayPalGatewayFactory; -use Sylius\PayPalPlugin\Payum\Model\PayPalApi; final class PayPalGatewayFactoryTest extends TestCase {