Skip to content

Commit

Permalink
Fix 1.13
Browse files Browse the repository at this point in the history
  • Loading branch information
leszczuu committed Mar 15, 2024
1 parent 9ab11fd commit ae36262
Show file tree
Hide file tree
Showing 18 changed files with 394 additions and 270 deletions.
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
18 changes: 14 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@
"require": {
"php": "^8.0",
"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"
}
}
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

0 comments on commit ae36262

Please sign in to comment.