Skip to content

Commit b079bb3

Browse files
committed
Update to Sylius 1.9
1 parent b3737be commit b079bb3

29 files changed

+169
-113
lines changed

.github/workflows/build.yml

+19-5
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,21 @@ jobs:
1616
tests:
1717
runs-on: ubuntu-18.04
1818

19-
name: "PHP ${{ matrix.php }}, MySQL ${{ matrix.mysql }}"
19+
name: "Sylius ${{ matrix.sylius }}, PHP ${{ matrix.php }}, Symfony ${{ matrix.symfony }}, MySQL ${{ matrix.mysql }}"
2020

2121
strategy:
2222
fail-fast: false
2323
matrix:
2424
php: [7.4, 7.3]
25+
symfony: [^4.4, ^5.2]
26+
sylius: [~1.8.0, ~1.9.0]
2527
node: [10.x]
26-
mysql: [5.7, 8.0]
28+
mysql: [5.7]
2729

2830
exclude:
29-
- # PHP 7.3 does not support "caching_sha2_password" authentication plugin which is a default one in MySQL 8.0
30-
php: 7.3
31-
mysql: 8.0
31+
-
32+
sylius: ~1.8.0
33+
symfony: ^5.2
3234

3335
env:
3436
APP_ENV: test
@@ -94,6 +96,18 @@ jobs:
9496
restore-keys: |
9597
${{ runner.os }}-php-${{ matrix.php }}-composer-
9698
99+
-
100+
name: Restrict Symfony version
101+
if: matrix.symfony != ''
102+
run: |
103+
composer global require --no-progress --no-scripts --no-plugins "symfony/flex:^1.10"
104+
composer config extra.symfony.require "${{ matrix.symfony }}"
105+
106+
-
107+
name: Restrict Sylius version
108+
if: matrix.sylius != ''
109+
run: composer require "sylius/sylius:${{ matrix.sylius }}" --no-update --no-scripts --no-interaction
110+
97111
-
98112
name: Install PHP dependencies
99113
run: composer install --no-interaction

behat.yml.dist

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ default:
4646
FriendsOfBehat\SymfonyExtension:
4747
bootstrap: tests/Application/config/bootstrap.php
4848
kernel:
49-
class: Tests\Acme\SyliusExamplePlugin\Application\Kernel
49+
class: Acme\Tests\SyliusExamplePlugin\Application\Kernel
5050

5151
FriendsOfBehat\VariadicExtension: ~
5252

composer.json

