Skip to content

Commit

Permalink
Remove unnecessary requirements and allow more Sylius versions (#117)
Browse files Browse the repository at this point in the history
* Remove unnecessary requirements and allow more Sylius versions

* [Build Sylius 1.12] Update composer.json to execute needed symlink script

* [Build Sylius 1.12] Switch to webpack on test app

* [Build Sylius 1.12] Add Sylius 1.12 dev to the build

* Update webpack config

* Fix Sylius 1.12 error with missing SwiftMailer

* Add require new mailer, security and framework config

* Add missing webpack changes

* Avoid deprecated warning during BeHat tests

* Fix line return

* Fix webpack entry points
  • Loading branch information
Prometee authored Oct 22, 2022
1 parent 72e9b7d commit a5e175b
Show file tree
Hide file tree
Showing 58 changed files with 399 additions and 75 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
matrix:
php: ["7.4", "8.0"]
symfony: ["^4.4", "^5.4"]
sylius: ["~1.9.0", "~1.10.0", "~1.11.0"]
sylius: ["~1.9.0", "~1.10.0", "~1.11.0", "~1.12.x-dev"]
node: ["14.x"]
mysql: ["8.0"]

Expand All @@ -34,6 +34,9 @@ jobs:
-
php: "7.4"
sylius: "~1.11.0"
-
php: "7.4"
sylius: "~1.12.x-dev"

env:
APP_ENV: test
Expand Down
26 changes: 20 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
"description": "Adds product customizing to Sylius",
"license": "MIT",
"require": {
"php": "^7.4 || ^8.0",
"sylius/sylius": "~1.9.0 || ~1.10.0 || ~1.11.0",
"symfony/event-dispatcher": "^4.3 || ^5.0"
"sylius/sylius": "^1.9"
},
"require-dev": {
"behat/behat": "^3.6.1",
Expand Down Expand Up @@ -36,6 +34,7 @@
"symfony/dotenv": "^4.4 || ^5.4",
"symfony/intl": "^4.4 || ^5.4",
"symfony/web-profiler-bundle": "^4.4 || ^5.4",
"symfony/webpack-encore-bundle": "^1.15",
"vimeo/psalm": "4.7.1",
"mamazu/documentation-validator": "dev-master",
"polishsymfonycommunity/symfony-mocker-container": "^1.0"
Expand All @@ -53,16 +52,31 @@
"autoload-dev": {
"classmap": ["tests/Application/Kernel.php"]
},
"config": {
"sort-packages": true,
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": false,
"phpstan/extension-installer": true,
"symfony/flex": true,
"symfony/thanks": true
}
},
"scripts": {
"post-install-cmd": [
"@php bin/create_node_symlink.php"
],
"post-update-cmd": [
"@php bin/create_node_symlink.php"
],
"post-create-project-cmd": [
"@php bin/create_node_symlink.php"
],
"analyse": [
"vendor/bin/ecs check --ansi --no-progress-bar src/ tests/PHPUnit --config etc/coding-standard.php",
"vendor/bin/phpstan analyse -c phpstan.neon --no-progress -l max src/"
],
"fix": [
"vendor/bin/ecs check --ansi --no-progress-bar src/ tests/PHPUnit --config etc/coding-standard.php --fix"
]
},
"config": {
"allow-plugins": false
}
}
2 changes: 1 addition & 1 deletion node_modules
7 changes: 3 additions & 4 deletions tests/Application/.babelrc
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
{
"presets": [
["env", {
["@babel/preset-env", {
"targets": {
"node": "6"
},
"useBuiltIns": true
}
}]
],
"plugins": [
["transform-object-rest-spread", {
["@babel/plugin-proposal-object-rest-spread", {
"useBuiltIns": true
}]
]
Expand Down
1 change: 1 addition & 0 deletions tests/Application/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/public/assets
/public/build
/public/css
/public/js
/public/media/*
Expand Down
1 change: 1 addition & 0 deletions tests/Application/assets/admin/entry.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import 'sylius/bundle/AdminBundle/Resources/private/entry';
1 change: 1 addition & 0 deletions tests/Application/assets/shop/entry.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import 'sylius/bundle/ShopBundle/Resources/private/entry';
2 changes: 1 addition & 1 deletion tests/Application/config/bundles.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true],
Symfony\Bundle\MonologBundle\MonologBundle::class => ['all' => true],
Symfony\Bundle\SecurityBundle\SecurityBundle::class => ['all' => true],
Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle::class => ['all' => true],
Symfony\Bundle\TwigBundle\TwigBundle::class => ['all' => true],
Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class => ['all' => true],
Sylius\Bundle\OrderBundle\SyliusOrderBundle::class => ['all' => true],
Expand Down Expand Up @@ -54,4 +53,5 @@
Lexik\Bundle\JWTAuthenticationBundle\LexikJWTAuthenticationBundle::class => ['all' => true],
Sylius\Bundle\ApiBundle\SyliusApiBundle::class => ['all' => true],
SyliusLabs\DoctrineMigrationsExtraBundle\SyliusLabsDoctrineMigrationsExtraBundle::class => ['all' => true],
Symfony\WebpackEncoreBundle\WebpackEncoreBundle::class => ['all' => true],
];
7 changes: 7 additions & 0 deletions tests/Application/config/packages/assets.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
framework:
assets:
packages:
shop:
json_manifest_path: '%kernel.project_dir%/public/build/shop/manifest.json'
admin:
json_manifest_path: '%kernel.project_dir%/public/build/admin/manifest.json'
6 changes: 2 additions & 4 deletions tests/Application/config/packages/test_cached/framework.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
framework:
test: ~
session:
storage_id: session.storage.mock_file
imports:
- { resource: "../test/framework.yaml" }
5 changes: 5 additions & 0 deletions tests/Application/config/packages/webpack_encore.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
webpack_encore:
output_path: '%kernel.project_dir%/public/build/default'
builds:
shop: '%kernel.project_dir%/public/build/shop'
admin: '%kernel.project_dir%/public/build/admin'
1 change: 1 addition & 0 deletions tests/Application/config/sylius/1.10/bundles.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

return [
Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle::class => ['all' => true],
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,2 @@
imports:
- { resource: "../test/swiftmailer.yaml" }
1 change: 1 addition & 0 deletions tests/Application/config/sylius/1.11/bundles.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

return [
Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle::class => ['all' => true],
BabDev\PagerfantaBundle\BabDevPagerfantaBundle::class => ['all' => true],
SyliusLabs\Polyfill\Symfony\Security\Bundle\SyliusLabsPolyfillSymfonySecurityBundle::class => ['all' => true],
Sylius\Calendar\SyliusCalendarBundle::class => ['all' => true],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
swiftmailer:
disable_delivery: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
swiftmailer:
url: '%env(MAILER_URL)%'
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
swiftmailer:
disable_delivery: true
logging: true
spool:
type: file
path: "%kernel.cache_dir%/spool"
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
imports:
- { resource: "../test/swiftmailer.yaml" }
8 changes: 8 additions & 0 deletions tests/Application/config/sylius/1.12/bundles.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

return [
BabDev\PagerfantaBundle\BabDevPagerfantaBundle::class => ['all' => true],
SyliusLabs\Polyfill\Symfony\Security\Bundle\SyliusLabsPolyfillSymfonySecurityBundle::class => ['all' => true],
Sylius\Calendar\SyliusCalendarBundle::class => ['all' => true],
League\FlysystemBundle\FlysystemBundle::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%'
3 changes: 3 additions & 0 deletions tests/Application/config/sylius/1.12/packages/mailer.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
framework:
mailer:
dsn: '%env(MAILER_DSN)%'
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
148 changes: 148 additions & 0 deletions tests/Application/config/sylius/1.12/packages/security.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
parameters:
sylius.security.admin_regex: "^/%sylius_admin.path_name%"
sylius.security.api_regex: "^/api"
sylius.security.shop_regex: "^/(?!%sylius_admin.path_name%|new-api|api/.*|api$|media/.*)[^/]++"
sylius.security.new_api_route: "/new-api"
sylius.security.new_api_regex: "^%sylius.security.new_api_route%"
sylius.security.new_api_admin_route: "%sylius.security.new_api_route%/admin"
sylius.security.new_api_admin_regex: "^%sylius.security.new_api_admin_route%"
sylius.security.new_api_shop_route: "%sylius.security.new_api_route%/shop"
sylius.security.new_api_shop_regex: "^%sylius.security.new_api_shop_route%"

security:
always_authenticate_before_granting: true
providers:
sylius_admin_user_provider:
id: sylius.admin_user_provider.email_or_name_based
sylius_api_admin_user_provider:
id: sylius.admin_user_provider.email_or_name_based
sylius_shop_user_provider:
id: sylius.shop_user_provider.email_or_name_based
sylius_api_shop_user_provider:
id: sylius.shop_user_provider.email_or_name_based
sylius_api_chain_provider:
chain:
providers: [sylius_api_shop_user_provider, sylius_api_admin_user_provider]

encoders:
Sylius\Component\User\Model\UserInterface: argon2i
firewalls:
admin:
switch_user: true
context: admin
pattern: "%sylius.security.admin_regex%"
provider: sylius_admin_user_provider
form_login:
provider: sylius_admin_user_provider
login_path: sylius_admin_login
check_path: sylius_admin_login_check
failure_path: sylius_admin_login
default_target_path: sylius_admin_dashboard
use_forward: false
use_referer: true
csrf_token_generator: security.csrf.token_manager
csrf_parameter: _csrf_admin_security_token
csrf_token_id: admin_authenticate
remember_me:
secret: "%env(APP_SECRET)%"
path: "/%sylius_admin.path_name%"
name: APP_ADMIN_REMEMBER_ME
lifetime: 31536000
remember_me_parameter: _remember_me
logout:
path: sylius_admin_logout
target: sylius_admin_login
anonymous: true

new_api_admin_user:
pattern: "%sylius.security.new_api_route%/admin-user-authentication-token"
provider: sylius_admin_user_provider
stateless: true
anonymous: true
json_login:
check_path: "%sylius.security.new_api_route%/admin-user-authentication-token"
username_path: email
password_path: password
success_handler: lexik_jwt_authentication.handler.authentication_success
failure_handler: lexik_jwt_authentication.handler.authentication_failure
guard:
authenticators:
- lexik_jwt_authentication.jwt_token_authenticator

new_api_shop_user:
pattern: "%sylius.security.new_api_route%/shop-user-authentication-token"
provider: sylius_shop_user_provider
stateless: true
anonymous: true
json_login:
check_path: "%sylius.security.new_api_route%/shop-user-authentication-token"
username_path: email
password_path: password
success_handler: lexik_jwt_authentication.handler.authentication_success
failure_handler: lexik_jwt_authentication.handler.authentication_failure
guard:
authenticators:
- lexik_jwt_authentication.jwt_token_authenticator

new_api:
pattern: "%sylius.security.new_api_regex%/*"
provider: sylius_api_chain_provider
stateless: true
anonymous: lazy
guard:
authenticators:
- lexik_jwt_authentication.jwt_token_authenticator

shop:
switch_user: { role: ROLE_ALLOWED_TO_SWITCH }
context: shop
pattern: "%sylius.security.shop_regex%"
provider: sylius_shop_user_provider
form_login:
success_handler: sylius.authentication.success_handler
failure_handler: sylius.authentication.failure_handler
provider: sylius_shop_user_provider
login_path: sylius_shop_login
check_path: sylius_shop_login_check
failure_path: sylius_shop_login
default_target_path: sylius_shop_homepage
use_forward: false
use_referer: true
csrf_token_generator: security.csrf.token_manager
csrf_parameter: _csrf_shop_security_token
csrf_token_id: shop_authenticate
remember_me:
secret: "%env(APP_SECRET)%"
name: APP_SHOP_REMEMBER_ME
lifetime: 31536000
remember_me_parameter: _remember_me
logout:
path: sylius_shop_logout
target: sylius_shop_login
invalidate_session: false
success_handler: sylius.handler.shop_user_logout
anonymous: true

dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false

access_control:
- { path: "%sylius.security.admin_regex%/_partial", role: IS_AUTHENTICATED_ANONYMOUSLY, ips: [127.0.0.1, ::1] }
- { path: "%sylius.security.admin_regex%/_partial", role: ROLE_NO_ACCESS }
- { path: "%sylius.security.shop_regex%/_partial", role: IS_AUTHENTICATED_ANONYMOUSLY, ips: [127.0.0.1, ::1] }
- { path: "%sylius.security.shop_regex%/_partial", role: ROLE_NO_ACCESS }

- { path: "%sylius.security.admin_regex%/login", role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: "%sylius.security.api_regex%/login", role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: "%sylius.security.shop_regex%/login", role: IS_AUTHENTICATED_ANONYMOUSLY }

- { path: "%sylius.security.shop_regex%/register", role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: "%sylius.security.shop_regex%/verify", role: IS_AUTHENTICATED_ANONYMOUSLY }

- { path: "%sylius.security.admin_regex%", role: ROLE_ADMINISTRATION_ACCESS }
- { path: "%sylius.security.api_regex%/.*", role: ROLE_API_ACCESS }
- { path: "%sylius.security.shop_regex%/account", role: ROLE_USER }

- { path: "%sylius.security.new_api_admin_regex%/.*", role: ROLE_API_ACCESS }
- { path: "%sylius.security.new_api_shop_regex%/.*", role: IS_AUTHENTICATED_ANONYMOUSLY }
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
framework:
test: ~
session:
storage_factory_id: session.storage.factory.mock_file
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
framework:
cache:
pools:
test.mailer_pool:
adapter: cache.adapter.filesystem
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
security:
password_hashers:
Sylius\Component\User\Model\UserInterface: argon2i
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
imports:
- { resource: "../test/framework.yaml" }
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
imports:
- { resource: "../test/mailer.yaml" }
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
imports:
- { resource: "../test/framework.yaml" }
1 change: 1 addition & 0 deletions tests/Application/config/sylius/1.8/bundles.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

return [
Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle::class => ['all' => true],
Doctrine\Bundle\DoctrineCacheBundle\DoctrineCacheBundle::class => ['all' => true],
WhiteOctober\PagerfantaBundle\WhiteOctoberPagerfantaBundle::class => ['all' => true],
FOS\OAuthServerBundle\FOSOAuthServerBundle::class => ['all' => true],
Expand Down
Loading

0 comments on commit a5e175b

Please sign in to comment.