Skip to content

Commit

Permalink
Update to Symfony 6
Browse files Browse the repository at this point in the history
  • Loading branch information
Valentin Silvestre committed Dec 22, 2022
1 parent 0268bf9 commit 5aed2ec
Show file tree
Hide file tree
Showing 25 changed files with 107 additions and 233 deletions.
56 changes: 3 additions & 53 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,61 +21,16 @@ jobs:
strategy:
fail-fast: false
matrix:
php: [7.3, 7.4, 8.0, 8.1]
symfony: [^4.4, ^5.4, ^6.0]
sylius: [~1.8.0, ~1.9.0, ~1.10.0, ~1.11.0, ~1.12.x-dev]
php: [8.0, 8.1]
symfony: [^5.4, ^6.0]
sylius: [~1.11.0, ~1.12.0]
node: [14.x]
mysql: [5.7]

exclude:
-
sylius: ~1.8.0
symfony: ^5.4
-
sylius: ~1.8.0
symfony: ^6.0
-
sylius: ~1.9.0
symfony: ^6.0
-
sylius: ~1.10.0
symfony: ^6.0
-
sylius: ~1.11.0
symfony: ^6.0
-
sylius: ~1.8.0
symfony: ^6.0
-
sylius: ~1.12.x-dev
symfony: ^4.4
-
sylius: ~1.8.0
php: 8.0
-
sylius: ~1.9.0
php: 8.0
-
sylius: ~1.8.0
php: 8.1
-
sylius: ~1.9.0
php: 8.1
-
sylius: ~1.10.0
php: 7.3
-
sylius: ~1.11.0
php: 7.3
-
sylius: ~1.11.0
php: 7.4
-
sylius: ~1.12.x-dev
php: 7.3
-
sylius: ~1.12.x-dev
php: 7.4

env:
APP_ENV: test
Expand Down Expand Up @@ -154,11 +109,6 @@ jobs:
if: matrix.sylius != ''
run: composer require "sylius/sylius:${{ matrix.sylius }}" --no-update --no-scripts --no-interaction

-
name: Add Admin API Bundle for Sylius >= 1.10
if: matrix.sylius != '~1.8.0' && matrix.sylius != '~1.9.0'
run: composer require sylius/admin-api-bundle --no-update --no-scripts --no-interaction

