Skip to content

Commit

Permalink
Allow for Sylius 1.8 & 1.9 and Symfony 4.4 & 5.2
Browse files Browse the repository at this point in the history
  • Loading branch information
pamil committed Feb 10, 2021
1 parent be27007 commit 1ce529d
Show file tree
Hide file tree
Showing 19 changed files with 130 additions and 39 deletions.
22 changes: 19 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
22 changes: 11 additions & 11 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
4 changes: 2 additions & 2 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/config/services/generator.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

<service id="Sylius\RefundPlugin\Generator\CreditMemoPdfFileGenerator">
<argument type="service" id="sylius_refund.repository.credit_memo" />
<argument type="service" id="templating.engine.twig" />
<argument type="service" id="twig" />
<argument type="service" id="knp_snappy.pdf" />
<argument type="service" id="file_locator" />
<argument>@SyliusRefundPlugin/Download/creditMemo.html.twig</argument>
Expand Down
67 changes: 51 additions & 16 deletions tests/Application/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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
Expand All @@ -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;
}
}
3 changes: 0 additions & 3 deletions tests/Application/config/bundles.php
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down Expand Up @@ -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],
Expand Down
2 changes: 2 additions & 0 deletions tests/Application/config/packages/_sylius.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down
1 change: 0 additions & 1 deletion tests/Application/config/packages/framework.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@ framework:
secret: '%env(APP_SECRET)%'
form: true
csrf_protection: true
templating: { engines: ["twig"] }
session:
handler_id: ~
6 changes: 6 additions & 0 deletions tests/Application/config/sylius/1.8/bundles.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php

return [
Doctrine\Bundle\DoctrineCacheBundle\DoctrineCacheBundle::class => ['all' => true],
WhiteOctober\PagerfantaBundle\WhiteOctoberPagerfantaBundle::class => ['all' => true],
];
2 changes: 2 additions & 0 deletions tests/Application/config/sylius/1.8/packages/framework.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
framework:
templating: { engines: ["twig"] }
6 changes: 6 additions & 0 deletions tests/Application/config/sylius/1.9/bundles.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php

return [
BabDev\PagerfantaBundle\BabDevPagerfantaBundle::class => ['all' => true],
SyliusLabs\Polyfill\Symfony\Security\Bundle\SyliusLabsPolyfillSymfonySecurityBundle::class => ['all' => true],
];
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
jms_serializer:
visitors:
xml_serialization:
format_output: '%kernel.debug%'
Original file line number Diff line number Diff line change
@@ -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
6 changes: 4 additions & 2 deletions tests/Application/public/index.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
<?php

declare(strict_types=1);

use Tests\Sylius\RefundPlugin\Application\Kernel;
use Symfony\Component\Debug\Debug;
use Symfony\Component\ErrorHandler\Debug;
use Symfony\Component\HttpFoundation\Request;

require dirname(__DIR__).'/config/bootstrap.php';
require dirname(__DIR__) . '/config/bootstrap.php';

if ($_SERVER['APP_DEBUG']) {
umask(0000);
Expand Down

0 comments on commit 1ce529d

Please sign in to comment.