+15-13
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@
66
"license": "MIT",
77
"require": {
88
"php": "^7.3",
9-
10-
"sylius/sylius": "^1.8"
9+
"sylius/sylius": "~1.8.0 || ~1.9.0"
10+
},
11+
"conflict": {
12+
"api-platform/core": "^2.6"
1113
},
1214
"require-dev": {
1315
"behat/behat": "^3.6.1",
@@ -21,22 +23,22 @@
2123
"friends-of-behat/suite-settings-extension": "^1.0",
2224
"friends-of-behat/symfony-extension": "^2.1",
2325
"friends-of-behat/variadic-extension": "^1.3",
26+
"friendsofsymfony/oauth-server-bundle": "^1.6 || >2.0.0-alpha.0 ^2.0@dev",
2427
"lakion/mink-debug-extension": "^2.0.0",
2528
"phpspec/phpspec": "^7.0",
2629
"phpstan/extension-installer": "^1.0",
27-
"phpstan/phpstan": "0.12.67",
28-
"phpstan/phpstan-doctrine": "0.12.28",
30+
"phpstan/phpstan": "0.12.74",
31+
"phpstan/phpstan-doctrine": "0.12.31",
2932
"phpstan/phpstan-strict-rules": "^0.12.0",
30-
"phpstan/phpstan-webmozart-assert": "0.12.8",
33+
"phpstan/phpstan-webmozart-assert": "0.12.12",
3134
"phpunit/phpunit": "^9.5",
3235
"sensiolabs/security-checker": "^6.0",
3336
"sylius-labs/coding-standard": "^3.1",
34-
"symfony/browser-kit": "^4.4",
35-
"symfony/debug-bundle": "^4.4|^5.0",
36-
"symfony/dotenv": "^4.4|^5.0",
37-
"symfony/intl": "^4.4|^5.0",
38-
"symfony/web-profiler-bundle": "^4.4|^5.0",
39-
"symfony/web-server-bundle": "^4.4|^5.0",
37+
"symfony/browser-kit": "^4.4 || ^5.2",
38+
"symfony/debug-bundle": "^4.4 || ^5.2",
39+
"symfony/dotenv": "^4.4 || ^5.2",
40+
"symfony/intl": "^4.4 || ^5.2",
41+
"symfony/web-profiler-bundle": "^4.4 || ^5.2",
4042
"vimeo/psalm": "4.4.1"
4143
},
4244
"autoload": {
@@ -47,12 +49,12 @@
4749
"autoload-dev": {
4850
"classmap": ["tests/Application/Kernel.php"],
4951
"psr-4": {
50-
"Acme\\SyliusExamplePlugin\\Tests\\": "tests/"
52+
"Acme\\Tests\\SyliusExamplePlugin\\": "tests/"
5153
}
5254
},
5355
"extra": {
5456
"branch-alias": {
55-
"dev-master": "1.8-dev"
57+
"dev-master": "1.9-dev"
5658
}
5759
},
5860
"config": {

config/routes/shop_routing.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
acme_sylius_example_static_welcome:
44
path: /static-welcome/{name}
55
defaults:
6-
_controller: AcmeSyliusExamplePlugin:Greeting:staticallyGreet
6+
_controller: Acme\SyliusExamplePlugin\Controller\GreetingController::staticallyGreetAction
77
name: ~
88

99
acme_sylius_example_dynamic_welcome:
1010
path: /dynamic-welcome/{name}
1111
defaults:
12-
_controller: AcmeSyliusExamplePlugin:Greeting:dynamicallyGreet
12+
_controller: Acme\SyliusExamplePlugin\Controller\GreetingController::dynamicallyGreetAction
1313
name: ~

config/services.xml

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
<container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
44
<services>
5+
<service id="Acme\SyliusExamplePlugin\Controller\GreetingController" autowire="true" autoconfigure="true" public="true" />
56
<!-- Put your services here -->
67
</services>
78
</container>
+26-39
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,41 @@
1-
# Sylius/Sylius:features/product/managing_products/adding_products_with_text_attribute.feature
1+
# Sylius/Sylius:features/product/managing_products/adding_product_with_associations.feature
22

33
@managing_products
4-
Feature: Adding a new product with text attribute
5-
In order to extend my merchandise with more complex products
4+
Feature: Adding a new product with associations
5+
In order to associate my product with others
66
As an Administrator
7-
I want to add a new product with text attribute to the shop
7+
I want to add a new product with associated products
88

99
Background:
1010
Given the store operates on a single channel in "United States"
11-
And the store has a text product attribute "Gun caliber"
12-
And the store has a text product attribute "Overall length"
11+
And the store has "Accessories" and "Alternatives" product association types
12+
And the store has "LG headphones", "LG earphones", "LG G4" and "LG G5" products
1313
And I am logged in as an administrator
1414

1515
@ui @javascript
16-
Scenario: Adding a text attribute to product
17-
Given I want to create a new simple product
18-
When I specify its code as "44_MAGNUM"
19-
And I name it "44 Magnum" in "English (United States)"
20-
And I set its price to "$100.00" for "United States" channel
21-
And I set its "Gun caliber" attribute to "11 mm" in "English (United States)"
16+
Scenario: Adding a new product with associations
17+
When I want to create a new simple product
18+
And I specify its code as "lg_g3"
19+
And I name it "LG G3" in "English (United States)"
20+
And I set its price to "$400.00" for "United States" channel
21+
And I associate as "Accessories" the "LG headphones" and "LG earphones" products
22+
And I associate as "Alternatives" the "LG G4" and "LG G5" products
2223
And I add it
2324
Then I should be notified that it has been successfully created
24-
And the product "44 Magnum" should appear in the store
25-
And attribute "Gun caliber" of product "44 Magnum" should be "11 mm"
25+
And this product should have an association "Accessories" with products "LG headphones" and "LG earphones"
26+
And this product should also have an association "Alternatives" with products "LG G4" and "LG G5"
27+
And the product "LG G3" should appear in the store
2628

2729
@ui @javascript
28-
Scenario: Adding multiple text attributes to product
29-
Given I want to create a new simple product
30-
When I specify its code as "44_MAGNUM"
31-
And I name it "44 Magnum" in "English (United States)"
32-
And I set its price to "$100.00" for "United States" channel
33-
And I set its "Gun caliber" attribute to "11 mm" in "English (United States)"
34-
And I set its "Overall length" attribute to "30.5 cm" in "English (United States)"
30+
Scenario: Adding a new product with associations after changing associated items
31+
When I want to create a new simple product
32+
And I specify its code as "lg_g3"
33+
And I name it "LG G3" in "English (United States)"
34+
And I set its price to "$400.00" for "United States" channel
35+
And I associate as "Accessories" the "LG headphones" and "LG earphones" products
36+
And I remove an associated product "LG earphones" from "Accessories"
3537
And I add it
3638
Then I should be notified that it has been successfully created
37-
And the product "44 Magnum" should appear in the store
38-
And attribute "Gun caliber" of product "44 Magnum" should be "11 mm"
39-
And attribute "Overall length" of product "44 Magnum" should be "30.5 cm"
40-
41-
@ui @javascript
42-
Scenario: Adding and removing text attributes on product create page
43-
Given I want to create a new simple product
44-
When I specify its code as "44_MAGNUM"
45-
And I name it "44 Magnum" in "English (United States)"
46-
And I set its price to "$100.00" for "United States" channel
47-
And I set its "Gun caliber" attribute to "11 mm" in "English (United States)"
48-
And I set its "Overall length" attribute to "30.5 cm" in "English (United States)"
49-
And I remove its "Gun caliber" attribute
50-
And I add it
51-
Then I should be notified that it has been successfully created
52-
And the product "44 Magnum" should appear in the store
53-
And attribute "Overall length" of product "44 Magnum" should be "30.5 cm"
54-
And product "44 Magnum" should not have a "Gun caliber" attribute
39+
And this product should have an association "Accessories" with product "LG headphones"
40+
And this product should not have an association "Accessories" with product "LG earphones"
41+
And the product "LG G3" should appear in the store

tests/Application/.env

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ APP_SECRET=EDITME
1212
# Format described at http://docs.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url
1313
# For a sqlite database, use: "sqlite:///%kernel.project_dir%/var/data.db"
1414
# Set "serverVersion" to your server version to avoid edge-case exceptions and extra database calls
15-
DATABASE_URL=mysql://[email protected]/acme_sylius_example_plugin_%kernel.environment%?serverVersion=5.5
15+
DATABASE_URL=mysql://[email protected]/acme_sylius_example_plugin_%kernel.environment%?serverVersion=5.7
1616
###< doctrine/doctrine-bundle ###
1717

1818
###> lexik/jwt-authentication-bundle ###

tests/Application/.env.test

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
APP_SECRET='ch4mb3r0f5ecr3ts'
22

3-
KERNEL_CLASS='Acme\SyliusExamplePlugin\Tests\Application\Kernel'
3+
KERNEL_CLASS='Acme\Tests\SyliusExamplePlugin\Application\Kernel'

tests/Application/Kernel.php

+51-35
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22

33
declare(strict_types=1);
44

5-
namespace Acme\SyliusExamplePlugin\Tests\Application;
5+
namespace Acme\Tests\SyliusExamplePlugin\Application;
66

77
use PSS\SymfonyMockerContainer\DependencyInjection\MockerContainer;
8+
use Sylius\Bundle\CoreBundle\Application\Kernel as SyliusKernel;
89
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
910
use Symfony\Component\Config\Loader\DelegatingLoader;
1011
use Symfony\Component\Config\Loader\LoaderInterface;
@@ -19,6 +20,7 @@
1920
use Symfony\Component\DependencyInjection\Loader\PhpFileLoader;
2021
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
2122
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
23+
use Symfony\Component\HttpKernel\Bundle\BundleInterface;
2224
use Symfony\Component\HttpKernel\Config\FileLocator;
2325
use Symfony\Component\HttpKernel\Kernel as BaseKernel;
2426
use Symfony\Component\Routing\RouteCollectionBuilder;
@@ -42,33 +44,29 @@ public function getLogDir(): string
4244

4345
public function registerBundles(): iterable
4446
{
45-
$contents = require $this->getProjectDir() . '/config/bundles.php';
46-
foreach ($contents as $class => $envs) {
47-
if (isset($envs['all']) || isset($envs[$this->environment])) {
48-
yield new $class();
49-
}
47+
foreach ($this->getConfigurationDirectories() as $confDir) {
48+
yield from $this->registerBundlesFromFile($confDir . '/bundles.php');
5049
}
5150
}
5251

5352
protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader): void
5453
{
55-
$container->addResource(new FileResource($this->getProjectDir() . '/config/bundles.php'));
54+
foreach ($this->getConfigurationDirectories() as $confDir) {
55+
$container->addResource(new FileResource($confDir . '/bundles.php'));
56+
}
57+
5658
$container->setParameter('container.dumper.inline_class_loader', true);
57-
$confDir = $this->getProjectDir() . '/config';
5859

59-
$loader->load($confDir . '/{packages}/*' . self::CONFIG_EXTS, 'glob');
60-
$loader->load($confDir . '/{packages}/' . $this->environment . '/**/*' . self::CONFIG_EXTS, 'glob');
61-
$loader->load($confDir . '/{services}' . self::CONFIG_EXTS, 'glob');
62-
$loader->load($confDir . '/{services}_' . $this->environment . self::CONFIG_EXTS, 'glob');
60+
foreach ($this->getConfigurationDirectories() as $confDir) {
61+
$this->loadContainerConfiguration($loader, $confDir);
62+
}
6363
}
6464

6565
protected function configureRoutes(RouteCollectionBuilder $routes): void
6666
{
67-
$confDir = $this->getProjectDir() . '/config';
68-
69-
$routes->import($confDir . '/{routes}/*' . self::CONFIG_EXTS, '/', 'glob');
70-
$routes->import($confDir . '/{routes}/' . $this->environment . '/**/*' . self::CONFIG_EXTS, '/', 'glob');
71-
$routes->import($confDir . '/{routes}' . self::CONFIG_EXTS, '/', 'glob');
67+
foreach ($this->getConfigurationDirectories() as $confDir) {
68+
$this->loadRoutesConfiguration($routes, $confDir);
69+
}
7270
}
7371

7472
protected function getContainerBaseClass(): string
@@ -80,27 +78,45 @@ protected function getContainerBaseClass(): string
8078
return parent::getContainerBaseClass();
8179
}
8280

83-
protected function getContainerLoader(ContainerInterface $container): LoaderInterface
81+
private function isTestEnvironment(): bool
8482
{
85-
/** @var ContainerBuilder $container */
86-
Assert::isInstanceOf($container, ContainerBuilder::class);
87-
88-
$locator = new FileLocator($this, $this->getRootDir() . '/Resources');
89-
$resolver = new LoaderResolver(array(
90-
new XmlFileLoader($container, $locator),
91-
new YamlFileLoader($container, $locator),
92-
new IniFileLoader($container, $locator),
93-
new PhpFileLoader($container, $locator),
94-
new GlobFileLoader($container, $locator),
95-
new DirectoryLoader($container, $locator),
96-
new ClosureLoader($container),
97-
));
98-
99-
return new DelegatingLoader($resolver);
83+
return 0 === strpos($this->getEnvironment(), 'test');
10084
}
10185

102-
private function isTestEnvironment(): bool
86+
private function loadContainerConfiguration(LoaderInterface $loader, string $confDir): void
10387
{
104-
return 0 === strpos($this->getEnvironment(), 'test');
88+
$loader->load($confDir . '/{packages}/*' . self::CONFIG_EXTS, 'glob');
89+
$loader->load($confDir . '/{packages}/' . $this->environment . '/**/*' . self::CONFIG_EXTS, 'glob');
90+
$loader->load($confDir . '/{services}' . self::CONFIG_EXTS, 'glob');
91+
$loader->load($confDir . '/{services}_' . $this->environment . self::CONFIG_EXTS, 'glob');
92+
}
93+
94+
private function loadRoutesConfiguration(RouteCollectionBuilder $routes, string $confDir): void
95+
{
96+
$routes->import($confDir . '/{routes}/*' . self::CONFIG_EXTS, '/', 'glob');
97+
$routes->import($confDir . '/{routes}/' . $this->environment . '/**/*' . self::CONFIG_EXTS, '/', 'glob');
98+
$routes->import($confDir . '/{routes}' . self::CONFIG_EXTS, '/', 'glob');
99+
}
100+
101+
/**
102+
* @return BundleInterface[]
103+
*/
104+
private function registerBundlesFromFile(string $bundlesFile): iterable
105+
{
106+
$contents = require $bundlesFile;
107+
foreach ($contents as $class => $envs) {
108+
if (isset($envs['all']) || isset($envs[$this->environment])) {
109+
yield new $class();
110+
}
111+
}
112+
}
113+
114+
/**
115+
* @return string[]
116+
*/
117+
private function getConfigurationDirectories(): iterable
118+
{
119+
yield $this->getProjectDir() . '/config';
120+
yield $this->getProjectDir() . '/config/sylius/' . SyliusKernel::MAJOR_VERSION . '.' . SyliusKernel::MINOR_VERSION;
105121
}
106122
}