-
name: Install PHP dependencies
run: composer install --no-interaction
Expand Down
34 changes: 16 additions & 18 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
"description": "import / export plugin for Sylius.",
"license": "MIT",
"require": {
"sylius/sylius": "^1.8",
"php": "^8.0",
"sylius/sylius": "~1.11.0 || ~1.12.0",
"portphp/portphp": "^1.2",
"symfony/stopwatch": "^4.4 || ^5.2",
"queue-interop/queue-interop": "^0.6.2 || ^0.7 || ^0.8"
"queue-interop/queue-interop": "^0.6.2 || ^0.7 || ^0.8",
"symfony/stopwatch": "^5.2 || ^6.0"
},
"suggest": {
"portphp/spreadsheet": "To support importing Excel and LibreOffice Calc files, use version ^1.1",
Expand All @@ -17,35 +18,32 @@
"enqueue/sqs" : "To support message queuing via sqs"
},
"require-dev": {
"behat/behat": "^3.6.1",
"behat/mink": "^1.8",
"behat/mink-selenium2-driver": "^1.3",
"behat/behat": "^3.7",
"behat/mink-selenium2-driver": "^1.4",
"enqueue/redis": "^0.8.23",
"friendsofsymfony/oauth-server-bundle": "^1.6 || >2.0.0-alpha.0 ^2.0@dev",
"friends-of-behat/mink": "^1.8",
"friends-of-behat/mink-browserkit-driver": "^1.4",
"friends-of-behat/mink-extension": "^2.4",
"friends-of-behat/mink-debug-extension": "^2.0",
"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.2",
"friends-of-behat/variadic-extension": "^1.1",
"friends-of-behat/symfony-extension": "^2.1",
"friends-of-behat/variadic-extension": "^1.3",
"phpspec/phpspec": "^7.0",
"phpstan/extension-installer": "^1.0",
"phpstan/phpstan": "0.12.82",
"phpstan/phpstan-doctrine": "0.12.33",
"phpstan/phpstan-strict-rules": "^0.12.0",
"phpstan/phpstan-webmozart-assert": "0.12.12",
"phpunit/phpunit": "^9.5",
"sensiolabs/security-checker": "^6.0",
"sylius-labs/coding-standard": "^3.2 || ^4.0",
"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/mailer": "^4.4 || ^5.2",
"symfony/browser-kit": "^5.4 || ^6.0",
"symfony/debug-bundle": "^5.4 || ^6.0",
"symfony/dotenv": "^5.4 || ^6.0",
"symfony/intl": "^5.4 || ^6.0",
"symfony/mailer": "^5.4 || ^6.0",
"symfony/webpack-encore-bundle": "^1.15",
"symfony/web-profiler-bundle": "^4.4 || ^5.2",
"symfony/web-server-bundle": "^4.4 || ^5.2",
"symfony/web-profiler-bundle": "^5.4 || ^6.0",
"portphp/csv": "^1.1.0",
"portphp/spreadsheet": "^1.0.0-alpha",
"predis/predis": "^1.1"
Expand Down
2 changes: 1 addition & 1 deletion spec/Exporter/ResourceExporterSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function it_should_export_but_also_transform(
PluginInterface $plugin
) {
$generator = new RewindableGenerator(function () {
return [new DateTimeToStringHandler()];
yield new DateTimeToStringHandler();
}, $count = 1);

$pool = new Pool($generator);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function it_should_process_via_pool()
$array = ['a', 'b', 'c'];

$generator = new RewindableGenerator(function () {
return [$this->getWrappedObject()];
yield $this->getWrappedObject();
}, $count = 1);

$pool = new Pool($generator);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function it_should_process_via_pool()
$date = \DateTime::createFromFormat('Y-m-d', '2018-01-01');

$generator = new RewindableGenerator(function () {
return [$this->getWrappedObject()];
yield $this->getWrappedObject();
}, $count = 1);

$pool = new Pool($generator);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use FriendsOfSylius\SyliusImportExportPlugin\Exporter\Transformer\HandlerInterface;
use FriendsOfSylius\SyliusImportExportPlugin\Exporter\Transformer\Pool;
use PhpSpec\ObjectBehavior;
use Prophecy\Prophet;
use Symfony\Component\DependencyInjection\Argument\RewindableGenerator;
use Webmozart\Assert\Assert;

Expand Down Expand Up @@ -38,12 +39,13 @@ function it_should_process_directly()
{
$this->handle('test', 10000)->shouldBeString();
$this->handle('test', 12345)->shouldBe('123.45');
$this->handle('test', 987654)->shouldBe('9876.54');
}

function it_should_process_via_pool()
{
$generator = new RewindableGenerator(function () {
return [$this->getWrappedObject()];
yield $this->getWrappedObject();
}, $count = 1);

$pool = new Pool($generator);
Expand Down
4 changes: 2 additions & 2 deletions spec/Exporter/Transformer/PoolSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ function it_should_implement_interface()

function let(HandlerInterface $dateTimeToStringHandler)
{
$generator = new RewindableGenerator(function () use ($dateTimeToStringHandler) {
return [$dateTimeToStringHandler];
$generator = new RewindableGenerator(function () use ($dateTimeToStringHandler): \Traversable {
yield $dateTimeToStringHandler;
}, $count = 1);

$this->beConstructedWith($generator);
Expand Down
2 changes: 1 addition & 1 deletion spec/Importer/JsonResourceImporterSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace spec\FriendsOfSylius\SyliusImportExportPlugin\Importer;

use Doctrine\Common\Persistence\ObjectManager;
use Doctrine\Persistence\ObjectManager;
use FriendsOfSylius\SyliusImportExportPlugin\Importer\ImporterResultInterface;
use FriendsOfSylius\SyliusImportExportPlugin\Importer\ImportResultLoggerInterface;
use FriendsOfSylius\SyliusImportExportPlugin\Importer\JsonResourceImporter;
Expand Down
2 changes: 1 addition & 1 deletion spec/Importer/ResourceImporterSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace spec\FriendsOfSylius\SyliusImportExportPlugin\Importer;

use Doctrine\Common\Persistence\ObjectManager;
use Doctrine\Persistence\ObjectManager;
use FriendsOfSylius\SyliusImportExportPlugin\Importer\ImporterInterface;
use FriendsOfSylius\SyliusImportExportPlugin\Importer\ImporterResultInterface;
use FriendsOfSylius\SyliusImportExportPlugin\Importer\ImportResultLoggerInterface;
Expand Down
5 changes: 3 additions & 2 deletions src/Controller/ImportDataController.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use Symfony\Component\HttpFoundation\File\UploadedFile;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface;
use Twig\Environment;
Expand All @@ -35,14 +36,14 @@ final class ImportDataController

public function __construct(
ServiceRegistryInterface $registry,
FlashBagInterface $flashBag,
RequestStack $requestStack,
FormFactoryInterface $formFactory,
Environment $twig
) {
$this->registry = $registry;
$this->formFactory = $formFactory;
$this->twig = $twig;
$this->flashBag = $flashBag;
$this->flashBag = $requestStack->getCurrentRequest()->getSession()->getFlashBag();
}

public function importFormAction(Request $request): Response
Expand Down
6 changes: 3 additions & 3 deletions src/DependencyInjection/ParameterBag/ParameterBag.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,23 @@ public function __construct(Container $container)
/**
* {@inheritdoc}
*/
public function all()
public function all(): array
{
return $this->container->getParameterBag()->all();
}

/**
* {@inheritdoc}
*/
public function get($name)
public function get($name): array|bool|string|int|float|\UnitEnum|null
{
return $this->container->getParameter($name);
}

/**
* {@inheritdoc}
*/
public function has($name)
public function has($name): bool
{
return $this->container->hasParameter($name);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ final class IntegerToMoneyFormatHandler extends Handler
/**
* @param string[] $allowedKeys
*/
public function __construct(array $allowedKeys, string $format = '%.2n')
public function __construct(array $allowedKeys, string $format = '%0.2f')
{
$this->keys = $allowedKeys;
$this->format = $format;
Expand All @@ -28,7 +28,7 @@ public function __construct(array $allowedKeys, string $format = '%.2n')
*/
protected function process($key, $value): ?string
{
return money_format($this->format, $value / 100);
return sprintf($this->format, $value / 100);
}

protected function allows($key, $value): bool
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ services:
class: FriendsOfSylius\SyliusImportExportPlugin\Controller\ImportDataController
arguments:
- "@sylius.importers_registry"
- "@session.flash_bag"
- "@request_stack"
- "@form.factory"
- "@twig"
tags: ['controller.service_arguments']
Expand Down
37 changes: 6 additions & 31 deletions tests/Application/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Bundle\BundleInterface;
use Symfony\Component\HttpKernel\Kernel as BaseKernel;
use Symfony\Component\Routing\RouteCollectionBuilder;
use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;

final class Kernel extends BaseKernel
{
Expand Down Expand Up @@ -41,24 +41,7 @@ public function registerBundles(): iterable
}
}

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

$container->setParameter('container.dumper.inline_class_loader', true);

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

protected function configureRoutes(RouteCollectionBuilder $routes): void
protected function configureRoutes(RoutingConfigurator $routes): void
{
foreach ($this->getConfigurationDirectories() as $confDir) {
$this->loadRoutesConfiguration($routes, $confDir);
Expand All @@ -79,19 +62,11 @@ 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
private function loadRoutesConfiguration(RoutingConfigurator $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');
$routes->import($confDir . '/{routes}/*' . self::CONFIG_EXTS);
$routes->import($confDir . '/{routes}/' . $this->environment . '/**/*' . self::CONFIG_EXTS);
$routes->import($confDir . '/{routes}' . self::CONFIG_EXTS);
}

/**
Expand Down
4 changes: 4 additions & 0 deletions tests/Application/config/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
$_ENV += $env;
} elseif (!class_exists(Dotenv::class)) {
throw new RuntimeException('Please run "composer require symfony/dotenv" to load the ".env" files configuring the application.');
} elseif (method_exists(Dotenv::class, 'bootEnv')) {
(new Dotenv())->bootEnv(dirname(__DIR__) . '/.env');

return;
} else {
// load all the .env files
(new Dotenv(true))->loadEnv(dirname(__DIR__) . '/.env');
Expand Down
2 changes: 0 additions & 2 deletions tests/Application/config/bundles.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@
Sylius\Bundle\ThemeBundle\SyliusThemeBundle::class => ['all' => true],
Sylius\Bundle\AdminBundle\SyliusAdminBundle::class => ['all' => true],
Sylius\Bundle\ShopBundle\SyliusShopBundle::class => ['all' => true],
FOS\OAuthServerBundle\FOSOAuthServerBundle::class => ['all' => true],
Sylius\Bundle\AdminApiBundle\SyliusAdminApiBundle::class => ['all' => true],
FriendsOfSylius\SyliusImportExportPlugin\FOSSyliusImportExportPlugin::class => ['all' => true],
Symfony\Bundle\DebugBundle\DebugBundle::class => ['dev' => true, 'test' => true, 'test_cached' => true],
Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true, 'test' => true, 'test_cached' => true],
Expand Down
1 change: 0 additions & 1 deletion tests/Application/config/packages/_sylius.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ imports:
- { resource: "@SyliusCoreBundle/Resources/config/app/config.yml" }

- { resource: "@SyliusAdminBundle/Resources/config/app/config.yml" }
- { resource: "@SyliusAdminApiBundle/Resources/config/app/config.yml" }

- { resource: "@SyliusShopBundle/Resources/config/app/config.yml" }

Expand Down
Loading

0 comments on commit 5aed2ec

Please sign in to comment.