From 9a77e0d68020a71d8e245dd16bb03be37564a25b Mon Sep 17 00:00:00 2001 From: Francis Hilaire Date: Wed, 24 May 2023 12:38:59 +0200 Subject: [PATCH 1/3] Replace deprecated class --- .github/workflows/build.yml | 2 +- tests/Application/.env | 2 +- tests/Application/config/sylius/1.10/services.yaml | 2 ++ tests/Application/config/sylius/1.11/services.yaml | 3 +++ tests/Application/config/sylius/1.9/services.yaml | 2 ++ 5 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 tests/Application/config/sylius/1.10/services.yaml create mode 100644 tests/Application/config/sylius/1.11/services.yaml create mode 100644 tests/Application/config/sylius/1.9/services.yaml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index df11b91..0cd0a11 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -281,7 +281,7 @@ jobs: - name: Upload Behat logs - uses: actions/upload-artifact@v3 + uses: codecov/codecov-action@v3 if: failure() with: name: Behat logs diff --git a/tests/Application/.env b/tests/Application/.env index db68ae9..c0926a9 100644 --- a/tests/Application/.env +++ b/tests/Application/.env @@ -25,7 +25,7 @@ JWT_PASSPHRASE=acme_plugin_development # For Gmail as a transport, use: "gmail://username:password@localhost" # For a generic SMTP server, use: "smtp://localhost:25?encryption=&auth_mode=" # Delivery is disabled by default via "null://localhost" -MAILER_URL=smtp://localhost +MAILER_URL=null://localhost ###< symfony/swiftmailer-bundle ### ###> symfony/mailer ### diff --git a/tests/Application/config/sylius/1.10/services.yaml b/tests/Application/config/sylius/1.10/services.yaml new file mode 100644 index 0000000..15abf2f --- /dev/null +++ b/tests/Application/config/sylius/1.10/services.yaml @@ -0,0 +1,2 @@ +imports: + - { resource: "../1.11/services.yaml" } diff --git a/tests/Application/config/sylius/1.11/services.yaml b/tests/Application/config/sylius/1.11/services.yaml new file mode 100644 index 0000000..43880f7 --- /dev/null +++ b/tests/Application/config/sylius/1.11/services.yaml @@ -0,0 +1,3 @@ +services: + sylius.http_message_factory: + class: Symfony\Component\HttpClient\Psr18Client diff --git a/tests/Application/config/sylius/1.9/services.yaml b/tests/Application/config/sylius/1.9/services.yaml new file mode 100644 index 0000000..15abf2f --- /dev/null +++ b/tests/Application/config/sylius/1.9/services.yaml @@ -0,0 +1,2 @@ +imports: + - { resource: "../1.11/services.yaml" } From b5c0b820ea12ec640c56fd923512c5c8bb840c20 Mon Sep 17 00:00:00 2001 From: Francis Hilaire Date: Wed, 24 May 2023 14:38:49 +0200 Subject: [PATCH 2/3] Replace HTTP factories --- .github/workflows/build.yml | 11 ++++ .../config/sylius/1.10/packages/payum.yaml | 25 ++++++++ .../config/sylius/1.10/services.yaml | 2 - .../config/sylius/1.11/packages/payum.yaml | 25 ++++++++ .../config/sylius/1.11/services.yaml | 3 - .../config/sylius/1.9/packages/payum.yaml | 25 ++++++++ .../config/sylius/1.9/services.yaml | 2 - .../src/Payum/Factory/MessageFactory.php | 60 +++++++++++++++++++ .../src/Payum/HttpClient/HttpClient.php | 25 ++++++++ 9 files changed, 171 insertions(+), 7 deletions(-) create mode 100644 tests/Application/config/sylius/1.10/packages/payum.yaml delete mode 100644 tests/Application/config/sylius/1.10/services.yaml create mode 100644 tests/Application/config/sylius/1.11/packages/payum.yaml delete mode 100644 tests/Application/config/sylius/1.11/services.yaml create mode 100644 tests/Application/config/sylius/1.9/packages/payum.yaml delete mode 100644 tests/Application/config/sylius/1.9/services.yaml create mode 100644 tests/Application/src/Payum/Factory/MessageFactory.php create mode 100644 tests/Application/src/Payum/HttpClient/HttpClient.php diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0cd0a11..5fa8677 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -227,6 +227,17 @@ jobs: composer require "friendsofsymfony/oauth-server-bundle:>2.0.0-alpha.0 ^2.0@dev" --no-update --no-scripts --no-interaction # Sylius issues on `json_array` type not existing composer require "doctrine/dbal:^2.6" --no-update --no-scripts --no-interaction + composer require "nyholm/psr7" --no-update --no-scripts --no-interaction + - + name: Fix build on Sylius 1.10 + if: matrix.sylius == '~1.10.0' + run: | + composer require "nyholm/psr7" --no-update --no-scripts --no-interaction + - + name: Fix build on Sylius 1.11 + if: matrix.sylius == '~1.11.0' + run: | + composer require "nyholm/psr7" --no-update --no-scripts --no-interaction - name: Install PHP dependencies diff --git a/tests/Application/config/sylius/1.10/packages/payum.yaml b/tests/Application/config/sylius/1.10/packages/payum.yaml new file mode 100644 index 0000000..e01f066 --- /dev/null +++ b/tests/Application/config/sylius/1.10/packages/payum.yaml @@ -0,0 +1,25 @@ +services: + app.payum.http_client: + public: true + class: Tests\FluxSE\SyliusPayumStripePlugin\App\Payum\HttpClient\HttpClient + arguments: + $client: '@Psr\Http\Client\ClientInterface' + app.payum.message_factory: + public: true + class: Tests\FluxSE\SyliusPayumStripePlugin\App\Payum\Factory\MessageFactory + arguments: + $requestFactory: '@Psr\Http\Client\ClientInterface' + $responseFactory: '@nyholm.psr17.factory' + $streamFactory: '@Psr\Http\Client\ClientInterface' + + nyholm.psr17.factory: + public: true + class: Nyholm\Psr7\Factory\Psr17Factory + +payum: + gateways: + core: + httplug.message_factory: '@app.payum.message_factory' + httplug.stream_factory: '@app.payum.message_factory' + httplug.client: '@Symfony\Component\HttpClient\HttplugClient' + payum.http_client: '@app.payum.http_client' diff --git a/tests/Application/config/sylius/1.10/services.yaml b/tests/Application/config/sylius/1.10/services.yaml deleted file mode 100644 index 15abf2f..0000000 --- a/tests/Application/config/sylius/1.10/services.yaml +++ /dev/null @@ -1,2 +0,0 @@ -imports: - - { resource: "../1.11/services.yaml" } diff --git a/tests/Application/config/sylius/1.11/packages/payum.yaml b/tests/Application/config/sylius/1.11/packages/payum.yaml new file mode 100644 index 0000000..e01f066 --- /dev/null +++ b/tests/Application/config/sylius/1.11/packages/payum.yaml @@ -0,0 +1,25 @@ +services: + app.payum.http_client: + public: true + class: Tests\FluxSE\SyliusPayumStripePlugin\App\Payum\HttpClient\HttpClient + arguments: + $client: '@Psr\Http\Client\ClientInterface' + app.payum.message_factory: + public: true + class: Tests\FluxSE\SyliusPayumStripePlugin\App\Payum\Factory\MessageFactory + arguments: + $requestFactory: '@Psr\Http\Client\ClientInterface' + $responseFactory: '@nyholm.psr17.factory' + $streamFactory: '@Psr\Http\Client\ClientInterface' + + nyholm.psr17.factory: + public: true + class: Nyholm\Psr7\Factory\Psr17Factory + +payum: + gateways: + core: + httplug.message_factory: '@app.payum.message_factory' + httplug.stream_factory: '@app.payum.message_factory' + httplug.client: '@Symfony\Component\HttpClient\HttplugClient' + payum.http_client: '@app.payum.http_client' diff --git a/tests/Application/config/sylius/1.11/services.yaml b/tests/Application/config/sylius/1.11/services.yaml deleted file mode 100644 index 43880f7..0000000 --- a/tests/Application/config/sylius/1.11/services.yaml +++ /dev/null @@ -1,3 +0,0 @@ -services: - sylius.http_message_factory: - class: Symfony\Component\HttpClient\Psr18Client diff --git a/tests/Application/config/sylius/1.9/packages/payum.yaml b/tests/Application/config/sylius/1.9/packages/payum.yaml new file mode 100644 index 0000000..e01f066 --- /dev/null +++ b/tests/Application/config/sylius/1.9/packages/payum.yaml @@ -0,0 +1,25 @@ +services: + app.payum.http_client: + public: true + class: Tests\FluxSE\SyliusPayumStripePlugin\App\Payum\HttpClient\HttpClient + arguments: + $client: '@Psr\Http\Client\ClientInterface' + app.payum.message_factory: + public: true + class: Tests\FluxSE\SyliusPayumStripePlugin\App\Payum\Factory\MessageFactory + arguments: + $requestFactory: '@Psr\Http\Client\ClientInterface' + $responseFactory: '@nyholm.psr17.factory' + $streamFactory: '@Psr\Http\Client\ClientInterface' + + nyholm.psr17.factory: + public: true + class: Nyholm\Psr7\Factory\Psr17Factory + +payum: + gateways: + core: + httplug.message_factory: '@app.payum.message_factory' + httplug.stream_factory: '@app.payum.message_factory' + httplug.client: '@Symfony\Component\HttpClient\HttplugClient' + payum.http_client: '@app.payum.http_client' diff --git a/tests/Application/config/sylius/1.9/services.yaml b/tests/Application/config/sylius/1.9/services.yaml deleted file mode 100644 index 15abf2f..0000000 --- a/tests/Application/config/sylius/1.9/services.yaml +++ /dev/null @@ -1,2 +0,0 @@ -imports: - - { resource: "../1.11/services.yaml" } diff --git a/tests/Application/src/Payum/Factory/MessageFactory.php b/tests/Application/src/Payum/Factory/MessageFactory.php new file mode 100644 index 0000000..063c997 --- /dev/null +++ b/tests/Application/src/Payum/Factory/MessageFactory.php @@ -0,0 +1,60 @@ +requestFactory = $requestFactory; + $this->responseFactory = $responseFactory; + $this->streamFactory = $streamFactory; + } + + public function createRequest(string $method, $uri): RequestInterface + { + return $this->requestFactory->createRequest($method, $uri); + } + + public function createResponse(int $code = 200, string $reasonPhrase = ''): ResponseInterface + { + return $this->responseFactory->createResponse($code, $reasonPhrase); + } + + + public function createStream(string $content = ''): StreamInterface + { + return $this->streamFactory->createStream($content); + } + + public function createStreamFromFile(string $filename, string $mode = 'r'): StreamInterface + { + return $this->streamFactory->createStreamFromFile($filename, $mode); + } + + public function createStreamFromResource($resource): StreamInterface + { + return $this->streamFactory->createStreamFromResource($resource); + } +} diff --git a/tests/Application/src/Payum/HttpClient/HttpClient.php b/tests/Application/src/Payum/HttpClient/HttpClient.php new file mode 100644 index 0000000..ecc464e --- /dev/null +++ b/tests/Application/src/Payum/HttpClient/HttpClient.php @@ -0,0 +1,25 @@ +client = $client; + } + + public function send(RequestInterface $request): ResponseInterface + { + return $this->client->sendRequest($request); + } +} From 3fea7e570319d4e23647e4a4b808a5dcb9357ea8 Mon Sep 17 00:00:00 2001 From: Francis Hilaire Date: Wed, 24 May 2023 18:37:31 +0200 Subject: [PATCH 3/3] Add required http_client enabled --- tests/Application/config/sylius/1.11/packages/payum.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/Application/config/sylius/1.11/packages/payum.yaml b/tests/Application/config/sylius/1.11/packages/payum.yaml index e01f066..5c1cea2 100644 --- a/tests/Application/config/sylius/1.11/packages/payum.yaml +++ b/tests/Application/config/sylius/1.11/packages/payum.yaml @@ -16,6 +16,10 @@ services: public: true class: Nyholm\Psr7\Factory\Psr17Factory +framework: + http_client: + enabled: true # require to alias the service Psr\Http\Client\ClientInterface + payum: gateways: core: