From 8cfd94270f1b01eb2799407d7c21b4a929f3584c Mon Sep 17 00:00:00 2001 From: Rafikooo Date: Wed, 13 Apr 2022 16:57:41 +0200 Subject: [PATCH] [Maintenance] Support PHP 8.1, drop PHP 7.4, bump to Sylius 1.10 --- .github/workflows/build.yml | 8 ++------ composer.json | 8 ++++---- spec/Validator/Cart/CartEligibilityValidatorSpec.php | 12 ++++++------ tests/Application/Kernel.php | 11 ++++++++++- 4 files changed, 22 insertions(+), 17 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6b73cb6c..8aca741b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -18,15 +18,11 @@ jobs: strategy: fail-fast: false matrix: - php: [7.4, 8.0] + php: [8.0, 8.1] node: [10.x] mysql: [5.7, 8.0] symfony: [^4.4, ~5.2.0, ~5.3.0] - sylius: [~1.9.0, ~1.10.0] - exclude: - - # Sylius 1.9 does not support PHP 8.0 - sylius: ~1.9.0 - php: 8.0 + sylius: [~1.10.0] env: APP_ENV: test diff --git a/composer.json b/composer.json index 7beb6db6..76ede408 100644 --- a/composer.json +++ b/composer.json @@ -4,8 +4,8 @@ "description": "Shop API for Sylius E-Commerce.", "license": "MIT", "require": { - "php": "^7.4|^8.0", - "sylius/sylius": "^1.9", + "php": "^8.0", + "sylius/sylius": "^1.10", "lexik/jwt-authentication-bundle": "^2.5", "symfony/messenger": "^4.4|^5.2", "doctrine/doctrine-bundle": "^2.0" @@ -15,8 +15,8 @@ "matthiasnoback/symfony-config-test": "^4.0", "matthiasnoback/symfony-dependency-injection-test": "^4.0", "phpspec/phpspec": "^7.0", - "phpstan/phpstan": "0.12.90", - "phpstan/phpstan-webmozart-assert": "^0.12", + "phpstan/phpstan": "0.12.96", + "phpstan/phpstan-webmozart-assert": "0.12.12", "phpunit/phpunit": "^9.0", "sylius-labs/coding-standard": "^3.0", "symfony/debug-bundle": "^4.4|^5.2", diff --git a/spec/Validator/Cart/CartEligibilityValidatorSpec.php b/spec/Validator/Cart/CartEligibilityValidatorSpec.php index 7734db7d..353cbbce 100644 --- a/spec/Validator/Cart/CartEligibilityValidatorSpec.php +++ b/spec/Validator/Cart/CartEligibilityValidatorSpec.php @@ -46,8 +46,8 @@ function it_add_no_violation_if_cart_has_eligible_item( $arrayIterator->valid()->will(new ReturnPromise(array_merge(array_fill(0, count([$orderItem]), true), [false]))); $arrayIterator->current()->will(new ReturnPromise([$orderItem])); $arrayIterator->count()->willReturn(count([$orderItem])); - $arrayIterator->next()->willReturn(); - $arrayIterator->rewind()->willReturn(); + $arrayIterator->next()->shouldBeCalled(); + $arrayIterator->rewind()->shouldBeCalled(); $arrayIterator->key()->willReturn(0); $order->getItems()->willReturn($collection); @@ -84,8 +84,8 @@ function it_add_violation_if_cart_has_non_eligible_item_variant( $arrayIterator->valid()->will(new ReturnPromise(array_merge(array_fill(0, count([$orderItem]), true), [false]))); $arrayIterator->current()->will(new ReturnPromise([$orderItem])); $arrayIterator->count()->willReturn(count([$orderItem])); - $arrayIterator->next()->willReturn(); - $arrayIterator->rewind()->willReturn(); + $arrayIterator->next()->shouldNotBeCalled(); + $arrayIterator->rewind()->shouldBeCalled(); $arrayIterator->key()->willReturn(0); $order->getItems()->willReturn($collection); @@ -121,8 +121,8 @@ function it_add_violation_if_cart_has_non_eligible_item( $arrayIterator->valid()->will(new ReturnPromise(array_merge(array_fill(0, count([$orderItem]), true), [false]))); $arrayIterator->current()->will(new ReturnPromise([$orderItem])); $arrayIterator->count()->willReturn(count([$orderItem])); - $arrayIterator->next()->willReturn(); - $arrayIterator->rewind()->willReturn(); + $arrayIterator->next()->shouldNotBeCalled(); + $arrayIterator->rewind()->shouldBeCalled(); $arrayIterator->key()->willReturn(0); $order->getItems()->willReturn($collection); diff --git a/tests/Application/Kernel.php b/tests/Application/Kernel.php index b04b0d6b..eb595c14 100644 --- a/tests/Application/Kernel.php +++ b/tests/Application/Kernel.php @@ -5,6 +5,7 @@ namespace Tests\Sylius\ShopApiPlugin\Application; use PSS\SymfonyMockerContainer\DependencyInjection\MockerContainer; +use Sylius\Bundle\CoreBundle\Application\Kernel as SyliusKernel; use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait; use Symfony\Component\Config\Loader\DelegatingLoader; use Symfony\Component\Config\Loader\LoaderInterface; @@ -43,6 +44,14 @@ public function getLogDir(): string public function registerBundles(): iterable { $contents = require $this->getProjectDir() . '/config/bundles.php'; + + if (SyliusKernel::MINOR_VERSION > 10) { + $contents = array_merge( + ['Sylius\Calendar\SyliusCalendarBundle' => ['all' => true]], + $contents + ); + } + foreach ($contents as $class => $envs) { if (isset($envs['all']) || isset($envs[$this->environment])) { yield new $class(); @@ -73,7 +82,7 @@ protected function configureRoutes(RouteCollectionBuilder $routes): void protected function getContainerBaseClass(): string { - if ($this->isTestEnvironment()) { + if ($this->isTestEnvironment() && class_exists(MockerContainer::class)) { return MockerContainer::class; }