Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix 1.13 #1

Open
wants to merge 2 commits into
base: 1.5
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ jobs:
strategy:
fail-fast: false
matrix:
php: ["8.0", "8.1"]
php: ["8.1", "8.2"]
node: ["16.x"]
mysql: ["5.7", "8.0"]
symfony: ["^5.4", "^6.0"]
sylius: ["~1.12.0"]
sylius: ["~1.12.0", "1.13.x-dev"]
env:
APP_ENV: test
DATABASE_URL: "mysql://root:[email protected]/sylius?serverVersion=${{ matrix.mysql }}"
Expand Down Expand Up @@ -149,10 +149,12 @@ jobs:

-
name: Validate composer.json
if: ${{ matrix.sylius != '1.13.x-dev' }}
run: composer validate --ansi --strict

-
name: Run analysis
if: ${{ matrix.sylius != '1.13.x-dev' }}
run: composer analyse

-
Expand Down
20 changes: 15 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@
"description": "PayPal plugin for Sylius.",
"license": "MIT",
"require": {
"php": "^8.0",
"php": "^8.1",
"doctrine/doctrine-migrations-bundle": "^3.0",
"php-http/discovery": "^1.17",
"phpseclib/phpseclib": "^2.0",
"polishsymfonycommunity/symfony-mocker-container": "^1.0",
"psr/http-client": "^1.0",
"psr/http-client-implementation": "~1.0",
"psr/http-factory-implementation": "~1.0",
"sylius-labs/doctrine-migrations-extra-bundle": "^0.1.4 || ^0.2",
"sylius/sylius": "~1.12.0",
"sylius/sylius": "~1.12.0 || 1.13.x-dev",
"symfony/mailer": "^5.4 || ^6.0"
},
"require-dev": {
Expand All @@ -27,16 +30,19 @@
"friends-of-behat/symfony-extension": "^2.1",
"friends-of-behat/variadic-extension": "^1.3",
"lchrusciel/api-test-case": "^5.1",
"nyholm/psr7": "^1.8",
"phpspec/phpspec": "^7.0",
"phpstan/phpstan": "^1.6",
"phpstan/phpstan-doctrine": "1.3.37",
"phpstan/phpstan-webmozart-assert": "^1.1",
"phpunit/phpunit": "^8.5",
"polishsymfonycommunity/symfony-mocker-container": "^1.0",
"sylius-labs/coding-standard": "^4.0",
"sylius/sylius-rector": "^1.0",
"symfony/browser-kit": "^5.4 || ^6.0",
"symfony/debug-bundle": "^5.4 || ^6.0",
"symfony/dotenv": "^5.4 || ^6.0",
"symfony/http-client": "^5.4 || ^6.0",
"symfony/intl": "^5.4 || ^6.0",
"symfony/web-profiler-bundle": "^5.4 || ^6.0",
"symfony/webpack-encore-bundle": "^1.15"
Expand All @@ -59,7 +65,8 @@
"dealerdirect/phpcodesniffer-composer-installer": false,
"ocramius/package-versions": false,
"symfony/flex": true,
"symfony/thanks": false
"symfony/thanks": false,
"php-http/discovery": true
}
},
"extra": {
Expand All @@ -77,5 +84,8 @@
]
},
"prefer-stable": true,
"minimum-stability": "dev"
"minimum-stability": "dev",
"suggest": {
"php-http/guzzle6-adapter ":"Required to use this package on 32bit PHP"
}
}
24 changes: 14 additions & 10 deletions spec/Api/GenericApiSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,19 @@

namespace spec\Sylius\PayPalPlugin\Api;

use GuzzleHttp\ClientInterface;
use PhpSpec\ObjectBehavior;
use Psr\Http\Client\ClientInterface;
use Psr\Http\Message\RequestFactoryInterface;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\StreamInterface;
use Sylius\PayPalPlugin\Api\GenericApiInterface;

