From 6e86cf18adbe0e84acf684d6062e486785ae2b4b Mon Sep 17 00:00:00 2001 From: SirDomin Date: Mon, 20 Dec 2021 09:15:01 +0100 Subject: [PATCH 1/4] [Build] remove php 7.4 from workflow --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f36579af..68db7633 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -18,7 +18,7 @@ jobs: strategy: fail-fast: false matrix: - php: ["8.0", "7.4"] + php: ["8.0"] node: ["10.x"] mysql: ["5.7", "8.0"] symfony: ["^4.4", "^5.2"] From f43a96bbd3e6192389a5b36d1d41483e838e1c9c Mon Sep 17 00:00:00 2001 From: SirDomin Date: Mon, 20 Dec 2021 09:19:21 +0100 Subject: [PATCH 2/4] add phpstan array description --- src/DependencyInjection/SyliusPayPalExtension.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/DependencyInjection/SyliusPayPalExtension.php b/src/DependencyInjection/SyliusPayPalExtension.php index 84371d8e..b882d2bc 100644 --- a/src/DependencyInjection/SyliusPayPalExtension.php +++ b/src/DependencyInjection/SyliusPayPalExtension.php @@ -51,6 +51,7 @@ public function prepend(ContainerBuilder $container): void return; } + /** @var array $doctrineConfig */ $doctrineConfig = $container->getExtensionConfig('doctrine_migrations'); $migrationsPath = (array) \array_pop($doctrineConfig)['migrations_paths']; $container->prependExtensionConfig('doctrine_migrations', [ From 6557b27367a64f2ce6adbce14fc42039708ed5b1 Mon Sep 17 00:00:00 2001 From: SirDomin Date: Mon, 3 Jan 2022 08:43:01 +0100 Subject: [PATCH 3/4] [Support] drop support to sylius 1.9, add support to sylius 1.11 --- .github/workflows/build.yml | 8 +- composer.json | 4 +- tests/Application/.env | 1 + tests/Application/.env.test | 2 + tests/Application/Kernel.php | 64 ++----- .../config/api_platform/config.yaml | 0 tests/Application/config/bundles.php | 2 + .../{sylius/1.10 => }/packages/security.yaml | 0 .../config/sylius/1.10/bundles.php | 6 - .../Application/config/sylius/1.9/bundles.php | 8 - .../config/sylius/1.9/packages/_sylius.yaml | 2 - .../1.9/packages/dev/jms_serializer.yaml | 12 -- .../sylius/1.9/packages/jms_serializer.yaml | 4 - .../1.9/packages/prod/jms_serializer.yaml | 10 -- .../config/sylius/1.9/packages/security.yaml | 159 ------------------ .../sylius/1.9/routes/sylius_admin_api.yaml | 3 - 16 files changed, 27 insertions(+), 258 deletions(-) create mode 100644 tests/Application/config/api_platform/config.yaml rename tests/Application/config/{sylius/1.10 => }/packages/security.yaml (100%) delete mode 100644 tests/Application/config/sylius/1.10/bundles.php delete mode 100644 tests/Application/config/sylius/1.9/bundles.php delete mode 100644 tests/Application/config/sylius/1.9/packages/_sylius.yaml delete mode 100644 tests/Application/config/sylius/1.9/packages/dev/jms_serializer.yaml delete mode 100644 tests/Application/config/sylius/1.9/packages/jms_serializer.yaml delete mode 100644 tests/Application/config/sylius/1.9/packages/prod/jms_serializer.yaml delete mode 100644 tests/Application/config/sylius/1.9/packages/security.yaml delete mode 100644 tests/Application/config/sylius/1.9/routes/sylius_admin_api.yaml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 68db7633..7752d866 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -21,13 +21,9 @@ jobs: php: ["8.0"] node: ["10.x"] mysql: ["5.7", "8.0"] - symfony: ["^4.4", "^5.2"] - sylius: ["~1.9.0", "~1.10.0"] + symfony: ["^4.4", "^5.4"] + sylius: ["~1.10.0", "^1.11.0-alpha"] - exclude: - - - php: "8.0" - sylius: "~1.9.0" env: APP_ENV: test DATABASE_URL: "mysql://root:root@127.0.0.1/sylius?serverVersion=${{ matrix.mysql }}" diff --git a/composer.json b/composer.json index 43037430..e22a883d 100644 --- a/composer.json +++ b/composer.json @@ -6,8 +6,8 @@ "license": "MIT", "require": { "php": "^7.4 || ^8.0", - - "sylius/sylius": "^1.9", + "polishsymfonycommunity/symfony-mocker-container": "^1.0", + "sylius/sylius": "^1.11-alpha", "phpseclib/phpseclib": "^2.0", "sylius-labs/doctrine-migrations-extra-bundle": "^0.1.3", "doctrine/doctrine-migrations-bundle": "^3.0" diff --git a/tests/Application/.env b/tests/Application/.env index 213ba3e5..23cd115b 100644 --- a/tests/Application/.env +++ b/tests/Application/.env @@ -21,3 +21,4 @@ DATABASE_URL=mysql://root@127.0.0.1/sylius_pay_pal_plugin_%kernel.environment% # Delivery is disabled by default via "null://localhost" MAILER_URL=smtp://localhost ###< symfony/swiftmailer-bundle ### +MESSENGER_TRANSPORT_DSN=doctrine://default diff --git a/tests/Application/.env.test b/tests/Application/.env.test index 8143b5ed..86f84732 100644 --- a/tests/Application/.env.test +++ b/tests/Application/.env.test @@ -3,3 +3,5 @@ APP_SECRET='ch4mb3r0f5ecr3ts' KERNEL_CLASS='Tests\Sylius\PayPalPlugin\Application\Kernel' TEST_CLIENT_ID='AWKG4oiWX9AOifqtdkbOTgSgi3MqcaiyAt-x9Pa35lDdW94kjrOEqN-n3NQ4hD2TuomgpiDc27snMKd9' + +MESSENGER_TRANSPORT_DSN=sync:// diff --git a/tests/Application/Kernel.php b/tests/Application/Kernel.php index e52fbee8..c9e923d0 100644 --- a/tests/Application/Kernel.php +++ b/tests/Application/Kernel.php @@ -25,7 +25,6 @@ use Symfony\Component\HttpKernel\Kernel as BaseKernel; use Symfony\Component\Routing\RouteCollectionBuilder; use Webmozart\Assert\Assert; - final class Kernel extends BaseKernel { use MicroKernelTrait; @@ -44,73 +43,46 @@ public function getLogDir(): string public function registerBundles(): iterable { - foreach ($this->getConfigurationDirectories() as $confDir) { - yield from $this->registerBundlesFromFile($confDir . '/bundles.php'); + $contents = require $this->getProjectDir() . '/config/bundles.php'; + foreach ($contents as $class => $envs) { + if (isset($envs['all']) || isset($envs[$this->environment])) { + yield new $class(); + } } } protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader): void { - foreach ($this->getConfigurationDirectories() as $confDir) { - $container->addResource(new FileResource($confDir . '/bundles.php')); - } - - foreach ($this->getConfigurationDirectories() as $confDir) { - $this->loadContainerConfiguration($loader, $confDir); - } - } - - protected function configureRoutes(RouteCollectionBuilder $routes): void - { - foreach ($this->getConfigurationDirectories() as $confDir) { - $this->loadRoutesConfiguration($routes, $confDir); - } - } - - protected function getContainerBaseClass(): string - { - if ($this->isTestEnvironment()) { - return MockerContainer::class; - } - - return parent::getContainerBaseClass(); - } - - private function isTestEnvironment(): bool - { - return 0 === strpos($this->getEnvironment(), 'test'); - } + $container->addResource(new FileResource($this->getProjectDir() . '/config/bundles.php')); + $container->setParameter('container.dumper.inline_class_loader', true); + $confDir = $this->getProjectDir() . '/config'; - 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 + protected function configureRoutes(RouteCollectionBuilder $routes): void { + $confDir = $this->getProjectDir() . '/config'; + $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'); } - /** @return BundleInterface[] */ - private function registerBundlesFromFile(string $bundlesFile): iterable + protected function getContainerBaseClass(): string { - $contents = require $bundlesFile; - foreach ($contents as $class => $environments) { - if (isset($environments['all']) || isset($environments[$this->environment])) { - yield new $class(); - } + if ($this->isTestEnvironment() && class_exists(MockerContainer::class)) { + return MockerContainer::class; } + + return parent::getContainerBaseClass(); } - /** @return string[] */ - private function getConfigurationDirectories(): iterable + private function isTestEnvironment(): bool { - yield $this->getProjectDir() . '/config'; - yield $this->getProjectDir() . '/config/sylius/' . SyliusKernel::MAJOR_VERSION . '.' . SyliusKernel::MINOR_VERSION; + return 0 === strpos($this->getEnvironment(), 'test'); } } diff --git a/tests/Application/config/api_platform/config.yaml b/tests/Application/config/api_platform/config.yaml new file mode 100644 index 00000000..e69de29b diff --git a/tests/Application/config/bundles.php b/tests/Application/config/bundles.php index 4fcad584..4e84ef84 100644 --- a/tests/Application/config/bundles.php +++ b/tests/Application/config/bundles.php @@ -55,4 +55,6 @@ SyliusLabs\DoctrineMigrationsExtraBundle\SyliusLabsDoctrineMigrationsExtraBundle::class => ['all' => true], Nelmio\Alice\Bridge\Symfony\NelmioAliceBundle::class => ['dev' => true, 'test' => true], Fidry\AliceDataFixtures\Bridge\Symfony\FidryAliceDataFixturesBundle::class => ['dev' => true, 'test' => true], + BabDev\PagerfantaBundle\BabDevPagerfantaBundle::class => ['all' => true], + SyliusLabs\Polyfill\Symfony\Security\Bundle\SyliusLabsPolyfillSymfonySecurityBundle::class => ['all' => true], ]; diff --git a/tests/Application/config/sylius/1.10/packages/security.yaml b/tests/Application/config/packages/security.yaml similarity index 100% rename from tests/Application/config/sylius/1.10/packages/security.yaml rename to tests/Application/config/packages/security.yaml diff --git a/tests/Application/config/sylius/1.10/bundles.php b/tests/Application/config/sylius/1.10/bundles.php deleted file mode 100644 index bd33f4ae..00000000 --- a/tests/Application/config/sylius/1.10/bundles.php +++ /dev/null @@ -1,6 +0,0 @@ - ['all' => true], - SyliusLabs\Polyfill\Symfony\Security\Bundle\SyliusLabsPolyfillSymfonySecurityBundle::class => ['all' => true], -]; diff --git a/tests/Application/config/sylius/1.9/bundles.php b/tests/Application/config/sylius/1.9/bundles.php deleted file mode 100644 index 03dbd31e..00000000 --- a/tests/Application/config/sylius/1.9/bundles.php +++ /dev/null @@ -1,8 +0,0 @@ - ['all' => true], - Sylius\Bundle\AdminApiBundle\SyliusAdminApiBundle::class => ['all' => true], - BabDev\PagerfantaBundle\BabDevPagerfantaBundle::class => ['all' => true], - SyliusLabs\Polyfill\Symfony\Security\Bundle\SyliusLabsPolyfillSymfonySecurityBundle::class => ['all' => true], -]; diff --git a/tests/Application/config/sylius/1.9/packages/_sylius.yaml b/tests/Application/config/sylius/1.9/packages/_sylius.yaml deleted file mode 100644 index 1674a972..00000000 --- a/tests/Application/config/sylius/1.9/packages/_sylius.yaml +++ /dev/null @@ -1,2 +0,0 @@ -imports: - - { resource: "@SyliusAdminApiBundle/Resources/config/app/config.yml" } diff --git a/tests/Application/config/sylius/1.9/packages/dev/jms_serializer.yaml b/tests/Application/config/sylius/1.9/packages/dev/jms_serializer.yaml deleted file mode 100644 index 2f32a9b1..00000000 --- a/tests/Application/config/sylius/1.9/packages/dev/jms_serializer.yaml +++ /dev/null @@ -1,12 +0,0 @@ -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 diff --git a/tests/Application/config/sylius/1.9/packages/jms_serializer.yaml b/tests/Application/config/sylius/1.9/packages/jms_serializer.yaml deleted file mode 100644 index ed7bc613..00000000 --- a/tests/Application/config/sylius/1.9/packages/jms_serializer.yaml +++ /dev/null @@ -1,4 +0,0 @@ -jms_serializer: - visitors: - xml_serialization: - format_output: '%kernel.debug%' diff --git a/tests/Application/config/sylius/1.9/packages/prod/jms_serializer.yaml b/tests/Application/config/sylius/1.9/packages/prod/jms_serializer.yaml deleted file mode 100644 index c2881820..00000000 --- a/tests/Application/config/sylius/1.9/packages/prod/jms_serializer.yaml +++ /dev/null @@ -1,10 +0,0 @@ -jms_serializer: - visitors: - json_serialization: - options: - - JSON_UNESCAPED_SLASHES - - JSON_PRESERVE_ZERO_FRACTION - json_deserialization: - options: - - JSON_UNESCAPED_SLASHES - - JSON_PRESERVE_ZERO_FRACTION diff --git a/tests/Application/config/sylius/1.9/packages/security.yaml b/tests/Application/config/sylius/1.9/packages/security.yaml deleted file mode 100644 index 904410bf..00000000 --- a/tests/Application/config/sylius/1.9/packages/security.yaml +++ /dev/null @@ -1,159 +0,0 @@ -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: "/api/v2" - 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 - - oauth_token: - pattern: "%sylius.security.api_regex%/oauth/v2/token" - security: false - - 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 - - api: - pattern: "%sylius.security.api_regex%/.*" - provider: sylius_admin_user_provider - fos_oauth: true - stateless: true - anonymous: true - - 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 } diff --git a/tests/Application/config/sylius/1.9/routes/sylius_admin_api.yaml b/tests/Application/config/sylius/1.9/routes/sylius_admin_api.yaml deleted file mode 100644 index 80aed457..00000000 --- a/tests/Application/config/sylius/1.9/routes/sylius_admin_api.yaml +++ /dev/null @@ -1,3 +0,0 @@ -sylius_admin_api: - resource: "@SyliusAdminApiBundle/Resources/config/routing.yml" - prefix: /api From ffeb95a0e2bdc83832778a65cd312f8143cf5f97 Mon Sep 17 00:00:00 2001 From: SirDomin Date: Mon, 3 Jan 2022 16:11:55 +0100 Subject: [PATCH 4/4] bring back 7.4 --- .github/workflows/build.yml | 6 ++++-- composer.json | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7752d866..0c430a2a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -18,12 +18,14 @@ jobs: strategy: fail-fast: false matrix: - php: ["8.0"] + php: ["7.4", "8.0"] node: ["10.x"] mysql: ["5.7", "8.0"] symfony: ["^4.4", "^5.4"] sylius: ["~1.10.0", "^1.11.0-alpha"] - + exclude: + - php: "7.4" + sylius: "^1.11.0-alpha" env: APP_ENV: test DATABASE_URL: "mysql://root:root@127.0.0.1/sylius?serverVersion=${{ matrix.mysql }}" diff --git a/composer.json b/composer.json index e22a883d..1f841ac1 100644 --- a/composer.json +++ b/composer.json @@ -7,7 +7,7 @@ "require": { "php": "^7.4 || ^8.0", "polishsymfonycommunity/symfony-mocker-container": "^1.0", - "sylius/sylius": "^1.11-alpha", + "sylius/sylius": "^1.10", "phpseclib/phpseclib": "^2.0", "sylius-labs/doctrine-migrations-extra-bundle": "^0.1.3", "doctrine/doctrine-migrations-bundle": "^3.0"