tests/Application/bin/console

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env php
22
<?php
33

4-
use Acme\SyliusExamplePlugin\Tests\Application\Kernel;
4+
use Acme\Tests\SyliusExamplePlugin\Application\Kernel;
55
use Symfony\Bundle\FrameworkBundle\Console\Application;
66
use Symfony\Component\Console\Input\ArgvInput;
77
use Symfony\Component\Debug\Debug;

tests/Application/config/bundles.php

-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle::class => ['all' => true],
88
Symfony\Bundle\TwigBundle\TwigBundle::class => ['all' => true],
99
Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class => ['all' => true],
10-
Doctrine\Bundle\DoctrineCacheBundle\DoctrineCacheBundle::class => ['all' => true],
1110
Sylius\Bundle\OrderBundle\SyliusOrderBundle::class => ['all' => true],
1211
Sylius\Bundle\MoneyBundle\SyliusMoneyBundle::class => ['all' => true],
1312
Sylius\Bundle\CurrencyBundle\SyliusCurrencyBundle::class => ['all' => true],
@@ -40,12 +39,10 @@
4039
Liip\ImagineBundle\LiipImagineBundle::class => ['all' => true],
4140
Payum\Bundle\PayumBundle\PayumBundle::class => ['all' => true],
4241
Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle::class => ['all' => true],
43-
WhiteOctober\PagerfantaBundle\WhiteOctoberPagerfantaBundle::class => ['all' => true],
4442
Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle::class => ['all' => true],
4543
Sylius\Bundle\FixturesBundle\SyliusFixturesBundle::class => ['all' => true],
4644
Sylius\Bundle\PayumBundle\SyliusPayumBundle::class => ['all' => true],
4745
Sylius\Bundle\ThemeBundle\SyliusThemeBundle::class => ['all' => true],
48-
Symfony\Bundle\WebServerBundle\WebServerBundle::class => ['all' => true],
4946
Sylius\Bundle\AdminBundle\SyliusAdminBundle::class => ['all' => true],
5047
Sylius\Bundle\ShopBundle\SyliusShopBundle::class => ['all' => true],
5148
FOS\OAuthServerBundle\FOSOAuthServerBundle::class => ['all' => true],

tests/Application/config/packages/framework.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,5 @@ framework:
22
secret: '%env(APP_SECRET)%'
33
form: true
44
csrf_protection: true
5-
templating: { engines: ["twig"] }
65
session:
76
handler_id: ~

0 commit comments

Comments
 (0)