final class GenericApiSpec extends ObjectBehavior
{
function let(ClientInterface $client): void
function let(ClientInterface $client, RequestFactoryInterface $requestFactory): void
{
$this->beConstructedWith($client);
$this->beConstructedWith($client, $requestFactory);
}

function it_implements_generic_api_interface(): void
Expand All @@ -33,17 +35,19 @@ function it_implements_generic_api_interface(): void

function it_calls_api_by_url(
ClientInterface $client,
RequestFactoryInterface $requestFactory,
RequestInterface $request,
ResponseInterface $response,
StreamInterface $body
): void {
$client->request('GET', 'http://url.com/', [
'headers' => [
'Authorization' => 'Bearer TOKEN',
'Content-Type' => 'application/json',
'Accept' => 'application/json',
],
])->willReturn($response);

$requestFactory->createRequest('GET', 'http://url.com/')->willReturn($request);

$request->withHeader('Authorization', 'Bearer TOKEN')->willReturn($request);
$request->withHeader('Content-Type', 'application/json')->willReturn($request);
$request->withHeader('Accept', 'application/json')->willReturn($request);

$client->sendRequest($request)->willReturn($response);
$response->getBody()->willReturn($body);
$body->getContents()->willReturn('{ "parameter": "VALUE" }');

Expand Down
67 changes: 29 additions & 38 deletions spec/Api/WebhookApiSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,42 @@

namespace spec\Sylius\PayPalPlugin\Api;

use GuzzleHttp\ClientInterface;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
use Psr\Http\Client\ClientInterface;
use Psr\Http\Message\RequestFactoryInterface;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\StreamFactoryInterface;
use Psr\Http\Message\StreamInterface;

final class WebhookApiSpec extends ObjectBehavior
{
function let(ClientInterface $client): void
{
$this->beConstructedWith($client, 'http://base-url.com/');
function let(
ClientInterface $client,
RequestFactoryInterface $requestFactory,
StreamFactoryInterface $streamFactory,
StreamInterface $stream,
RequestInterface $request
): void {
$this->beConstructedWith($client, $requestFactory, $streamFactory, 'http://base-url.com/');
$request->withHeader(Argument::any(), Argument::any())->willReturn($request);
$request->withBody(Argument::any())->willReturn($request);
$streamFactory->createStream(Argument::any())->willReturn($stream);
}

function it_registers_webhook(
ClientInterface $client,
RequestFactoryInterface $requestFactory,
RequestInterface $request,
ResponseInterface $response,
StreamInterface $body
): void {
$client->request(
'POST',
'http://base-url.com/v1/notifications/webhooks',
[
'headers' => [
'Authorization' => 'Bearer TOKEN',
'Content-Type' => 'application/json',
'Accept' => 'application/json',
],
'json' => [
'url' => 'https://webhook.com',
'event_types' => [
['name' => 'PAYMENT.CAPTURE.REFUNDED'],
],
],
]
)->willReturn($response);

$requestFactory->createRequest('POST','http://base-url.com/v1/notifications/webhooks')
->willReturn($request);
$client->sendRequest($request)->willReturn($response);

$response->getBody()->willReturn($body);
$body->getContents()->willReturn('{ "status": "CREATED" }');

Expand All @@ -46,26 +48,15 @@ function it_registers_webhook(

function it_registers_webhook_without_https(
ClientInterface $client,
RequestFactoryInterface $requestFactory,
RequestInterface $request,
ResponseInterface $response,
StreamInterface $body
): void {
$client->request(
'POST',
'http://base-url.com/v1/notifications/webhooks',
[
'headers' => [
'Authorization' => 'Bearer TOKEN',
'Content-Type' => 'application/json',
'Accept' => 'application/json',
],
'json' => [
'url' => 'https://webhook.com',
'event_types' => [
['name' => 'PAYMENT.CAPTURE.REFUNDED'],
],
],
]
)->willReturn($response);
$requestFactory->createRequest('POST','http://base-url.com/v1/notifications/webhooks')
->willReturn($request);
$client->sendRequest($request)->willReturn($response);

$response->getBody()->willReturn($body);
$body->getContents()->willReturn('{ "status": "CREATED" }');

Expand Down
Loading
Loading