Skip to content

Commit ed3be6f

Browse files
authored
Merge pull request #4 from kuba-end/feature/add_sylius_1_11_support
Feature/add sylius 1 11 support
2 parents f2f987d + 4635efd commit ed3be6f

16 files changed

+315
-23
lines changed

.github/workflows/build.yml

+7-5
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,18 @@ jobs:
1818
strategy:
1919
fail-fast: false
2020
matrix:
21-
php: ["7.4"]
21+
php: ["8.0", "7.4"]
2222
symfony: ["^4.4", "^5.2"]
23-
sylius: ["~1.9.0", "~1.10.0@alpha"]
23+
sylius: ["~1.9.0", "~1.10.0", "~1.11.0"]
2424
node: ["10.x"]
2525
mysql: ["8.0"]
2626

2727
exclude:
28-
-
29-
php: "8.0"
30-
sylius: "~1.9.0"
28+
- sylius: ~1.9.0
29+
php: 8.0
30+
31+
- sylius: ~1.11.0
32+
php: 7.4
3133

3234

3335
env:

.github/workflows/coding-standard.yml

+92
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
name: Coding standard
2+
3+
on:
4+
push:
5+
branches-ignore:
6+
- 'dependabot/**'
7+
pull_request: ~
8+
release:
9+
types: [created]
10+
schedule:
11+
-
12+
cron: "0 1 * * 6" #Run at 1am every Saturday
13+
workflow_dispatch: ~
14+
15+
jobs:
16+
tests:
17+
runs-on: ubuntu-18.04
18+
19+
name: "Sylius ${{ matrix.sylius }}, PHP ${{ matrix.php }}, Symfony ${{ matrix.symfony }}, MySQL ${{ matrix.mysql }}"
20+
21+
strategy:
22+
fail-fast: false
23+
matrix:
24+
php: ["8.0", "7.4"]
25+
symfony: ["^4.4", "^5.2"]
26+
sylius: ["~1.9.6", "~1.10.0", "~1.11.0"]
27+
node: ["14.x"]
28+
mysql: ["8.0"]
29+
30+
exclude:
31+
- sylius: ~1.9.6
32+
php: 8.0
33+
34+
- sylius: ~1.10.0
35+
symfony: 4.4
36+
37+
- sylius: ~1.11.0
38+
php: 7.4
39+
40+
env:
41+
APP_ENV: test
42+
DATABASE_URL: "mysql://root:root@127.0.0.1/sylius?serverVersion=${{ matrix.mysql }}"
43+
44+
steps:
45+
-
46+
uses: actions/checkout@v2
47+
-
48+
name: Setup PHP
49+
uses: shivammathur/setup-php@v2
50+
with:
51+
php-version: "${{ matrix.php }}"
52+
extensions: intl
53+
tools: symfony
54+
coverage: none
55+
-
56+
name: Get Composer cache directory
57+
id: composer-cache
58+
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
59+
60+
-
61+
name: Cache Composer
62+
uses: actions/cache@v2
63+
with:
64+
path: ${{ steps.composer-cache.outputs.dir }}
65+
key: ${{ runner.os }}-php-${{ matrix.php }}-composer-${{ hashFiles('**/composer.json **/composer.lock') }}
66+
restore-keys: |
67+
${{ runner.os }}-php-${{ matrix.php }}-composer-
68+
-
69+
name: Restrict Symfony version
70+
if: matrix.symfony != ''
71+
run: |
72+
composer global require --no-progress --no-scripts --no-plugins "symfony/flex:^1.10"
73+
composer config extra.symfony.require "${{ matrix.symfony }}"
74+
-
75+
name: Restrict Sylius version
76+
if: matrix.sylius != ''
77+
run: composer require "sylius/sylius:${{ matrix.sylius }}" --no-update --no-scripts --no-interaction
78+
79+
-
80+
name: Install PHP dependencies
81+
run: composer install --no-interaction
82+
83+
- name: Run ECS
84+
run: vendor/bin/ecs
85+
86+
-
87+
name: Run PHPStan in /src directory
88+
run: ./vendor/bin/phpstan analyze --configuration=./phpstan.neon src --level=8
89+
90+
-
91+
name: Run PHPStan in /test directory
92+
run: ./vendor/bin/phpstan analyze --configuration=./phpstan.neon tests --level=5

