diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3ec73e0e..18bcc92e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -18,45 +18,54 @@ jobs: tests: runs-on: ubuntu-latest - name: "Sylius ${{ matrix.sylius }}, PHP ${{ matrix.php }}, Symfony ${{ matrix.symfony }}, MySQL ${{ matrix.mysql }}, wkhtmltopdf: ${{ matrix.wkhtmltopdf }}" + name: "Sylius ${{ matrix.sylius }}, PHP ${{ matrix.php }}, Symfony ${{ matrix.symfony }}, MySQL ${{ matrix.mysql }}, wkhtmltopdf: ${{ matrix.wkhtmltopdf }}, State Machine Adapter ${{ matrix.state_machine_adapter }}" strategy: fail-fast: false matrix: - php: ["8.0", "8.1"] - symfony: ["^5.4", "^6.0"] - sylius: ["~1.11.4", "~1.12.0"] - node: ["16.x"] - mysql: ["5.7", "8.0"] + php: ["8.1", "8.2"] + symfony: ["^5.4.21", "^6.4"] + sylius: ["~1.12.0", "~1.13.x-dev",] + node: ["20.x"] + mysql: ["8.0"] wkhtmltopdf: ["0.12.6-1"] + state_machine_adapter: [ "winzou_state_machine", "symfony_workflow" ] include: - - php: "8.1" - symfony: "^6.0" + php: "8.3" + symfony: "^6.4" + sylius: "~1.13.x-dev" + node: "20.x" + mysql: "8.0" + wkhtmltopdf: "0.12.6-1" + state_machine_adapter: "symfony_workflow" + - + php: "8.2" + symfony: "^6.4" sylius: "~1.12.0" - node: "16.x" + node: "20.x" mysql: "8.0" wkhtmltopdf: false + state_machine_adapter: "winzou_state_machine" - - php: "8.1" - symfony: "^5.4" - sylius: "~1.11.2" - node: "14.x" + php: "8.2" + symfony: "^6.4" + sylius: "~1.13.x-dev" + node: "20.x" mysql: "8.0" wkhtmltopdf: false + state_machine_adapter: "symfony_workflow" exclude: - - php: "8.0" - symfony: "^6.0" - - - symfony: "^6.0" - sylius: "~1.11.4" + sylius: "~1.12.0" + state_machine_adapter: "symfony_workflow" env: APP_ENV: test DATABASE_URL: "mysql://root:root@127.0.0.1/sylius?serverVersion=${{ matrix.mysql }}" + TEST_SYLIUS_STATE_MACHINE_ADAPTER: "${{ matrix.state_machine_adapter }}" steps: - diff --git a/UPGRADE-1.5.md b/UPGRADE-1.5.md index 5411f987..9c3413d6 100644 --- a/UPGRADE-1.5.md +++ b/UPGRADE-1.5.md @@ -16,3 +16,10 @@ constructors of `Sylius\RefundPlugin\Converter\LineItem\OrderItemUnitLineItemsConverter` and `Sylius\RefundPlugin\Converter\LineItem\ShipmentLineItemsConverter` has been deprecated and will be prohibited in 2.0. + +5. Support for Sylius 1.13 has been added, it is now the recommended Sylius version to use with RefundPlugin. + +6. Support for Sylius 1.11 has been dropped, upgrade your application to [Sylius 1.12](https://github.com/Sylius/Sylius/blob/1.12/UPGRADE-1.12.md). + or to [Sylius 1.13](https://github.com/Sylius/Sylius/blob/1.13/UPGRADE-1.13.md). + +7. Support for PHP 8.0 has been dropped. diff --git a/composer.json b/composer.json index 4008d75a..55351f76 100644 --- a/composer.json +++ b/composer.json @@ -19,41 +19,41 @@ } ], "require": { - "php": "^8.0", + "php": "^8.1", "knplabs/knp-snappy-bundle": "^1.7", "myclabs/php-enum": "^1.7", "php-http/message-factory": "^1.1", - "sylius/resource-bundle": "^1.6", - "sylius/sylius": "~1.11.4 || ~1.12.0", - "symfony/messenger": "^5.4 || ^6.0" + "sylius/resource-bundle": "^1.9", + "sylius/sylius": "~1.12.0 || ~1.13.x-dev", + "symfony/messenger": "^5.4.21 || ^6.4" }, "require-dev": { - "behat/behat": "^3.6", + "behat/behat": "^3.6.1", "behat/mink-selenium2-driver": "^1.4", "dmore/behat-chrome-extension": "^1.3", "dmore/chrome-mink-driver": "^2.7", "friends-of-behat/exclude-specifications-extension": "^0.2 || ^0.3", "friends-of-behat/mink": "^1.8", - "friends-of-behat/mink-browserkit-driver": "^1.3", + "friends-of-behat/mink-browserkit-driver": "^1.4", "friends-of-behat/mink-debug-extension": "^2.0", - "friends-of-behat/mink-extension": "^2.3", + "friends-of-behat/mink-extension": "^2.4", "friends-of-behat/page-object-extension": "^0.3", "friends-of-behat/suite-settings-extension": "^1.0", "friends-of-behat/symfony-extension": "^2.1", "friends-of-behat/variadic-extension": "^1.3", - "matthiasnoback/symfony-config-test": "^4.0", - "matthiasnoback/symfony-dependency-injection-test": "^4.1", - "phpspec/phpspec": "^7.0", - "phpstan/phpstan": "1.5.4", - "phpstan/phpstan-webmozart-assert": "1.1.2", + "matthiasnoback/symfony-config-test": "^4.2", + "matthiasnoback/symfony-dependency-injection-test": "^4.2", + "phpspec/phpspec": "^7.2", + "phpstan/phpstan": "^1.6", + "phpstan/phpstan-webmozart-assert": "^1.1", "phpunit/phpunit": "^9.5", "polishsymfonycommunity/symfony-mocker-container": "^1.0", - "sylius-labs/coding-standard": "~4.3.0", - "symfony/browser-kit": "^5.4 || ^6.0", - "symfony/debug-bundle": "^5.4 || ^6.0", - "symfony/dotenv": "^5.4 || ^6.0", + "sylius-labs/coding-standard": "^4.2", + "symfony/browser-kit": "^5.4.21 || ^6.4", + "symfony/debug-bundle": "^5.4.21 || ^6.4", + "symfony/dotenv": "^5.4.21 || ^6.4", "symfony/intl": "^5.4 || ^6.0", - "symfony/web-profiler-bundle": "^5.4 || ^6.0", + "symfony/web-profiler-bundle": "^5.4.21 || ^6.4", "symfony/webpack-encore-bundle": "^1.15" }, "conflict": { diff --git a/ecs.php b/ecs.php index 7aab94f6..4d179d7a 100644 --- a/ecs.php +++ b/ecs.php @@ -9,11 +9,19 @@ { $containerConfigurator->import('vendor/sylius-labs/coding-standard/ecs.php'); + $containerConfigurator->parallel(); $containerConfigurator->paths([ 'src/', 'spec/', ]); - $containerConfigurator->parallel(); + + $containerConfigurator->skip([ + VisibilityRequiredFixer::class => ['*Spec.php'], + InlineDocCommentDeclarationSniff::class . '.MissingVariable', + 'src/Resources/config/**', + '**/var/*', + ]); + $containerConfigurator->ruleWithConfiguration( HeaderCommentFixer::class, [ @@ -29,10 +37,4 @@ TEXT ] ); - - $containerConfigurator->skip([ - VisibilityRequiredFixer::class => ['*Spec.php'], - InlineDocCommentDeclarationSniff::class . '.MissingVariable', - '**/var/*', - ]); }; diff --git a/features/filtering_credit_memos.feature b/features/filtering_credit_memos.feature index ad8f5ee0..abed6d79 100644 --- a/features/filtering_credit_memos.feature +++ b/features/filtering_credit_memos.feature @@ -12,7 +12,7 @@ Feature: Filtering credit memos And the store has a zone "United States + United Kingdom" with code "US + UK" And this zone has the "United States" country member And this zone has the "United Kingdom" country member - And the store has a product "Mr. Meeseeks T-Shirt" priced at "$10" available in channel "Web-US" and channel "Web-UK" + And the store has a product "Mr. Meeseeks T-Shirt" priced at "$10.00" available in channel "Web-US" and channel "Web-UK" And the store ships everywhere for free for all channels And the store allows paying offline for all channels And there is a customer "rick.sanchez@wubba-lubba-dub-dub.com" that placed an order "#00000001" diff --git a/features/refunding_single_order_unit_with_promotion_applied.feature b/features/refunding_single_order_unit_with_promotion_applied.feature index f7dc9309..535a0847 100644 --- a/features/refunding_single_order_unit_with_promotion_applied.feature +++ b/features/refunding_single_order_unit_with_promotion_applied.feature @@ -10,7 +10,7 @@ Feature: Refunding a single order unit with promotion applied And the store allows shipping with "Galaxy Post" And the store allows paying with "Space money" And there is a promotion "Anatomy Park Promotion" - And this promotion gives "$1" off on every product with minimum price at "$5.00" + And this promotion gives "$1.00" off on every product with minimum price at "$5.00" And there is a customer "rick.sanchez@wubba-lubba-dub-dub.com" that placed an order "#00000022" And the customer bought 2 "Mr. Meeseeks T-Shirt" products And the customer chose "Galaxy Post" shipping method to "United States" with "Space money" payment diff --git a/phpstan.neon b/phpstan.neon index 2f5f6696..671fb399 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -10,7 +10,7 @@ parameters: checkMissingIterableValueType: false checkGenericClassInNonGenericObjectType: false - excludes_analyse: + excludePaths: # Makes PHPStan crash - 'src/DependencyInjection/Configuration.php' diff --git a/src/Resources/config/app/config.yml b/src/Resources/config/app/config.yml index c92be548..155d9cb0 100644 --- a/src/Resources/config/app/config.yml +++ b/src/Resources/config/app/config.yml @@ -1,5 +1,6 @@ imports: - { resource: "@SyliusRefundPlugin/Resources/config/app/events.yaml" } + - { resource: "@SyliusRefundPlugin/Resources/config/app/integrations.php" } parameters: sylius_refund.credit_memo_save_path: "%kernel.project_dir%/private/credit_memos/" diff --git a/src/Resources/config/app/integrations.php b/src/Resources/config/app/integrations.php new file mode 100644 index 00000000..4ca6519f --- /dev/null +++ b/src/Resources/config/app/integrations.php @@ -0,0 +1,12 @@ +import('../integrations/workflow.yaml'); + } +}; diff --git a/src/Resources/config/integrations/workflow.yaml b/src/Resources/config/integrations/workflow.yaml new file mode 100644 index 00000000..decc1053 --- /dev/null +++ b/src/Resources/config/integrations/workflow.yaml @@ -0,0 +1,17 @@ +framework: + workflows: + sylius_refund_refund_payment: + type: state_machine + marking_store: + type: method + property: state + supports: + - Sylius\RefundPlugin\Entity\RefundPayment + initial_marking: new + places: + - !php/const Sylius\RefundPlugin\Entity\RefundPaymentInterface::STATE_NEW + - !php/const Sylius\RefundPlugin\Entity\RefundPaymentInterface::STATE_COMPLETED + transitions: + complete: + from: !php/const Sylius\RefundPlugin\Entity\RefundPaymentInterface::STATE_NEW + to: !php/const Sylius\RefundPlugin\Entity\RefundPaymentInterface::STATE_COMPLETED diff --git a/tests/Application/Kernel.php b/tests/Application/Kernel.php index 2dcdfde2..e47c5e3a 100644 --- a/tests/Application/Kernel.php +++ b/tests/Application/Kernel.php @@ -5,28 +5,15 @@ namespace Tests\Sylius\RefundPlugin\Application; use PSS\SymfonyMockerContainer\DependencyInjection\MockerContainer; -use Sylius\Bundle\CoreBundle\Application\Kernel as SyliusKernel; +use Sylius\Bundle\CoreBundle\SyliusCoreBundle; use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait; -use Symfony\Component\Config\Loader\LoaderInterface; -use Symfony\Component\Config\Resource\FileResource; -use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\HttpKernel\Bundle\BundleInterface; use Symfony\Component\HttpKernel\Kernel as BaseKernel; -use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator; final class Kernel extends BaseKernel { use MicroKernelTrait; - private const CONFIG_EXTS = '.{php,xml,yaml,yml}'; - - private const IGNORED_SERVICES_DURING_CLEANUP = [ - 'kernel', - 'http_kernel', - 'liip_imagine.mime_type_guesser', - 'liip_imagine.extension_guesser', - ]; - public function getCacheDir(): string { return $this->getProjectDir() . '/var/cache/' . $this->environment; @@ -44,26 +31,6 @@ public function registerBundles(): iterable } } - protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader): void - { - foreach ($this->getBundleListFiles() as $file) { - $container->addResource(new FileResource($file)); - } - - $container->setParameter('container.dumper.inline_class_loader', true); - - foreach ($this->getConfigurationDirectories() as $confDir) { - $this->loadContainerConfiguration($loader, $confDir); - } - } - - protected function configureRoutes(RoutingConfigurator $routes): void - { - foreach ($this->getConfigurationDirectories() as $confDir) { - $this->loadRoutesConfiguration($routes, $confDir); - } - } - protected function getContainerBaseClass(): string { if ($this->isTestEnvironment() && class_exists(MockerContainer::class)) { @@ -75,22 +42,7 @@ protected function getContainerBaseClass(): string private function isTestEnvironment(): bool { - return 0 === strpos($this->getEnvironment(), 'test'); - } - - private function loadContainerConfiguration(LoaderInterface $loader, string $confDir): void - { - $loader->load($confDir . '/{packages}/*' . self::CONFIG_EXTS, 'glob'); - $loader->load($confDir . '/{packages}/' . $this->environment . '/**/*' . self::CONFIG_EXTS, 'glob'); - $loader->load($confDir . '/{services}' . self::CONFIG_EXTS, 'glob'); - $loader->load($confDir . '/{services}_' . $this->environment . self::CONFIG_EXTS, 'glob'); - } - - private function loadRoutesConfiguration(RoutingConfigurator $routes, string $confDir): void - { - $routes->import($confDir . '/{routes}/*' . self::CONFIG_EXTS); - $routes->import($confDir . '/{routes}/' . $this->environment . '/**/*' . self::CONFIG_EXTS); - $routes->import($confDir . '/{routes}' . self::CONFIG_EXTS); + return str_starts_with($this->getEnvironment(), 'test'); } /** @@ -100,6 +52,7 @@ private function registerBundlesFromFile(string $bundlesFile): iterable { $contents = require $bundlesFile; + /** @var BundleInterface $class */ foreach ($contents as $class => $envs) { if (isset($envs['all']) || isset($envs[$this->environment])) { yield new $class(); @@ -130,7 +83,7 @@ private function getConfigurationDirectories(): array { $directories = [ $this->getProjectDir() . '/config', - $this->getProjectDir() . '/config/sylius/' . SyliusKernel::MAJOR_VERSION . '.' . SyliusKernel::MINOR_VERSION, + $this->getProjectDir() . '/config/sylius/' . SyliusCoreBundle::MAJOR_VERSION . '.' . SyliusCoreBundle::MINOR_VERSION, ]; return array_filter($directories, 'file_exists'); diff --git a/tests/Application/config/bundles.php b/tests/Application/config/bundles.php index 143e9c41..f82c7db5 100644 --- a/tests/Application/config/bundles.php +++ b/tests/Application/config/bundles.php @@ -1,6 +1,6 @@ ['all' => true], @@ -8,6 +8,7 @@ Symfony\Bundle\SecurityBundle\SecurityBundle::class => ['all' => true], Symfony\Bundle\TwigBundle\TwigBundle::class => ['all' => true], Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class => ['all' => true], + League\FlysystemBundle\FlysystemBundle::class => ['all' => true], Sylius\Bundle\OrderBundle\SyliusOrderBundle::class => ['all' => true], Sylius\Bundle\MoneyBundle\SyliusMoneyBundle::class => ['all' => true], Sylius\Bundle\CurrencyBundle\SyliusCurrencyBundle::class => ['all' => true], @@ -61,10 +62,8 @@ Symfony\WebpackEncoreBundle\WebpackEncoreBundle::class => ['all' => true], ]; -if (SyliusKernel::MINOR_VERSION > 11) { - $bundles[League\FlysystemBundle\FlysystemBundle::class] = ['all' => true]; -} else { - $bundles[Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle::class] = ['all' => true]; +if (SyliusCoreBundle::VERSION_ID >= '11300') { + $bundles[Sylius\Abstraction\StateMachine\SyliusStateMachineAbstractionBundle::class] = ['all' => true]; } return $bundles; diff --git a/tests/Application/config/sylius/1.12/packages/mailer.yaml b/tests/Application/config/packages/mailer.yaml similarity index 100% rename from tests/Application/config/sylius/1.12/packages/mailer.yaml rename to tests/Application/config/packages/mailer.yaml diff --git a/tests/Application/config/sylius/1.12/packages/test/mailer.yaml b/tests/Application/config/packages/test/mailer.yaml similarity index 75% rename from tests/Application/config/sylius/1.12/packages/test/mailer.yaml rename to tests/Application/config/packages/test/mailer.yaml index 52610d69..092eb288 100644 --- a/tests/Application/config/sylius/1.12/packages/test/mailer.yaml +++ b/tests/Application/config/packages/test/mailer.yaml @@ -1,4 +1,6 @@ framework: + mailer: + dsn: 'null://null' cache: pools: test.mailer_pool: diff --git a/tests/Application/config/sylius/1.12/packages/test_cached/mailer.yaml b/tests/Application/config/packages/test_cached/mailer.yaml similarity index 100% rename from tests/Application/config/sylius/1.12/packages/test_cached/mailer.yaml rename to tests/Application/config/packages/test_cached/mailer.yaml diff --git a/tests/Application/config/sylius/1.11/packages/dev/swiftmailer.yaml b/tests/Application/config/sylius/1.11/packages/dev/swiftmailer.yaml deleted file mode 100644 index f4380780..00000000 --- a/tests/Application/config/sylius/1.11/packages/dev/swiftmailer.yaml +++ /dev/null @@ -1,2 +0,0 @@ -swiftmailer: - disable_delivery: true diff --git a/tests/Application/config/sylius/1.11/packages/staging/swiftmailer.yaml b/tests/Application/config/sylius/1.11/packages/staging/swiftmailer.yaml deleted file mode 100644 index 98d6b73b..00000000 --- a/tests/Application/config/sylius/1.11/packages/staging/swiftmailer.yaml +++ /dev/null @@ -1,2 +0,0 @@ -imports: - - { resource: "../dev/mailer.yaml" } diff --git a/tests/Application/config/sylius/1.11/packages/swiftmailer.yaml b/tests/Application/config/sylius/1.11/packages/swiftmailer.yaml deleted file mode 100644 index 3bab0d32..00000000 --- a/tests/Application/config/sylius/1.11/packages/swiftmailer.yaml +++ /dev/null @@ -1,2 +0,0 @@ -swiftmailer: - url: '%env(MAILER_URL)%' diff --git a/tests/Application/config/sylius/1.11/packages/test/swiftmailer.yaml b/tests/Application/config/sylius/1.11/packages/test/swiftmailer.yaml deleted file mode 100644 index c438f4b2..00000000 --- a/tests/Application/config/sylius/1.11/packages/test/swiftmailer.yaml +++ /dev/null @@ -1,6 +0,0 @@ -swiftmailer: - disable_delivery: true - logging: true - spool: - type: file - path: "%kernel.cache_dir%/spool" diff --git a/tests/Application/config/sylius/1.11/packages/test_cached/swiftmailer.yaml b/tests/Application/config/sylius/1.11/packages/test_cached/swiftmailer.yaml deleted file mode 100644 index 16f3170a..00000000 --- a/tests/Application/config/sylius/1.11/packages/test_cached/swiftmailer.yaml +++ /dev/null @@ -1,2 +0,0 @@ -imports: - - { resource: "../test/mailer.yaml" } diff --git a/tests/Application/config/sylius/1.13/_sylius.yaml b/tests/Application/config/sylius/1.13/_sylius.yaml new file mode 100644 index 00000000..76aa43aa --- /dev/null +++ b/tests/Application/config/sylius/1.13/_sylius.yaml @@ -0,0 +1,7 @@ +parameters: + test_default_state_machine_adapter: 'symfony_workflow' + test_sylius_state_machine_adapter: '%env(string:default:test_default_state_machine_adapter:TEST_SYLIUS_STATE_MACHINE_ADAPTER)%' + +sylius_state_machine_abstraction: + graphs_to_adapters_mapping: + sylius_refund_refund_payment: '%test_sylius_state_machine_adapter%' diff --git a/tests/Application/package.json b/tests/Application/package.json index 94b2d1c8..d9d9b90d 100644 --- a/tests/Application/package.json +++ b/tests/Application/package.json @@ -52,7 +52,7 @@ "yargs": "^17.5.1" }, "engines": { - "node": "^14 || ^16 || ^18 || ^19" + "node": "^18 || ^20" }, "engineStrict": true, "scripts": { diff --git a/tests/Application/public/media/image/.gitignore b/tests/Application/public/media/image/.gitignore deleted file mode 100644 index e69de29b..00000000