Skip to content

Commit

Permalink
minor #424 Update plugin to sylius 1.13. (BartoszWojdalowicz)
Browse files Browse the repository at this point in the history
This PR was merged into the 1.5 branch.

Discussion
----------

| Q               | A
| --------------- | -----
| Branch?         | 1.5 (new features)
| Bug fix?        | no/
| New feature?    | no
| Related tickets | -


Commits
-------
  Sylius 1.13 - Update composer.json
  Sylius 1.13 - Add workflow configuration
  Sylius 1.13 - Remove deprecation
  Sylius 1.13 - Update gh actions config
  Sylius 1.13 - Update bundles.php in test application
  Sylius 1.13 - Update bundles.php in test application
  Sylius 1.13 - add workflow configuration only in 1.13, add workflow to the gh actions
  Sylius 1.13 - add mailer configuration to the 1.13 version
  Sylius 1.13 - add mailer configuration in the global config of test app
  Sylius 1.13 - adapt state machine configuration per version
  Sylius 1.13 - fix composer.json problem
  Sylius 1.13 - try to fix problem with not existing service
  Sylius 1.13 - unlock sylius 13 version in gh actions
  Sylius 1.13 - fix behats scenarios
  Sylius 1.13 - Add info about state machine adapter in gh actions
  Sylius 1.13 - Add missing info about symfony workflow in readme
  Sylius 1.13 - Fix duplicated configuration key
  [Maintenance] Slight fixes of 1.13 support
  [Maintenance] Update builds
  • Loading branch information
TheMilek authored Mar 5, 2024
2 parents 0054251 + 95884bb commit 99c0f78
Show file tree
Hide file tree
Showing 23 changed files with 111 additions and 116 deletions.
45 changes: 27 additions & 18 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
-
Expand Down
7 changes: 7 additions & 0 deletions UPGRADE-1.5.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
34 changes: 17 additions & 17 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
16 changes: 9 additions & 7 deletions ecs.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
[
Expand All @@ -29,10 +37,4 @@
TEXT
]
);

$containerConfigurator->skip([
VisibilityRequiredFixer::class => ['*Spec.php'],
InlineDocCommentDeclarationSniff::class . '.MissingVariable',
'**/var/*',
]);
};
2 changes: 1 addition & 1 deletion features/filtering_credit_memos.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ parameters:
checkMissingIterableValueType: false
checkGenericClassInNonGenericObjectType: false

excludes_analyse:
excludePaths:
# Makes PHPStan crash
- 'src/DependencyInjection/Configuration.php'

Expand Down
1 change: 1 addition & 0 deletions src/Resources/config/app/config.yml
Original file line number Diff line number Diff line change
@@ -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/"
Expand Down
12 changes: 12 additions & 0 deletions src/Resources/config/app/integrations.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

declare(strict_types=1);

use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;

return static function (ContainerConfigurator $configurator, ContainerBuilder $container): void {
if (class_exists('\Symfony\Component\Workflow\Workflow')) {
$configurator->import('../integrations/workflow.yaml');
}
};
17 changes: 17 additions & 0 deletions src/Resources/config/integrations/workflow.yaml
Original file line number Diff line number Diff line change
@@ -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
55 changes: 4 additions & 51 deletions tests/Application/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)) {
Expand All @@ -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');
}

/**
Expand All @@ -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();
Expand Down Expand Up @@ -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');
Expand Down
9 changes: 4 additions & 5 deletions tests/Application/config/bundles.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
<?php

use Sylius\Bundle\CoreBundle\Application\Kernel as SyliusKernel;
use Sylius\Bundle\CoreBundle\SyliusCoreBundle;

$bundles = [
Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true],
Symfony\Bundle\MonologBundle\MonologBundle::class => ['all' => true],
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],
Expand Down Expand Up @@ -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;
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
framework:
mailer:
dsn: 'null://null'
cache:
pools:
test.mailer_pool:
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 99c0f78

Please sign in to comment.