composer.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,12 @@
1313
"php": "^7.4 || ^8.0",
1414
"bitbag/shipping-export-plugin": "^1.5",
1515
"msztorc/php-dpd-api": "^2.1",
16-
"sylius/sylius": "~1.9.0 || ~1.10.0"
16+
"sylius/sylius": "~1.9.0 || ~1.10.0 || ~1.11.0"
1717
},
1818
"require-dev": {
1919
"behat/behat": "^3.6.1",
2020
"behat/mink-selenium2-driver": "^1.4",
21+
"bitbag/coding-standard": "^1.0",
2122
"dmore/behat-chrome-extension": "^1.3",
2223
"dmore/chrome-mink-driver": "^2.7",
2324
"friends-of-behat/mink": "^1.8",
@@ -36,6 +37,7 @@
3637
"phpstan/phpstan-strict-rules": "^0.12.0",
3738
"phpstan/phpstan-webmozart-assert": "0.12.12",
3839
"phpunit/phpunit": "^9.5",
40+
"polishsymfonycommunity/symfony-mocker-container": "^1.0",
3941
"sensiolabs/security-checker": "^6.0",
4042
"sylius-labs/coding-standard": "^4.0",
4143
"symfony/browser-kit": "^4.4 || ^5.2",

ecs.php

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

88
return static function (ContainerConfigurator $containerConfigurator): void {
99
$containerConfigurator->import('vendor/sylius-labs/coding-standard/ecs.php');
10+
$containerConfigurator->import('vendor/bitbag/coding-standard/ecs.php');
1011

1112
$containerConfigurator->parameters()->set(Option::SKIP, [
1213
VisibilityRequiredFixer::class => ['*Spec.php'],

phpstan.neon

+7-5
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@ parameters:
33
checkMissingIterableValueType: false
44

55
excludes_analyse:
6-
# Makes PHPStan crash
7-
- 'src/DependencyInjection/Configuration.php'
6+
# Makes PHPStan crash
7+
- 'src/DependencyInjection/Configuration.php'
88

9-
# Test dependencies
10-
- 'tests/Application/app/**.php'
11-
- 'tests/Application/src/**.php'
9+
# Test dependencies
10+
- 'tests/Application/*'
11+
12+
# ECS Fixer dependency
13+
- 'src/Fixer'
1214

1315
ignoreErrors:
1416
- '/Parameter #1 \$configuration of method Symfony\\Component\\DependencyInjection\\Extension\\Extension::processConfiguration\(\) expects Symfony\\Component\\Config\\Definition\\ConfigurationInterface, Symfony\\Component\\Config\\Definition\\ConfigurationInterface\|null given\./'

tests/Application/.env

+8
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,11 @@ JWT_PASSPHRASE=YOUR_SECRET_PASSPHRASE
2727
# Delivery is disabled by default via "null://localhost"
2828
MAILER_URL=smtp://localhost
2929
###< symfony/swiftmailer-bundle ###
30+
31+
###> symfony/messenger ###
32+
# Choose one of the transports below
33+
# MESSENGER_TRANSPORT_DSN=amqp://guest:guest@localhost:5672/%2f/messages
34+
# MESSENGER_TRANSPORT_DSN=doctrine://default
35+
# MESSENGER_TRANSPORT_DSN=redis://localhost:6379/messages
36+
MESSENGER_TRANSPORT_DSN=sync://
37+
###< symfony/messenger ###

tests/Application/Kernel.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ protected function configureRoutes(RouteCollectionBuilder $routes): void
6767

6868
protected function getContainerBaseClass(): string
6969
{
70-
if ($this->isTestEnvironment()) {
70+
if ($this->isTestEnvironment() && class_exists(MockerContainer::class)) {
7171
return MockerContainer::class;
7272
}
7373

tests/Application/config/api_platform/.gitkeep

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
3+
return [
4+
BabDev\PagerfantaBundle\BabDevPagerfantaBundle::class => ['all' => true],
5+
SyliusLabs\Polyfill\Symfony\Security\Bundle\SyliusLabsPolyfillSymfonySecurityBundle::class => ['all' => true],
6+
Sylius\Calendar\SyliusCalendarBundle::class => ['all' => true]
7+
];
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
jms_serializer:
2+
visitors:
3+
json_serialization:
4+
options:
5+
- JSON_PRETTY_PRINT
6+
- JSON_UNESCAPED_SLASHES
7+
- JSON_PRESERVE_ZERO_FRACTION
8+
json_deserialization:
9+
options:
10+
- JSON_PRETTY_PRINT
11+
- JSON_UNESCAPED_SLASHES
12+
- JSON_PRESERVE_ZERO_FRACTION
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
jms_serializer:
2+
visitors:
3+
xml_serialization:
4+
format_output: '%kernel.debug%'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
jms_serializer:
2+
visitors:
3+
json_serialization:
4+
options:
5+
- JSON_UNESCAPED_SLASHES
6+
- JSON_PRESERVE_ZERO_FRACTION
7+
json_deserialization:
8+
options:
9+
- JSON_UNESCAPED_SLASHES
10+
- JSON_PRESERVE_ZERO_FRACTION
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
parameters:
2+
sylius.security.admin_regex: "^/%sylius_admin.path_name%"
3+
sylius.security.api_regex: "^/api"
4+
sylius.security.shop_regex: "^/(?!%sylius_admin.path_name%|new-api|api/.*|api$|media/.*)[^/]++"
5+
sylius.security.new_api_route: "/new-api"
6+
sylius.security.new_api_regex: "^%sylius.security.new_api_route%"
7+
sylius.security.new_api_admin_route: "%sylius.security.new_api_route%/admin"
8+
sylius.security.new_api_admin_regex: "^%sylius.security.new_api_admin_route%"
9+
sylius.security.new_api_shop_route: "%sylius.security.new_api_route%/shop"
10+
sylius.security.new_api_shop_regex: "^%sylius.security.new_api_shop_route%"
11+
12+
security:
13+
always_authenticate_before_granting: true
14+
providers:
15+
sylius_admin_user_provider:
16+
id: sylius.admin_user_provider.email_or_name_based
17+
sylius_api_admin_user_provider:
18+
id: sylius.admin_user_provider.email_or_name_based
19+
sylius_shop_user_provider:
20+
id: sylius.shop_user_provider.email_or_name_based
21+
sylius_api_shop_user_provider:
22+
id: sylius.shop_user_provider.email_or_name_based
23+
sylius_api_chain_provider:
24+
chain:
25+
providers: [sylius_api_shop_user_provider, sylius_api_admin_user_provider]
26+
27+
encoders:
28+
Sylius\Component\User\Model\UserInterface: argon2i
29+
firewalls:
30+
admin:
31+
switch_user: true
32+
context: admin
33+
pattern: "%sylius.security.admin_regex%"
34+
provider: sylius_admin_user_provider
35+
form_login:
36+
provider: sylius_admin_user_provider
37+
login_path: sylius_admin_login
38+
check_path: sylius_admin_login_check
39+
failure_path: sylius_admin_login
40+
default_target_path: sylius_admin_dashboard
41+
use_forward: false
42+
use_referer: true
43+
csrf_token_generator: security.csrf.token_manager
44+
csrf_parameter: _csrf_admin_security_token
45+
csrf_token_id: admin_authenticate
46+
remember_me:
47+
secret: "%env(APP_SECRET)%"
48+
path: "/%sylius_admin.path_name%"
49+
name: APP_ADMIN_REMEMBER_ME
50+
lifetime: 31536000
51+
remember_me_parameter: _remember_me
52+
logout:
53+
path: sylius_admin_logout
54+
target: sylius_admin_login
55+
anonymous: true
56+
57+
new_api_admin_user:
58+
pattern: "%sylius.security.new_api_route%/admin-user-authentication-token"
59+
provider: sylius_admin_user_provider
60+
stateless: true
61+
anonymous: true
62+
json_login:
63+
check_path: "%sylius.security.new_api_route%/admin-user-authentication-token"
64+
username_path: email
65+
password_path: password
66+
success_handler: lexik_jwt_authentication.handler.authentication_success
67+
failure_handler: lexik_jwt_authentication.handler.authentication_failure
68+
guard:
69+
authenticators:
70+
- lexik_jwt_authentication.jwt_token_authenticator
71+
72+
new_api_shop_user:
73+
pattern: "%sylius.security.new_api_route%/shop-user-authentication-token"
74+
provider: sylius_shop_user_provider
75+
stateless: true
76+
anonymous: true
77+
json_login:
78+
check_path: "%sylius.security.new_api_route%/shop-user-authentication-token"
79+
username_path: email
80+
password_path: password
81+
success_handler: lexik_jwt_authentication.handler.authentication_success
82+
failure_handler: lexik_jwt_authentication.handler.authentication_failure
83+
guard:
84+
authenticators:
85+
- lexik_jwt_authentication.jwt_token_authenticator
86+
87+
new_api:
88+
pattern: "%sylius.security.new_api_regex%/*"
89+
provider: sylius_api_chain_provider
90+
stateless: true
91+
anonymous: lazy
92+
guard:
93+
authenticators:
94+
- lexik_jwt_authentication.jwt_token_authenticator
95+
96+
shop:
97+
switch_user: { role: ROLE_ALLOWED_TO_SWITCH }
98+
context: shop
99+
pattern: "%sylius.security.shop_regex%"
100+
provider: sylius_shop_user_provider
101+
form_login:
102+
success_handler: sylius.authentication.success_handler
103+
failure_handler: sylius.authentication.failure_handler
104+
provider: sylius_shop_user_provider
105+
login_path: sylius_shop_login
106+
check_path: sylius_shop_login_check
107+
failure_path: sylius_shop_login
108+
default_target_path: sylius_shop_homepage
109+
use_forward: false
110+
use_referer: true
111+
csrf_token_generator: security.csrf.token_manager
112+
csrf_parameter: _csrf_shop_security_token
113+
csrf_token_id: shop_authenticate
114+
remember_me:
115+
secret: "%env(APP_SECRET)%"
116+
name: APP_SHOP_REMEMBER_ME
117+
lifetime: 31536000
118+
remember_me_parameter: _remember_me
119+
logout:
120+
path: sylius_shop_logout
121+
target: sylius_shop_login
122+
invalidate_session: false
123+
success_handler: sylius.handler.shop_user_logout
124+
anonymous: true
125+
126+
dev:
127+
pattern: ^/(_(profiler|wdt)|css|images|js)/
128+
security: false
129+
130+
access_control:
131+
- { path: "%sylius.security.admin_regex%/_partial", role: IS_AUTHENTICATED_ANONYMOUSLY, ips: [127.0.0.1, ::1] }
132+
- { path: "%sylius.security.admin_regex%/_partial", role: ROLE_NO_ACCESS }
133+
- { path: "%sylius.security.shop_regex%/_partial", role: IS_AUTHENTICATED_ANONYMOUSLY, ips: [127.0.0.1, ::1] }
134+
- { path: "%sylius.security.shop_regex%/_partial", role: ROLE_NO_ACCESS }
135+
136+
- { path: "%sylius.security.admin_regex%/login", role: IS_AUTHENTICATED_ANONYMOUSLY }
137+
- { path: "%sylius.security.api_regex%/login", role: IS_AUTHENTICATED_ANONYMOUSLY }
138+
- { path: "%sylius.security.shop_regex%/login", role: IS_AUTHENTICATED_ANONYMOUSLY }
139+
140+
- { path: "%sylius.security.shop_regex%/register", role: IS_AUTHENTICATED_ANONYMOUSLY }
141+
- { path: "%sylius.security.shop_regex%/verify", role: IS_AUTHENTICATED_ANONYMOUSLY }
142+
143+
- { path: "%sylius.security.admin_regex%", role: ROLE_ADMINISTRATION_ACCESS }
144+
- { path: "%sylius.security.api_regex%/.*", role: ROLE_API_ACCESS }
145+
- { path: "%sylius.security.shop_regex%/account", role: ROLE_USER }
146+
147+
- { path: "%sylius.security.new_api_admin_regex%/.*", role: ROLE_API_ACCESS }
148+
- { path: "%sylius.security.new_api_shop_regex%/.*", role: IS_AUTHENTICATED_ANONYMOUSLY }

tests/Behat/Context/Setup/ShippingGatewayContext.php

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use Sylius\Component\Core\Model\ShipmentInterface;
1414
use Sylius\Component\Product\Resolver\ProductVariantResolverInterface;
1515
use Sylius\Component\Resource\Repository\RepositoryInterface;
16+
use Sylius\Component\Shipping\Model\ShipmentUnitInterface;
1617

1718
final class ShippingGatewayContext implements Context
1819
{
@@ -107,6 +108,7 @@ public function setUnitsToTheShipment()
107108

108109
/** @var OrderItemInterface $orderItem */
109110
foreach ($shipment->getOrder()->getItems() as $orderItem) {
111+
/** @var ShipmentUnitInterface $itemUnit */
110112
foreach ($orderItem->getUnits() as $itemUnit) {
111113
$shipment->addUnit($itemUnit);
112114
}

0 commit comments

Comments
 (0)