diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 99ed9722a..4e89a9421 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -11,22 +11,26 @@ on: jobs: tests: - runs-on: ubuntu-latest + runs-on: ubuntu-18.04 - name: "PHP ${{ matrix.php }}, MySQL ${{ matrix.mysql }}, Sylius ${{ matrix.sylius }}" + name: "Sylius ${{ matrix.sylius }}, PHP ${{ matrix.php }}, Symfony ${{ matrix.symfony }}, MySQL ${{ matrix.mysql }}" strategy: fail-fast: false matrix: php: [7.4, 7.3] + symfony: [^4.4, ^5.2] + sylius: [~1.8.0, ~1.9.0@beta] node: [10.x] mysql: [5.7, 8.0] - sylius: [1.8.*] exclude: - php: 7.3 mysql: 8.0 + - + sylius: ~1.8.0 + symfony: ^5.2 env: APP_ENV: test @@ -101,6 +105,18 @@ jobs: run: | composer require "sylius/sylius:${{ matrix.sylius }}" --no-update + - + name: Restrict Symfony version + if: matrix.symfony != '' + run: | + composer global require --no-progress --no-scripts --no-plugins "symfony/flex:^1.10" + composer config extra.symfony.require "${{ matrix.symfony }}" + + - + name: Restrict Sylius version + if: matrix.sylius != '' + run: composer require "sylius/sylius:${{ matrix.sylius }}" --no-update --no-scripts --no-interaction + - name: Install PHP dependencies run: composer update --no-interaction diff --git a/composer.json b/composer.json index 62f1d58ce..d0f848a9e 100644 --- a/composer.json +++ b/composer.json @@ -23,33 +23,33 @@ "knplabs/knp-snappy-bundle": "^1.7", "myclabs/php-enum": "^1.7", "sylius/resource-bundle": "^1.6", - "sylius/sylius": "^1.8", - "symfony/messenger": "^4.4" + "sylius/sylius": "~1.8.0 || ~1.9.0@beta", + "symfony/messenger": "^4.4 || ^5.2" }, "require-dev": { "behat/behat": "^3.6", - "behat/mink": "^1.8", - "behat/mink-browserkit-driver": "^1.3", - "behat/mink-extension": "^2.3", "behat/mink-selenium2-driver": "^1.4", "dmore/behat-chrome-extension": "^1.3", "dmore/chrome-mink-driver": "^2.7", + "friends-of-behat/mink": "^1.8", + "friends-of-behat/mink-browserkit-driver": "^1.3", + "friends-of-behat/mink-extension": "^2.3", "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", + "friendsofsymfony/oauth-server-bundle": "^1.6 || >2.0.0-alpha.0 ^2.0@dev", "lakion/mink-debug-extension": "^1.2.3", "phpspec/phpspec": "^6.0", "phpstan/phpstan": "0.12.29", "phpstan/phpstan-webmozart-assert": "0.12.6", "phpunit/phpunit": "^8.5", "sylius-labs/coding-standard": "^3.2", - "symfony/browser-kit": "^4.4", - "symfony/debug-bundle": "^4.4", - "symfony/dotenv": "^4.4", - "symfony/intl": "^4.4", - "symfony/web-profiler-bundle": "^4.4", - "symfony/web-server-bundle": "^4.4" + "symfony/browser-kit": "^4.4 || ^5.2", + "symfony/debug-bundle": "^4.4 || ^5.2", + "symfony/dotenv": "^4.4 || ^5.2", + "symfony/intl": "^4.4 || ^5.2", + "symfony/web-profiler-bundle": "^4.4 || ^5.2" }, "autoload": { "psr-4": { diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index 71079858e..c0456fcb5 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -14,8 +14,8 @@ final class Configuration implements ConfigurationInterface */ public function getConfigTreeBuilder(): TreeBuilder { - $treeBuilder = new TreeBuilder(); - $rootNode = $treeBuilder->root('sylius_refund_plugin'); + $treeBuilder = new TreeBuilder('sylius_refund_plugin'); + $rootNode = $treeBuilder->getRootNode(); return $treeBuilder; } diff --git a/src/Resources/config/services/generator.xml b/src/Resources/config/services/generator.xml index 5721b83b8..92a33ff5e 100644 --- a/src/Resources/config/services/generator.xml +++ b/src/Resources/config/services/generator.xml @@ -22,7 +22,7 @@ - + @SyliusRefundPlugin/Download/creditMemo.html.twig diff --git a/tests/Application/Kernel.php b/tests/Application/Kernel.php index 0da88b306..6038b297d 100644 --- a/tests/Application/Kernel.php +++ b/tests/Application/Kernel.php @@ -6,11 +6,13 @@ use ProxyManager\Proxy\VirtualProxyInterface; use PSS\SymfonyMockerContainer\DependencyInjection\MockerContainer; +use Sylius\Bundle\CoreBundle\Application\Kernel as SyliusKernel; 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\DependencyInjection\ContainerInterface; +use Symfony\Component\HttpKernel\Bundle\BundleInterface; use Symfony\Component\HttpKernel\Kernel as BaseKernel; use Symfony\Component\Routing\RouteCollectionBuilder; @@ -39,33 +41,29 @@ public function getLogDir(): string public function registerBundles(): iterable { - $contents = require $this->getProjectDir() . '/config/bundles.php'; - foreach ($contents as $class => $envs) { - if (isset($envs['all']) || isset($envs[$this->environment])) { - yield new $class(); - } + foreach ($this->getConfigurationDirectories() as $confDir) { + yield from $this->registerBundlesFromFile($confDir . '/bundles.php'); } } protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader): void { - $container->addResource(new FileResource($this->getProjectDir() . '/config/bundles.php')); + foreach ($this->getConfigurationDirectories() as $confDir) { + $container->addResource(new FileResource($confDir . '/bundles.php')); + } + $container->setParameter('container.dumper.inline_class_loader', true); - $confDir = $this->getProjectDir() . '/config'; - $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'); + foreach ($this->getConfigurationDirectories() as $confDir) { + $this->loadContainerConfiguration($loader, $confDir); + } } protected function configureRoutes(RouteCollectionBuilder $routes): void { - $confDir = $this->getProjectDir() . '/config'; - - $routes->import($confDir . '/{routes}/*' . self::CONFIG_EXTS, '/', 'glob'); - $routes->import($confDir . '/{routes}/' . $this->environment . '/**/*' . self::CONFIG_EXTS, '/', 'glob'); - $routes->import($confDir . '/{routes}' . self::CONFIG_EXTS, '/', 'glob'); + foreach ($this->getConfigurationDirectories() as $confDir) { + $this->loadRoutesConfiguration($routes, $confDir); + } } protected function getContainerBaseClass(): string @@ -81,4 +79,41 @@ 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(RouteCollectionBuilder $routes, string $confDir): void + { + $routes->import($confDir . '/{routes}/*' . self::CONFIG_EXTS, '/', 'glob'); + $routes->import($confDir . '/{routes}/' . $this->environment . '/**/*' . self::CONFIG_EXTS, '/', 'glob'); + $routes->import($confDir . '/{routes}' . self::CONFIG_EXTS, '/', 'glob'); + } + + /** + * @return BundleInterface[] + */ + private function registerBundlesFromFile(string $bundlesFile): iterable + { + $contents = require $bundlesFile; + foreach ($contents as $class => $envs) { + if (isset($envs['all']) || isset($envs[$this->environment])) { + yield new $class(); + } + } + } + + /** + * @return string[] + */ + private function getConfigurationDirectories(): iterable + { + yield $this->getProjectDir() . '/config'; + yield $this->getProjectDir() . '/config/sylius/' . SyliusKernel::MAJOR_VERSION . '.' . SyliusKernel::MINOR_VERSION; + } } diff --git a/tests/Application/config/bundles.php b/tests/Application/config/bundles.php index 2ac911a99..9d9790ccd 100644 --- a/tests/Application/config/bundles.php +++ b/tests/Application/config/bundles.php @@ -7,7 +7,6 @@ Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle::class => ['all' => true], Symfony\Bundle\TwigBundle\TwigBundle::class => ['all' => true], Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class => ['all' => true], - Doctrine\Bundle\DoctrineCacheBundle\DoctrineCacheBundle::class => ['all' => true], Sylius\Bundle\OrderBundle\SyliusOrderBundle::class => ['all' => true], Sylius\Bundle\MoneyBundle\SyliusMoneyBundle::class => ['all' => true], Sylius\Bundle\CurrencyBundle\SyliusCurrencyBundle::class => ['all' => true], @@ -40,12 +39,10 @@ Liip\ImagineBundle\LiipImagineBundle::class => ['all' => true], Payum\Bundle\PayumBundle\PayumBundle::class => ['all' => true], Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle::class => ['all' => true], - WhiteOctober\PagerfantaBundle\WhiteOctoberPagerfantaBundle::class => ['all' => true], Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle::class => ['all' => true], Sylius\Bundle\FixturesBundle\SyliusFixturesBundle::class => ['all' => true], Sylius\Bundle\PayumBundle\SyliusPayumBundle::class => ['all' => true], Sylius\Bundle\ThemeBundle\SyliusThemeBundle::class => ['all' => true], - Symfony\Bundle\WebServerBundle\WebServerBundle::class => ['all' => true], Sylius\Bundle\AdminBundle\SyliusAdminBundle::class => ['all' => true], Sylius\Bundle\ShopBundle\SyliusShopBundle::class => ['all' => true], FOS\OAuthServerBundle\FOSOAuthServerBundle::class => ['all' => true], diff --git a/tests/Application/config/packages/_sylius.yaml b/tests/Application/config/packages/_sylius.yaml index 8ad31ca4a..aa0c8387c 100644 --- a/tests/Application/config/packages/_sylius.yaml +++ b/tests/Application/config/packages/_sylius.yaml @@ -6,6 +6,8 @@ imports: - { resource: "@SyliusShopBundle/Resources/config/app/config.yml" } + - { resource: "@SyliusApiBundle/Resources/config/app/config.yaml" } + parameters: sylius_core.public_dir: '%kernel.project_dir%/public' diff --git a/tests/Application/config/packages/framework.yaml b/tests/Application/config/packages/framework.yaml index e74ed811e..9b445011c 100644 --- a/tests/Application/config/packages/framework.yaml +++ b/tests/Application/config/packages/framework.yaml @@ -2,6 +2,5 @@ framework: secret: '%env(APP_SECRET)%' form: true csrf_protection: true - templating: { engines: ["twig"] } session: handler_id: ~ diff --git a/tests/Application/config/sylius/1.8/bundles.php b/tests/Application/config/sylius/1.8/bundles.php new file mode 100644 index 000000000..74ee2bc02 --- /dev/null +++ b/tests/Application/config/sylius/1.8/bundles.php @@ -0,0 +1,6 @@ + ['all' => true], + WhiteOctober\PagerfantaBundle\WhiteOctoberPagerfantaBundle::class => ['all' => true], +]; diff --git a/tests/Application/config/packages/dev/jms_serializer.yaml b/tests/Application/config/sylius/1.8/packages/dev/jms_serializer.yaml similarity index 100% rename from tests/Application/config/packages/dev/jms_serializer.yaml rename to tests/Application/config/sylius/1.8/packages/dev/jms_serializer.yaml diff --git a/tests/Application/config/sylius/1.8/packages/framework.yaml b/tests/Application/config/sylius/1.8/packages/framework.yaml new file mode 100644 index 000000000..62f82d357 --- /dev/null +++ b/tests/Application/config/sylius/1.8/packages/framework.yaml @@ -0,0 +1,2 @@ +framework: + templating: { engines: ["twig"] } diff --git a/tests/Application/config/packages/jms_serializer.yaml b/tests/Application/config/sylius/1.8/packages/jms_serializer.yaml similarity index 100% rename from tests/Application/config/packages/jms_serializer.yaml rename to tests/Application/config/sylius/1.8/packages/jms_serializer.yaml diff --git a/tests/Application/config/packages/prod/jms_serializer.yaml b/tests/Application/config/sylius/1.8/packages/prod/jms_serializer.yaml similarity index 100% rename from tests/Application/config/packages/prod/jms_serializer.yaml rename to tests/Application/config/sylius/1.8/packages/prod/jms_serializer.yaml diff --git a/tests/Application/config/routes/dev/twig.yaml b/tests/Application/config/sylius/1.8/routes/dev/twig.yaml similarity index 100% rename from tests/Application/config/routes/dev/twig.yaml rename to tests/Application/config/sylius/1.8/routes/dev/twig.yaml diff --git a/tests/Application/config/sylius/1.9/bundles.php b/tests/Application/config/sylius/1.9/bundles.php new file mode 100644 index 000000000..bd33f4ae8 --- /dev/null +++ b/tests/Application/config/sylius/1.9/bundles.php @@ -0,0 +1,6 @@ + ['all' => true], + SyliusLabs\Polyfill\Symfony\Security\Bundle\SyliusLabsPolyfillSymfonySecurityBundle::class => ['all' => true], +]; diff --git a/tests/Application/config/sylius/1.9/packages/dev/jms_serializer.yaml b/tests/Application/config/sylius/1.9/packages/dev/jms_serializer.yaml new file mode 100644 index 000000000..2f32a9b18 --- /dev/null +++ b/tests/Application/config/sylius/1.9/packages/dev/jms_serializer.yaml @@ -0,0 +1,12 @@ +jms_serializer: + visitors: + json_serialization: + options: + - JSON_PRETTY_PRINT + - JSON_UNESCAPED_SLASHES + - JSON_PRESERVE_ZERO_FRACTION + json_deserialization: + options: + - JSON_PRETTY_PRINT + - JSON_UNESCAPED_SLASHES + - JSON_PRESERVE_ZERO_FRACTION diff --git a/tests/Application/config/sylius/1.9/packages/jms_serializer.yaml b/tests/Application/config/sylius/1.9/packages/jms_serializer.yaml new file mode 100644 index 000000000..ed7bc613f --- /dev/null +++ b/tests/Application/config/sylius/1.9/packages/jms_serializer.yaml @@ -0,0 +1,4 @@ +jms_serializer: + visitors: + xml_serialization: + format_output: '%kernel.debug%' diff --git a/tests/Application/config/sylius/1.9/packages/prod/jms_serializer.yaml b/tests/Application/config/sylius/1.9/packages/prod/jms_serializer.yaml new file mode 100644 index 000000000..c2881820f --- /dev/null +++ b/tests/Application/config/sylius/1.9/packages/prod/jms_serializer.yaml @@ -0,0 +1,10 @@ +jms_serializer: + visitors: + json_serialization: + options: + - JSON_UNESCAPED_SLASHES + - JSON_PRESERVE_ZERO_FRACTION + json_deserialization: + options: + - JSON_UNESCAPED_SLASHES + - JSON_PRESERVE_ZERO_FRACTION diff --git a/tests/Application/public/index.php b/tests/Application/public/index.php index b35db6266..7840b1527 100644 --- a/tests/Application/public/index.php +++ b/tests/Application/public/index.php @@ -1,10 +1,12 @@