Skip to content

Commit

Permalink
minor #227 Add support for sylius 1.11, drop support for sylius 1.9 (…
Browse files Browse the repository at this point in the history
…SirDomin)

This PR was merged into the 1.0-dev branch.

Discussion
----------

| Q               | A
| --------------- | -----
| Branch?         | master
| Bug fix?        | no
| New feature?    | no
| Related tickets | 


Commits
-------

6e86cf1 [Build] remove php 7.4 from workflow
f43a96b add phpstan array description
6557b27 [Support] drop support to sylius 1.9, add support to sylius 1.11
ffeb95a bring back 7.4
  • Loading branch information
SirDomin authored Jan 4, 2022
2 parents bde7f26 + ffeb95a commit d00e3a8
Show file tree
Hide file tree
Showing 17 changed files with 31 additions and 259 deletions.
12 changes: 5 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,14 @@ jobs:
strategy:
fail-fast: false
matrix:
php: ["8.0", "7.4"]
php: ["7.4", "8.0"]
node: ["10.x"]
mysql: ["5.7", "8.0"]
symfony: ["^4.4", "^5.2"]
sylius: ["~1.9.0", "~1.10.0"]

symfony: ["^4.4", "^5.4"]
sylius: ["~1.10.0", "^1.11.0-alpha"]
exclude:
-
php: "8.0"
sylius: "~1.9.0"
- php: "7.4"
sylius: "^1.11.0-alpha"
env:
APP_ENV: test
DATABASE_URL: "mysql://root:[email protected]/sylius?serverVersion=${{ matrix.mysql }}"
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"license": "MIT",
"require": {
"php": "^7.4 || ^8.0",

"sylius/sylius": "^1.9",
"polishsymfonycommunity/symfony-mocker-container": "^1.0",
"sylius/sylius": "^1.10",
"phpseclib/phpseclib": "^2.0",
"sylius-labs/doctrine-migrations-extra-bundle": "^0.1.3",
"doctrine/doctrine-migrations-bundle": "^3.0"
Expand Down
1 change: 1 addition & 0 deletions src/DependencyInjection/SyliusPayPalExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public function prepend(ContainerBuilder $container): void
return;
}

/** @var array<int|string, mixed> $doctrineConfig */
$doctrineConfig = $container->getExtensionConfig('doctrine_migrations');
$migrationsPath = (array) \array_pop($doctrineConfig)['migrations_paths'];
$container->prependExtensionConfig('doctrine_migrations', [
Expand Down
1 change: 1 addition & 0 deletions tests/Application/.env
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ DATABASE_URL=mysql://[email protected]/sylius_pay_pal_plugin_%kernel.environment%
# Delivery is disabled by default via "null://localhost"
MAILER_URL=smtp://localhost
###< symfony/swiftmailer-bundle ###
MESSENGER_TRANSPORT_DSN=doctrine://default
2 changes: 2 additions & 0 deletions tests/Application/.env.test
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ APP_SECRET='ch4mb3r0f5ecr3ts'
KERNEL_CLASS='Tests\Sylius\PayPalPlugin\Application\Kernel'

TEST_CLIENT_ID='AWKG4oiWX9AOifqtdkbOTgSgi3MqcaiyAt-x9Pa35lDdW94kjrOEqN-n3NQ4hD2TuomgpiDc27snMKd9'

MESSENGER_TRANSPORT_DSN=sync://
64 changes: 18 additions & 46 deletions tests/Application/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
use Symfony\Component\HttpKernel\Kernel as BaseKernel;
use Symfony\Component\Routing\RouteCollectionBuilder;
use Webmozart\Assert\Assert;

final class Kernel extends BaseKernel
{
use MicroKernelTrait;
Expand All @@ -44,73 +43,46 @@ public function getLogDir(): string

public function registerBundles(): iterable
{
foreach ($this->getConfigurationDirectories() as $confDir) {
yield from $this->registerBundlesFromFile($confDir . '/bundles.php');
$contents = require $this->getProjectDir() . '/config/bundles.php';
foreach ($contents as $class => $envs) {
if (isset($envs['all']) || isset($envs[$this->environment])) {
yield new $class();
}
}
}

protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader): void
{
foreach ($this->getConfigurationDirectories() as $confDir) {
$container->addResource(new FileResource($confDir . '/bundles.php'));
}

foreach ($this->getConfigurationDirectories() as $confDir) {
$this->loadContainerConfiguration($loader, $confDir);
}
}

protected function configureRoutes(RouteCollectionBuilder $routes): void
{
foreach ($this->getConfigurationDirectories() as $confDir) {
$this->loadRoutesConfiguration($routes, $confDir);
}
}

protected function getContainerBaseClass(): string
{
if ($this->isTestEnvironment()) {
return MockerContainer::class;
}

return parent::getContainerBaseClass();
}

private function isTestEnvironment(): bool
{
return 0 === strpos($this->getEnvironment(), 'test');
}
$container->addResource(new FileResource($this->getProjectDir() . '/config/bundles.php'));
$container->setParameter('container.dumper.inline_class_loader', true);
$confDir = $this->getProjectDir() . '/config';

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
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');
}

/** @return BundleInterface[] */
private function registerBundlesFromFile(string $bundlesFile): iterable
protected function getContainerBaseClass(): string
{
$contents = require $bundlesFile;
foreach ($contents as $class => $environments) {
if (isset($environments['all']) || isset($environments[$this->environment])) {
yield new $class();
}
if ($this->isTestEnvironment() && class_exists(MockerContainer::class)) {
return MockerContainer::class;
}

return parent::getContainerBaseClass();
}

/** @return string[] */
private function getConfigurationDirectories(): iterable
private function isTestEnvironment(): bool
{
yield $this->getProjectDir() . '/config';
yield $this->getProjectDir() . '/config/sylius/' . SyliusKernel::MAJOR_VERSION . '.' . SyliusKernel::MINOR_VERSION;
return 0 === strpos($this->getEnvironment(), 'test');
}
}
Empty file.
2 changes: 2 additions & 0 deletions tests/Application/config/bundles.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,6 @@
SyliusLabs\DoctrineMigrationsExtraBundle\SyliusLabsDoctrineMigrationsExtraBundle::class => ['all' => true],
Nelmio\Alice\Bridge\Symfony\NelmioAliceBundle::class => ['dev' => true, 'test' => true],
Fidry\AliceDataFixtures\Bridge\Symfony\FidryAliceDataFixturesBundle::class => ['dev' => true, 'test' => true],
BabDev\PagerfantaBundle\BabDevPagerfantaBundle::class => ['all' => true],
SyliusLabs\Polyfill\Symfony\Security\Bundle\SyliusLabsPolyfillSymfonySecurityBundle::class => ['all' => true],
];
6 changes: 0 additions & 6 deletions tests/Application/config/sylius/1.10/bundles.php

This file was deleted.

8 changes: 0 additions & 8 deletions tests/Application/config/sylius/1.9/bundles.php

This file was deleted.

2 changes: 0 additions & 2 deletions tests/Application/config/sylius/1.9/packages/_sylius.yaml

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

159 changes: 0 additions & 159 deletions tests/Application/config/sylius/1.9/packages/security.yaml

This file was deleted.

This file was deleted.

0 comments on commit d00e3a8

Please sign in to comment.