From 0494fb162ab1985a9248bde0d1a43d601e1c8514 Mon Sep 17 00:00:00 2001 From: Lorenzo Ruozzi Date: Fri, 2 Aug 2024 16:11:30 +0200 Subject: [PATCH] Try to fix CI --- .github/workflows/build.yml | 12 ++++-------- composer.json | 3 +-- ...ing_with_pagolight_during_checkout.feature | 12 +++++++----- ...with_pagolight_pro_during_checkout.feature | 12 +++++++----- phpstan.neon | 2 ++ src/Controller/PaymentController.php | 4 ---- .../PagolightPaymentMethodsResolver.php | 3 --- .../PagolightPaymentMethodUniqueValidator.php | 4 +--- tests/Behat/Context/Api/PagolightContext.php | 16 +++++++--------- tests/Behat/Context/Setup/PaymentContext.php | 3 --- tests/Behat/Context/Ui/PagolightContext.php | 19 ++++--------------- 11 files changed, 33 insertions(+), 57 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 23d76c4..f5c943c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -77,6 +77,10 @@ jobs: name: Run webserver run: (cd tests/Application && symfony server:start --port=8080 --dir=public --daemon) + - + name: Validate composer.json + run: composer validate --ansi --strict + - name: Get Composer cache directory id: composer-cache @@ -153,14 +157,6 @@ jobs: name: Load fixtures in test application run: (cd tests/Application && bin/console sylius:fixtures:load -n) - - - name: Validate composer.json - run: composer validate --ansi --strict - - - - name: Validate database schema - run: (cd tests/Application && bin/console doctrine:schema:validate) - - name: Install certificates run: symfony server:ca:install diff --git a/composer.json b/composer.json index 90d910d..9f39736 100644 --- a/composer.json +++ b/composer.json @@ -10,7 +10,7 @@ "license": "proprietary", "require": { "php": "^8.2", - "guzzlehttp/psr7": "^2.5", + "guzzlehttp/psr7": "^1.8 || ^2.5", "php-http/discovery": "^1.19", "psr/http-factory": "^1.0", "sylius/sylius": "^1.12", @@ -99,7 +99,6 @@ "unit": "vendor/bin/phpunit --colors=always", "behat": "vendor/bin/behat --colors --strict -vvv --no-interaction || vendor/bin/behat --colors --strict -vvv --no-interaction --rerun", "tests": [ - "composer validate --ansi --strict", "@ecs", "@phpstan", "@psalm", diff --git a/features/checkout/paying_for_order/paying_with_pagolight_during_checkout.feature b/features/checkout/paying_for_order/paying_with_pagolight_during_checkout.feature index e652efd..bf5a1cb 100644 --- a/features/checkout/paying_for_order/paying_with_pagolight_during_checkout.feature +++ b/features/checkout/paying_for_order/paying_with_pagolight_during_checkout.feature @@ -23,7 +23,7 @@ Feature: Paying with Pagolight during checkout And I proceeded with "Free" shipping method and "Pagolight" payment When I confirm my order And I complete the payment on Pagolight - Then I should be on the capture payment page + Then I should be on the waiting payment processing page When Pagolight notify the store about the successful payment Then I should be redirected to the thank you page And I should be notified that my payment has been completed @@ -39,13 +39,13 @@ Feature: Paying with Pagolight during checkout And I proceeded with "Free" shipping method and "Pagolight" payment When I confirm my order And I complete the payment on Pagolight - Then I should be on the capture payment page + Then I should be on the waiting payment processing page When Pagolight notify the store about the failed payment - Then I should be redirected to the order page page + Then I should be redirected to the order page And I should be notified that my payment has been cancelled And I should be able to pay again - @ui + @ui @javascript Scenario: Cancelling the payment Given I added product "PHP T-Shirt" to the cart And I am at the checkout addressing step @@ -54,7 +54,8 @@ Feature: Paying with Pagolight during checkout And I proceeded with "Free" shipping method and "Pagolight" payment When I confirm my order And I cancel the payment on Pagolight - Then I should be notified that my payment has been cancelled + Then I should be on the waiting payment processing page + And I should be redirected to the order page And I should be able to pay again @ui @javascript @@ -66,6 +67,7 @@ Feature: Paying with Pagolight during checkout And I proceeded with "Free" shipping method and "Pagolight" payment And I have confirmed order But I have cancelled Pagolight payment + Then I should be redirected to the order page When I try to pay again with Pagolight And Pagolight notify the store about the successful payment Then I should be redirected to the thank you page diff --git a/features/checkout/paying_for_order/paying_with_pagolight_pro_during_checkout.feature b/features/checkout/paying_for_order/paying_with_pagolight_pro_during_checkout.feature index 5b2e3a2..e4ee209 100644 --- a/features/checkout/paying_for_order/paying_with_pagolight_pro_during_checkout.feature +++ b/features/checkout/paying_for_order/paying_with_pagolight_pro_during_checkout.feature @@ -23,7 +23,7 @@ Feature: Paying with Pagolight PRO during checkout And I proceeded with "Free" shipping method and "Pagolight PRO" payment When I confirm my order And I complete the payment on Pagolight - Then I should be on the capture payment page + Then I should be on the waiting payment processing page When Pagolight notify the store about the successful payment Then I should be redirected to the thank you page And I should be notified that my payment has been completed @@ -39,13 +39,13 @@ Feature: Paying with Pagolight PRO during checkout And I proceeded with "Free" shipping method and "Pagolight PRO" payment When I confirm my order And I complete the payment on Pagolight - Then I should be on the capture payment page + Then I should be on the waiting payment processing page When Pagolight notify the store about the failed payment - Then I should be redirected to the order page page + Then I should be redirected to the order page And I should be notified that my payment has been cancelled And I should be able to pay again - @ui + @ui @javascript Scenario: Cancelling the payment Given I added product "PHP T-Shirt" to the cart And I am at the checkout addressing step @@ -54,7 +54,8 @@ Feature: Paying with Pagolight PRO during checkout And I proceeded with "Free" shipping method and "Pagolight PRO" payment When I confirm my order And I cancel the payment on Pagolight - Then I should be notified that my payment has been cancelled + Then I should be on the waiting payment processing page + And I should be redirected to the order page And I should be able to pay again @ui @javascript @@ -66,6 +67,7 @@ Feature: Paying with Pagolight PRO during checkout And I proceeded with "Free" shipping method and "Pagolight PRO" payment And I have confirmed order But I have cancelled Pagolight payment + Then I should be redirected to the order page When I try to pay again with Pagolight And Pagolight notify the store about the successful payment Then I should be redirected to the thank you page diff --git a/phpstan.neon b/phpstan.neon index 5f96af4..e934200 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -14,5 +14,7 @@ parameters: - 'tests/Application/src/**.php' ignoreErrors: + - + identifier: missingType.generics # Temp - identifier: missingType.iterableValue diff --git a/src/Controller/PaymentController.php b/src/Controller/PaymentController.php index 59045d0..8ba9fcb 100644 --- a/src/Controller/PaymentController.php +++ b/src/Controller/PaymentController.php @@ -33,10 +33,6 @@ final class PaymentController extends AbstractController public const TOKEN_HASH_SESSION_KEY = 'webgriffe_pagolight_token_hash'; - /** - * @param OrderRepositoryInterface $orderRepository - * @param PaymentRepositoryInterface $paymentRepository - */ public function __construct( private readonly OrderRepositoryInterface $orderRepository, private readonly RequestStack $requestStack, diff --git a/src/Resolver/PagolightPaymentMethodsResolver.php b/src/Resolver/PagolightPaymentMethodsResolver.php index f7344e7..8da4475 100644 --- a/src/Resolver/PagolightPaymentMethodsResolver.php +++ b/src/Resolver/PagolightPaymentMethodsResolver.php @@ -18,9 +18,6 @@ final class PagolightPaymentMethodsResolver implements PaymentMethodsResolverInterface { - /** - * @param PaymentMethodRepositoryInterface $paymentMethodRepository - */ public function __construct( private readonly PaymentMethodRepositoryInterface $paymentMethodRepository, ) { diff --git a/src/Validator/PagolightPaymentMethodUniqueValidator.php b/src/Validator/PagolightPaymentMethodUniqueValidator.php index 73bf343..60a6183 100644 --- a/src/Validator/PagolightPaymentMethodUniqueValidator.php +++ b/src/Validator/PagolightPaymentMethodUniqueValidator.php @@ -16,9 +16,6 @@ */ final class PagolightPaymentMethodUniqueValidator extends ConstraintValidator { - /** - * @param PaymentMethodRepositoryInterface $paymentMethodRepository - */ public function __construct( private readonly PaymentMethodRepositoryInterface $paymentMethodRepository, ) { @@ -48,6 +45,7 @@ public function validate(mixed $value, Constraint $constraint): void return; } + /** @var PaymentMethodInterface[] $paymentMethods */ $paymentMethods = $this->paymentMethodRepository->findAll(); /** @psalm-suppress DeprecatedMethod */ $paymentMethodsWithSameGatewayConfig = array_filter( diff --git a/tests/Behat/Context/Api/PagolightContext.php b/tests/Behat/Context/Api/PagolightContext.php index 53fb433..0c0ba69 100644 --- a/tests/Behat/Context/Api/PagolightContext.php +++ b/tests/Behat/Context/Api/PagolightContext.php @@ -5,10 +5,10 @@ namespace Tests\Webgriffe\SyliusPagolightPlugin\Behat\Context\Api; use Behat\Behat\Context\Context; +use GuzzleHttp\Client; use GuzzleHttp\Psr7\Request; use Psr\Http\Client\ClientInterface; use Sylius\Bundle\PayumBundle\Model\PaymentSecurityTokenInterface; -use Sylius\Component\Core\Model\PaymentInterface; use Sylius\Component\Core\Repository\PaymentRepositoryInterface; use Sylius\Component\Resource\Repository\RepositoryInterface; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; @@ -23,15 +23,11 @@ final class PagolightContext implements Context { use PayumPaymentTrait; - /** - * @param RepositoryInterface $paymentTokenRepository - * @param PaymentRepositoryInterface $paymentRepository - */ public function __construct( private readonly RepositoryInterface $paymentTokenRepository, private readonly PaymentRepositoryInterface $paymentRepository, private readonly UrlGeneratorInterface $urlGenerator, - private readonly ClientInterface $client, + private readonly ClientInterface|Client $client, private readonly WebhookTokenRepositoryInterface $webhookTokenRepository, ) { // TODO: Why config parameters are not loaded? @@ -70,9 +66,6 @@ public function pagolightNotifyTheStoreAboutTheFailedPayment(): void ]); } - /** - * @return PaymentRepositoryInterface - */ protected function getPaymentRepository(): PaymentRepositoryInterface { return $this->paymentRepository; @@ -97,6 +90,11 @@ private function notifyPaymentState(PaymentSecurityTokenInterface $token, array ], $formParams, ); + if ($this->client instanceof Client) { + $this->client->send($request); + + return; + } $this->client->sendRequest($request); } diff --git a/tests/Behat/Context/Setup/PaymentContext.php b/tests/Behat/Context/Setup/PaymentContext.php index f414991..a3318b0 100644 --- a/tests/Behat/Context/Setup/PaymentContext.php +++ b/tests/Behat/Context/Setup/PaymentContext.php @@ -17,9 +17,6 @@ final class PaymentContext implements Context { public const MERCHANT_KEY = '83Y4TDI8W7Y4EWIY48TWT'; - /** - * @param PaymentMethodRepositoryInterface $paymentMethodRepository - */ public function __construct( private readonly SharedStorageInterface $sharedStorage, private readonly PaymentMethodRepositoryInterface $paymentMethodRepository, diff --git a/tests/Behat/Context/Ui/PagolightContext.php b/tests/Behat/Context/Ui/PagolightContext.php index 17fed4a..4da6f5e 100644 --- a/tests/Behat/Context/Ui/PagolightContext.php +++ b/tests/Behat/Context/Ui/PagolightContext.php @@ -10,7 +10,6 @@ use Sylius\Behat\Page\Shop\Order\ThankYouPageInterface; use Sylius\Bundle\PayumBundle\Model\PaymentSecurityTokenInterface; use Sylius\Component\Core\Model\OrderInterface; -use Sylius\Component\Core\Model\PaymentInterface; use Sylius\Component\Core\Repository\OrderRepositoryInterface; use Sylius\Component\Core\Repository\PaymentRepositoryInterface; use Sylius\Component\Resource\Repository\RepositoryInterface; @@ -24,11 +23,6 @@ final class PagolightContext implements Context { use PayumPaymentTrait; - /** - * @param RepositoryInterface $paymentTokenRepository - * @param PaymentRepositoryInterface $paymentRepository - * @param OrderRepositoryInterface $orderRepository - */ public function __construct( private readonly RepositoryInterface $paymentTokenRepository, private readonly PaymentRepositoryInterface $paymentRepository, @@ -69,13 +63,11 @@ public function iCancelThePaymentOnPagolight(): void } /** - * @Then I should be on the capture payment page + * @Then I should be on the waiting payment processing page */ - public function iShouldBeOnTheCapturePaymentPage(): void + public function iShouldBeOnTheWaitingPaymentProcessingPage(): void { $payment = $this->getCurrentPayment(); - [$paymentCaptureSecurityToken] = $this->getCurrentPaymentSecurityTokens($payment); - $this->paymentProcessPage->verify([ 'tokenValue' => $payment->getOrder()?->getTokenValue(), ]); @@ -100,9 +92,9 @@ public function iTryToPayAgainWithPagolight(): void } /** - * @Then /^I should be redirected to the order page page$/ + * @Then /^I should be redirected to the order page/ */ - public function iShouldBeRedirectedToTheOrderPagePage(): void + public function iShouldBeRedirectedToTheOrderPage(): void { $this->paymentProcessPage->waitForRedirect(); $orders = $this->orderRepository->findAll(); @@ -111,9 +103,6 @@ public function iShouldBeRedirectedToTheOrderPagePage(): void Assert::true($this->orderShowPage->isOpen(['tokenValue' => $order->getTokenValue()])); } - /** - * @return PaymentRepositoryInterface - */ protected function getPaymentRepository(): PaymentRepositoryInterface { return $this->paymentRepository;