Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Symfony 6 #355

Merged
merged 1 commit into from
Nov 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
fail-fast: false
matrix:
php: ["8.0", "8.1"]
symfony: ["5.4.*"]
symfony: ["5.4.*", "^6.0"]
sylius: ["^1.12"]
node: ["14.x", "16.x", "18.x"]
mysql: ["5.7", "8.0"]
Expand Down Expand Up @@ -97,6 +97,12 @@ jobs:
composer global config --no-plugins allow-plugins.symfony/flex true
composer global require --no-progress --no-scripts --no-plugins "symfony/flex:^2.2.2"

-
name: Restrict Symfony version
if: matrix.symfony != ''
run: |
composer config extra.symfony.require "${{ matrix.symfony }}"

-
name: Restrict Sylius version
if: matrix.sylius != ''
Expand Down
13 changes: 6 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"require": {
"php": "^8.0",
"sylius/sylius": "^1.12",
"sylius/mailer-bundle": "^1.8 || ^2.0@beta",
"symfony/webpack-encore-bundle": "^1.15"
},
"require-dev": {
Expand All @@ -25,7 +26,6 @@
"friends-of-behat/suite-settings-extension": "^1.0",
"friends-of-behat/symfony-extension": "^2.1",
"friends-of-behat/variadic-extension": "^1.3",
"friendsofsymfony/oauth-server-bundle": "^1.6 || >2.0.0-alpha.0 ^2.0@dev",
"phpspec/phpspec": "^7.2",
"phpstan/extension-installer": "^1.0",
"phpstan/phpstan": "^1.8.1",
Expand All @@ -34,14 +34,13 @@
"phpstan/phpstan-webmozart-assert": "^1.2.0",
"phpunit/phpunit": "^9.5",
"polishsymfonycommunity/symfony-mocker-container": "^1.0",
"sensiolabs/security-checker": "^6.0",
"sylius-labs/coding-standard": "^4.2",
"symfony/browser-kit": "^5.4",
"symfony/debug-bundle": "^5.4",
"symfony/dotenv": "^5.4",
"symfony/browser-kit": "^5.4 || ^6.0",
"symfony/debug-bundle": "^5.4 || ^6.0",
"symfony/dotenv": "^5.4 || ^6.0",
"symfony/flex": "^2.2.2",
"symfony/intl": "^5.4",
"symfony/web-profiler-bundle": "^5.4",
"symfony/intl": "^5.4 || ^6.0",
"symfony/web-profiler-bundle": "^5.4 || ^6.0",
"vimeo/psalm": "4.27.0"
},
"config": {
Expand Down
40 changes: 6 additions & 34 deletions tests/Application/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,9 @@
use PSS\SymfonyMockerContainer\DependencyInjection\MockerContainer;
use Sylius\Bundle\CoreBundle\Application\Kernel as SyliusKernel;
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
use Symfony\Component\Config\Loader\LoaderInterface;
use Symfony\Component\Config\Resource\FileResource;
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 +38,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 +59,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
44 changes: 19 additions & 25 deletions tests/Application/config/packages/security.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
security:
always_authenticate_before_granting: true
enable_authenticator_manager: true
providers:
sylius_admin_user_provider:
id: sylius.admin_user_provider.email_or_name_based
Expand All @@ -10,7 +10,7 @@ security:
sylius_api_shop_user_provider:
id: sylius.shop_user_provider.email_or_name_based

encoders:
password_hashers:
Sylius\Component\User\Model\UserInterface: argon2i
firewalls:
admin:
Expand All @@ -26,7 +26,7 @@ security:
default_target_path: sylius_admin_dashboard
use_forward: false
use_referer: true
csrf_token_generator: security.csrf.token_manager
enable_csrf: true
csrf_parameter: _csrf_admin_security_token
csrf_token_id: admin_authenticate
remember_me:
Expand All @@ -38,37 +38,32 @@ security:
logout:
path: sylius_admin_logout
target: sylius_admin_login
anonymous: true

new_api_admin_user:
pattern: "%sylius.security.new_api_admin_regex%/.*"
provider: sylius_api_admin_user_provider
stateless: true
anonymous: true
entry_point: jwt
json_login:
check_path: "%sylius.security.new_api_admin_route%/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
jwt: true

new_api_shop_user:
pattern: "%sylius.security.new_api_shop_regex%/.*"
provider: sylius_api_shop_user_provider
stateless: true
anonymous: true
entry_point: jwt
json_login:
check_path: "%sylius.security.new_api_shop_route%/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
jwt: true

shop:
switch_user: { role: ROLE_ALLOWED_TO_SWITCH }
Expand All @@ -85,7 +80,7 @@ security:
default_target_path: sylius_shop_homepage
use_forward: false
use_referer: true
csrf_token_generator: security.csrf.token_manager
enable_csrf: true
csrf_parameter: _csrf_shop_security_token
csrf_token_id: shop_authenticate
remember_me:
Expand All @@ -95,10 +90,8 @@ security:
remember_me_parameter: _remember_me
logout:
path: sylius_shop_logout
target: sylius_shop_login
target: sylius_shop_homepage
invalidate_session: false
success_handler: sylius.handler.shop_user_logout
anonymous: true

dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
Expand All @@ -109,22 +102,23 @@ security:
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: PUBLIC_ACCESS, 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: PUBLIC_ACCESS, 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.shop_regex%/login", role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: "%sylius.security.admin_regex%/login", role: PUBLIC_ACCESS }
- { path: "%sylius.security.shop_regex%/login", role: PUBLIC_ACCESS }

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

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

- { path: "%sylius.security.new_api_admin_route%/reset-password-requests", role: PUBLIC_ACCESS }
- { path: "%sylius.security.new_api_admin_regex%/.*", role: ROLE_API_ACCESS }
- { path: "%sylius.security.new_api_admin_route%/authentication-token", role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: "%sylius.security.new_api_admin_route%/authentication-token", role: PUBLIC_ACCESS }
- { path: "%sylius.security.new_api_user_account_regex%/.*", role: ROLE_USER }
- { path: "%sylius.security.new_api_shop_route%/authentication-token", role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: "%sylius.security.new_api_shop_regex%/.*", role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: "%sylius.security.new_api_shop_route%/authentication-token", role: PUBLIC_ACCESS }
- { path: "%sylius.security.new_api_shop_regex%/.*", role: PUBLIC_ACCESS }
9 changes: 0 additions & 9 deletions tests/Application/config/packages/security_checker.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion tests/Application/config/packages/test/framework.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
framework:
test: ~
session:
storage_id: session.storage.mock_file
storage_factory_id: session.storage.factory.mock_file
7 changes: 5 additions & 2 deletions tests/Application/config/packages/test/security.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
security:
encoders:
sha512: sha512
password_hashers:
Sylius\Component\User\Model\UserInterface:
algorithm: argon2i
time_cost: 3
memory_cost: 10
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: 2 additions & 3 deletions tests/Application/config/packages/test_cached/security.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
security:
encoders:
sha512: sha512
imports:
- { resource: ../test/security.yaml }