From e5559ce1f50e25ea03095c694a7a95b834218517 Mon Sep 17 00:00:00 2001 From: Jan Goralski Date: Tue, 18 Oct 2022 08:17:15 +0200 Subject: [PATCH 1/7] [Maintenance] Remove sylius 1.10 leftovers --- .github/workflows/build.yml | 6 - phpunit.xml.dist | 11 +- tests/Behat/Resources/sylius-1.10/suites.yml | 163 ------------------- 3 files changed, 7 insertions(+), 173 deletions(-) delete mode 100644 tests/Behat/Resources/sylius-1.10/suites.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ad6d67e7..63cdfc20 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -120,12 +120,6 @@ jobs: name: Install JS dependencies run: (cd tests/Application && yarn install) - - - name: Prepare configuration for Sylius 1.10 - if: matrix.sylius == '1.10.*' - run: | - rm tests/Behat/Resources/suites.yml - cp tests/Behat/Resources/sylius-1.10/suites.yml tests/Behat/Resources - name: Prepare test application database run: | diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 8f3a1834..2eec8a0e 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -3,7 +3,8 @@ + bootstrap="tests/Application/config/bootstrap.php" +> tests @@ -13,10 +14,12 @@ - - - + + + + + diff --git a/tests/Behat/Resources/sylius-1.10/suites.yml b/tests/Behat/Resources/sylius-1.10/suites.yml deleted file mode 100644 index df27e53e..00000000 --- a/tests/Behat/Resources/sylius-1.10/suites.yml +++ /dev/null @@ -1,163 +0,0 @@ -# This file is part of the Sylius package. -# (c) Paweł Jędrzejewski - -default: - suites: - ui_checkout: - contexts: - - sylius.behat.context.hook.doctrine_orm - - sylius.behat.context.hook.email_spool - - - sylius.behat.context.transform.address - - sylius.behat.context.transform.country - - sylius.behat.context.transform.channel - - sylius.behat.context.transform.currency - - sylius.behat.context.transform.customer - - sylius.behat.context.transform.lexical - - sylius.behat.context.transform.locale - - sylius.behat.context.transform.order - - sylius.behat.context.transform.payment - - sylius.behat.context.transform.product - - sylius.behat.context.transform.product_option - - sylius.behat.context.transform.province - - sylius.behat.context.transform.shared_storage - - sylius.behat.context.transform.shipping_category - - sylius.behat.context.transform.shipping_method - - sylius.behat.context.transform.tax_category - - sylius.behat.context.transform.user - - sylius.behat.context.transform.zone - - - sylius.behat.context.setup.address - - sylius.behat.context.setup.admin_user - - sylius.behat.context.setup.channel - - sylius.behat.context.setup.currency - - sylius.behat.context.setup.customer - - sylius.behat.context.setup.exchange_rate - - sylius.behat.context.setup.geographical - - sylius.behat.context.setup.locale - - sylius.behat.context.setup.payment - - sylius.behat.context.setup.product - - sylius.behat.context.setup.promotion - - sylius.behat.context.setup.shop_security - - sylius.behat.context.setup.shipping - - sylius.behat.context.setup.shipping_category - - sylius.behat.context.setup.taxation - - sylius.behat.context.setup.user - - sylius.behat.context.setup.zone - - Tests\Sylius\PayPalPlugin\Behat\Context\Setup\PaymentPayPalContext - - - sylius.behat.context.ui.admin.managing_orders - - sylius.behat.context.ui.channel - - sylius.behat.context.ui.email - - sylius.behat.context.ui.shop.address_book - - sylius.behat.context.ui.shop.cart - - sylius.behat.context.ui.shop.checkout - - sylius.behat.context.ui.shop.checkout.addressing - - sylius.behat.context.ui.shop.checkout.complete - - sylius.behat.context.ui.shop.checkout.payment - - sylius.behat.context.ui.shop.checkout.shipping - - sylius.behat.context.ui.shop.checkout.thank_you - - sylius.behat.context.ui.shop.checkout.registration_after_checkout - - sylius.behat.context.ui.shop.currency - - sylius.behat.context.ui.shop.homepage - - sylius.behat.context.ui.shop.locale - - filters: - tags: "@checkout && @ui" - ui_managing_payment_methods: - contexts: - - sylius.behat.context.hook.doctrine_orm - - - sylius.behat.context.transform.address - - sylius.behat.context.transform.channel - - sylius.behat.context.transform.country - - sylius.behat.context.transform.customer - - sylius.behat.context.transform.order - - sylius.behat.context.transform.payment - - sylius.behat.context.transform.product - - sylius.behat.context.transform.shared_storage - - sylius.behat.context.transform.shipping_method - - sylius.behat.context.transform.zone - - sylius.behat.context.transform.lexical - - - sylius.behat.context.setup.admin_security - - sylius.behat.context.setup.channel - - sylius.behat.context.setup.customer - - sylius.behat.context.setup.geographical - - sylius.behat.context.setup.order - - sylius.behat.context.setup.payment - - sylius.behat.context.setup.product - - sylius.behat.context.setup.shipping - - sylius.behat.context.setup.zone - - - Tests\Sylius\PayPalPlugin\Behat\Context\Setup\PaymentPayPalContext - - - sylius.behat.context.ui.admin.managing_payment_methods - - sylius.behat.context.ui.channel - - sylius.behat.context.ui.email - - sylius.behat.context.ui.shop.cart - - - Tests\Sylius\PayPalPlugin\Behat\Context\Admin\ManagingPaymentMethodsContext - filters: - tags: "@managing_payment_methods && @ui" - ui_managing_orders: - contexts: - - sylius.behat.context.hook.calendar - - sylius.behat.context.hook.doctrine_orm - - sylius.behat.context.hook.email_spool - - - sylius.behat.context.setup.admin_security - - sylius.behat.context.setup.admin_user - - sylius.behat.context.setup.calendar - - sylius.behat.context.setup.channel - - sylius.behat.context.setup.currency - - sylius.behat.context.setup.customer - - sylius.behat.context.setup.geographical - - sylius.behat.context.setup.locale - - sylius.behat.context.setup.order - - sylius.behat.context.setup.payment - - sylius.behat.context.setup.product - - sylius.behat.context.setup.product_taxon - - sylius.behat.context.setup.promotion - - sylius.behat.context.setup.shipping - - sylius.behat.context.setup.shop_security - - sylius.behat.context.setup.taxation - - sylius.behat.context.setup.taxonomy - - sylius.behat.context.setup.user - - sylius.behat.context.setup.zone - - - Tests\Sylius\PayPalPlugin\Behat\Context\Setup\PaymentPayPalContext - - - sylius.behat.context.transform.address - - sylius.behat.context.transform.channel - - sylius.behat.context.transform.country - - sylius.behat.context.transform.currency - - sylius.behat.context.transform.customer - - sylius.behat.context.transform.lexical - - sylius.behat.context.transform.locale - - sylius.behat.context.transform.order - - sylius.behat.context.transform.payment - - sylius.behat.context.transform.product - - sylius.behat.context.transform.product_variant - - sylius.behat.context.transform.promotion - - sylius.behat.context.transform.shipping_method - - sylius.behat.context.transform.tax_category - - sylius.behat.context.transform.taxon - - sylius.behat.context.transform.zone - - - sylius.behat.context.transform.shared_storage - - - sylius.behat.context.ui.admin.managing_orders - - sylius.behat.context.ui.admin.notification - - sylius.behat.context.ui.channel - - sylius.behat.context.ui.email - - sylius.behat.context.ui.shop.cart - - sylius.behat.context.ui.shop.checkout - - sylius.behat.context.ui.shop.checkout.addressing - - sylius.behat.context.ui.shop.checkout.complete - - sylius.behat.context.ui.shop.currency - - - Tests\Sylius\PayPalPlugin\Behat\Context\Admin\ManagingOrdersContext - - filters: - tags: "@managing_orders && @ui" From 30953046fb797c6b2e12e159e4ac7711f83039f3 Mon Sep 17 00:00:00 2001 From: Jan Goralski Date: Tue, 18 Oct 2022 09:32:18 +0200 Subject: [PATCH 2/7] [Maintenance] Fix incorrect spec location --- spec/{Api => Provider}/OrderProviderSpec.php | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename spec/{Api => Provider}/OrderProviderSpec.php (100%) diff --git a/spec/Api/OrderProviderSpec.php b/spec/Provider/OrderProviderSpec.php similarity index 100% rename from spec/Api/OrderProviderSpec.php rename to spec/Provider/OrderProviderSpec.php From dfbf928e42fa30d5b9f8ce355265f37c0901fa6e Mon Sep 17 00:00:00 2001 From: Jan Goralski Date: Tue, 18 Oct 2022 09:36:21 +0200 Subject: [PATCH 3/7] [Maintenance] Conditional Swiftmailer/Symfony Mailer config --- .github/workflows/build.yml | 8 +- composer.json | 21 ++- tests/Application/.env | 5 + tests/Application/Kernel.php | 54 +++----- tests/Application/config/bundles.php | 6 +- .../1.11}/packages/dev/swiftmailer.yaml | 0 .../{ => sylius/1.11}/packages/security.yaml | 0 .../1.11}/packages/staging/swiftmailer.yaml | 0 .../1.11}/packages/swiftmailer.yaml | 0 .../1.11}/packages/test/swiftmailer.yaml | 0 .../packages/test_cached/swiftmailer.yaml | 0 .../config/sylius/1.12/packages/mailer.yaml | 3 + .../config/sylius/1.12/packages/security.yaml | 130 ++++++++++++++++++ .../sylius/1.12/packages/test/mailer.yaml | 5 + .../1.12/packages/test_cached/mailer.yaml | 2 + tests/Application/public/index.php | 2 +- tests/Behat/Resources/services.xml | 9 +- tests/Behat/Resources/services/mailer.php | 18 +++ tests/Behat/Resources/suites.yml | 4 +- 19 files changed, 212 insertions(+), 55 deletions(-) rename tests/Application/config/{ => sylius/1.11}/packages/dev/swiftmailer.yaml (100%) rename tests/Application/config/{ => sylius/1.11}/packages/security.yaml (100%) rename tests/Application/config/{ => sylius/1.11}/packages/staging/swiftmailer.yaml (100%) rename tests/Application/config/{ => sylius/1.11}/packages/swiftmailer.yaml (100%) rename tests/Application/config/{ => sylius/1.11}/packages/test/swiftmailer.yaml (100%) rename tests/Application/config/{ => sylius/1.11}/packages/test_cached/swiftmailer.yaml (100%) create mode 100644 tests/Application/config/sylius/1.12/packages/mailer.yaml create mode 100644 tests/Application/config/sylius/1.12/packages/security.yaml create mode 100644 tests/Application/config/sylius/1.12/packages/test/mailer.yaml create mode 100644 tests/Application/config/sylius/1.12/packages/test_cached/mailer.yaml create mode 100644 tests/Behat/Resources/services/mailer.php diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 63cdfc20..44f1e9e7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -22,12 +22,8 @@ jobs: php: ["8.0", "8.1"] node: ["16.x"] mysql: ["5.7", "8.0"] - symfony: ["^4.4", "^5.4"] + symfony: ["^5.4"] sylius: ["1.11.*", "~1.12.x-dev"] - exclude: - - - symfony: "^4.4" - sylius: "~1.12.x-dev" env: APP_ENV: test DATABASE_URL: "mysql://root:root@127.0.0.1/sylius?serverVersion=${{ matrix.mysql }}" @@ -100,7 +96,7 @@ jobs: - name: Install PHP dependencies - run: composer install --no-interaction + run: composer update --no-interaction - name: Get Yarn cache directory diff --git a/composer.json b/composer.json index 490aedd0..f02ca9ab 100644 --- a/composer.json +++ b/composer.json @@ -6,11 +6,12 @@ "license": "MIT", "require": { "php": "^8.0", + "doctrine/doctrine-migrations-bundle": "^3.0", + "phpseclib/phpseclib": "^2.0", "polishsymfonycommunity/symfony-mocker-container": "^1.0", + "sylius-labs/doctrine-migrations-extra-bundle": "^0.1.4 || ^0.2", "sylius/sylius": "~1.11.0 || 1.12.x-dev", - "phpseclib/phpseclib": "^2.0", - "sylius-labs/doctrine-migrations-extra-bundle": "^0.1.3", - "doctrine/doctrine-migrations-bundle": "^3.0" + "symfony/mailer": "^5.4" }, "require-dev": { "behat/behat": "^3.6.1", @@ -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": ">2.0.0-alpha.0 ^2.0@dev", "phpspec/phpspec": "^7.0", "phpstan/phpstan": "0.12.98", "phpstan/phpstan-doctrine": "0.12.33", @@ -33,19 +33,17 @@ "phpunit/phpunit": "^8.5", "sensiolabs/security-checker": "^6.0", "sylius-labs/coding-standard": "^4.0", - "symfony/browser-kit": "^4.4 || ^5.2", - "symfony/debug-bundle": "^4.4 || ^5.2", - "symfony/dotenv": "^4.4 || ^5.2", - "symfony/intl": "^4.4 || ^5.2", - "symfony/web-profiler-bundle": "^4.4 || ^5.2", - "symfony/web-server-bundle": "^4.4|^5.0", + "symfony/browser-kit": "^5.4", + "symfony/debug-bundle": "^5.4", + "symfony/dotenv": "^5.4", + "symfony/intl": "^5.4", + "symfony/web-profiler-bundle": "^5.4", "vimeo/psalm": "4.27.0", "rector/rector": "^0.11.53", "lchrusciel/api-test-case": "^5.1", "symfony/webpack-encore-bundle": "^1.15" }, "conflict": { - "symfony/doctrine-bridge": "4.4.16", "doctrine/doctrine-bundle": "2.3.0", "doctrine/dbal": "^3.0.0", "sylius/invoicing-plugin": "<0.16.0" @@ -60,6 +58,7 @@ "classmap": ["tests/Application/Kernel.php"] }, "config": { + "sort-packages": true, "allow-plugins": { "dealerdirect/phpcodesniffer-composer-installer": false, "ocramius/package-versions": false, diff --git a/tests/Application/.env b/tests/Application/.env index 23cd115b..b7c019cd 100644 --- a/tests/Application/.env +++ b/tests/Application/.env @@ -21,4 +21,9 @@ 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 + +###> symfony/mailer ### +MAILER_DSN=null://null +###< symfony/mailer ### diff --git a/tests/Application/Kernel.php b/tests/Application/Kernel.php index ab0c493b..db65e57d 100644 --- a/tests/Application/Kernel.php +++ b/tests/Application/Kernel.php @@ -7,24 +7,12 @@ use PSS\SymfonyMockerContainer\DependencyInjection\MockerContainer; use Sylius\Bundle\CoreBundle\Application\Kernel as SyliusKernel; use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait; -use Symfony\Component\Config\Loader\DelegatingLoader; use Symfony\Component\Config\Loader\LoaderInterface; -use Symfony\Component\Config\Loader\LoaderResolver; use Symfony\Component\Config\Resource\FileResource; use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\DependencyInjection\ContainerInterface; -use Symfony\Component\DependencyInjection\Loader\ClosureLoader; -use Symfony\Component\DependencyInjection\Loader\DirectoryLoader; -use Symfony\Component\DependencyInjection\Loader\GlobFileLoader; -use Symfony\Component\DependencyInjection\Loader\IniFileLoader; -use Symfony\Component\DependencyInjection\Loader\PhpFileLoader; -use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; -use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; -use Symfony\Component\HttpKernel\Config\FileLocator; -use Symfony\Component\HttpKernel\Bundle\BundleInterface; use Symfony\Component\HttpKernel\Kernel as BaseKernel; -use Symfony\Component\Routing\RouteCollectionBuilder; -use Webmozart\Assert\Assert; +use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator; + final class Kernel extends BaseKernel { use MicroKernelTrait; @@ -45,13 +33,6 @@ public function registerBundles(): iterable { $contents = require $this->getProjectDir() . '/config/bundles.php'; - if (SyliusKernel::MINOR_VERSION > 10) { - $contents = array_merge( - ['Sylius\Calendar\SyliusCalendarBundle' => ['all' => true]], - $contents - ); - } - foreach ($contents as $class => $envs) { if (isset($envs['all']) || isset($envs[$this->environment])) { yield new $class(); @@ -63,21 +44,22 @@ protected function configureContainer(ContainerBuilder $container, LoaderInterfa { $container->addResource(new FileResource($this->getProjectDir() . '/config/bundles.php')); $container->setParameter('container.dumper.inline_class_loader', true); - $confDir = $this->getProjectDir() . '/config'; - $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'); + foreach ($this->getConfigDirectories() as $confDir) { + $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'); + } } - protected function configureRoutes(RouteCollectionBuilder $routes): void + protected function configureRoutes(RoutingConfigurator $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'); + foreach ($this->getConfigDirectories() as $confDir) { + $routes->import($confDir . '/{routes}/*' . self::CONFIG_EXTS); + $routes->import($confDir . '/{routes}/' . $this->environment . '/**/*' . self::CONFIG_EXTS); + $routes->import($confDir . '/{routes}' . self::CONFIG_EXTS); + } } protected function getContainerBaseClass(): string @@ -89,6 +71,14 @@ protected function getContainerBaseClass(): string return parent::getContainerBaseClass(); } + private function getConfigDirectories(): array + { + return array_filter([ + $this->getProjectDir() . '/config', + $this->getProjectDir() . '/config/sylius/' . SyliusKernel::MAJOR_VERSION . '.' . SyliusKernel::MINOR_VERSION, + ], 'file_exists'); + } + private function isTestEnvironment(): bool { return 0 === strpos($this->getEnvironment(), 'test'); diff --git a/tests/Application/config/bundles.php b/tests/Application/config/bundles.php index 909a3850..d260b314 100644 --- a/tests/Application/config/bundles.php +++ b/tests/Application/config/bundles.php @@ -6,7 +6,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], @@ -60,9 +59,12 @@ BabDev\PagerfantaBundle\BabDevPagerfantaBundle::class => ['all' => true], SyliusLabs\Polyfill\Symfony\Security\Bundle\SyliusLabsPolyfillSymfonySecurityBundle::class => ['all' => true], Symfony\WebpackEncoreBundle\WebpackEncoreBundle::class => ['all' => true], + Sylius\Calendar\SyliusCalendarBundle::class => ['all' => true], ]; -if (Kernel::MINOR_VERSION >= 12) { +if (Kernel::MINOR_VERSION < 12) { + $bundles[Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle::class] = ['all' => true]; +} else { $bundles[League\FlysystemBundle\FlysystemBundle::class] = ['all' => true]; } diff --git a/tests/Application/config/packages/dev/swiftmailer.yaml b/tests/Application/config/sylius/1.11/packages/dev/swiftmailer.yaml similarity index 100% rename from tests/Application/config/packages/dev/swiftmailer.yaml rename to tests/Application/config/sylius/1.11/packages/dev/swiftmailer.yaml diff --git a/tests/Application/config/packages/security.yaml b/tests/Application/config/sylius/1.11/packages/security.yaml similarity index 100% rename from tests/Application/config/packages/security.yaml rename to tests/Application/config/sylius/1.11/packages/security.yaml diff --git a/tests/Application/config/packages/staging/swiftmailer.yaml b/tests/Application/config/sylius/1.11/packages/staging/swiftmailer.yaml similarity index 100% rename from tests/Application/config/packages/staging/swiftmailer.yaml rename to tests/Application/config/sylius/1.11/packages/staging/swiftmailer.yaml diff --git a/tests/Application/config/packages/swiftmailer.yaml b/tests/Application/config/sylius/1.11/packages/swiftmailer.yaml similarity index 100% rename from tests/Application/config/packages/swiftmailer.yaml rename to tests/Application/config/sylius/1.11/packages/swiftmailer.yaml diff --git a/tests/Application/config/packages/test/swiftmailer.yaml b/tests/Application/config/sylius/1.11/packages/test/swiftmailer.yaml similarity index 100% rename from tests/Application/config/packages/test/swiftmailer.yaml rename to tests/Application/config/sylius/1.11/packages/test/swiftmailer.yaml diff --git a/tests/Application/config/packages/test_cached/swiftmailer.yaml b/tests/Application/config/sylius/1.11/packages/test_cached/swiftmailer.yaml similarity index 100% rename from tests/Application/config/packages/test_cached/swiftmailer.yaml rename to tests/Application/config/sylius/1.11/packages/test_cached/swiftmailer.yaml diff --git a/tests/Application/config/sylius/1.12/packages/mailer.yaml b/tests/Application/config/sylius/1.12/packages/mailer.yaml new file mode 100644 index 00000000..56a650d8 --- /dev/null +++ b/tests/Application/config/sylius/1.12/packages/mailer.yaml @@ -0,0 +1,3 @@ +framework: + mailer: + dsn: '%env(MAILER_DSN)%' diff --git a/tests/Application/config/sylius/1.12/packages/security.yaml b/tests/Application/config/sylius/1.12/packages/security.yaml new file mode 100644 index 00000000..1d3c1123 --- /dev/null +++ b/tests/Application/config/sylius/1.12/packages/security.yaml @@ -0,0 +1,130 @@ +parameters: + sylius.security.admin_regex: "^/%sylius_admin.path_name%" + 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: + enable_authenticator_manager: 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 + + password_hashers: + 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 + enable_csrf: true + 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 + + new_api_admin_user: + pattern: "%sylius.security.new_api_admin_regex%/.*" + provider: sylius_api_admin_user_provider + stateless: 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 + jwt: true + + new_api_shop_user: + pattern: "%sylius.security.new_api_shop_regex%/.*" + provider: sylius_shop_user_provider + stateless: 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 + jwt: 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 + enable_csrf: true + 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_homepage + invalidate_session: false + + dev: + pattern: ^/(_(profiler|wdt)|css|images|js)/ + security: false + + access_control: + - { 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: 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: PUBLIC_ACCESS } + - { path: "%sylius.security.shop_regex%/login", role: PUBLIC_ACCESS } + + - { 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: PUBLIC_ACCESS } + - { path: "%sylius.security.new_api_user_account_regex%/.*", role: ROLE_USER } + - { path: "%sylius.security.new_api_shop_route%/authentication-token", role: PUBLIC_ACCESS } + - { path: "%sylius.security.new_api_shop_regex%/.*", role: PUBLIC_ACCESS } diff --git a/tests/Application/config/sylius/1.12/packages/test/mailer.yaml b/tests/Application/config/sylius/1.12/packages/test/mailer.yaml new file mode 100644 index 00000000..52610d69 --- /dev/null +++ b/tests/Application/config/sylius/1.12/packages/test/mailer.yaml @@ -0,0 +1,5 @@ +framework: + cache: + pools: + test.mailer_pool: + adapter: cache.adapter.filesystem diff --git a/tests/Application/config/sylius/1.12/packages/test_cached/mailer.yaml b/tests/Application/config/sylius/1.12/packages/test_cached/mailer.yaml new file mode 100644 index 00000000..16f3170a --- /dev/null +++ b/tests/Application/config/sylius/1.12/packages/test_cached/mailer.yaml @@ -0,0 +1,2 @@ +imports: + - { resource: "../test/mailer.yaml" } diff --git a/tests/Application/public/index.php b/tests/Application/public/index.php index 2a5031f3..de77e4c7 100644 --- a/tests/Application/public/index.php +++ b/tests/Application/public/index.php @@ -1,8 +1,8 @@ - + + + + + diff --git a/tests/Behat/Resources/services/mailer.php b/tests/Behat/Resources/services/mailer.php new file mode 100644 index 00000000..649a7f31 --- /dev/null +++ b/tests/Behat/Resources/services/mailer.php @@ -0,0 +1,18 @@ + 11) { + return; + } + + $configurator->services() + ->alias('sylius.behat.context.hook.mailer', 'sylius.behat.context.hook.email_spool') + ->public() + ; +}; diff --git a/tests/Behat/Resources/suites.yml b/tests/Behat/Resources/suites.yml index e8741ff1..db8795b4 100644 --- a/tests/Behat/Resources/suites.yml +++ b/tests/Behat/Resources/suites.yml @@ -6,7 +6,7 @@ default: ui_checkout: contexts: - sylius.behat.context.hook.doctrine_orm - - sylius.behat.context.hook.email_spool + - sylius.behat.context.hook.mailer - sylius.behat.context.transform.address - sylius.behat.context.transform.country @@ -104,7 +104,7 @@ default: contexts: - Sylius\Calendar\Tests\Behat\Context\Hook\CalendarContext - sylius.behat.context.hook.doctrine_orm - - sylius.behat.context.hook.email_spool + - sylius.behat.context.hook.mailer - sylius.behat.context.setup.admin_security - sylius.behat.context.setup.admin_user From 902015f9101d82c07e1f7d7b613bb6e59f550ca2 Mon Sep 17 00:00:00 2001 From: Jan Goralski Date: Tue, 18 Oct 2022 13:36:13 +0200 Subject: [PATCH 4/7] [Maintenance] Use request stack for flash setting --- src/Controller/CancelPayPalOrderAction.php | 10 +++--- src/Controller/CancelPayPalPaymentAction.php | 12 ++++--- src/Controller/PayPalPaymentOnErrorAction.php | 12 ++++--- src/Listener/PayPalPaymentMethodListener.php | 12 ++++--- src/Provider/FlashBagProvider.php | 32 +++++++++++++++++++ src/Resources/config/services.xml | 2 +- src/Resources/config/services/controller.xml | 6 ++-- 7 files changed, 66 insertions(+), 20 deletions(-) create mode 100644 src/Provider/FlashBagProvider.php diff --git a/src/Controller/CancelPayPalOrderAction.php b/src/Controller/CancelPayPalOrderAction.php index 8c6527ee..c76e0239 100644 --- a/src/Controller/CancelPayPalOrderAction.php +++ b/src/Controller/CancelPayPalOrderAction.php @@ -6,8 +6,10 @@ use Sylius\Component\Core\Model\OrderInterface; use Sylius\Component\Core\Repository\OrderRepositoryInterface; +use Sylius\PayPalPlugin\Provider\FlashBagProvider; use Sylius\PayPalPlugin\Provider\PaymentProviderInterface; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Session\Flash\FlashBag; @@ -17,16 +19,16 @@ final class CancelPayPalOrderAction private OrderRepositoryInterface $orderRepository; - private FlashBag $flashBag; + private FlashBag|RequestStack $flashBagOrRequestStack; public function __construct( PaymentProviderInterface $paymentProvider, OrderRepositoryInterface $orderRepository, - FlashBag $flashBag + FlashBag|RequestStack $flashBagOrRequestStack ) { $this->paymentProvider = $paymentProvider; $this->orderRepository = $orderRepository; - $this->flashBag = $flashBag; + $this->flashBagOrRequestStack = $flashBagOrRequestStack; } public function __invoke(Request $request): Response @@ -39,7 +41,7 @@ public function __invoke(Request $request): Response $order = $payment->getOrder(); $this->orderRepository->remove($order); - $this->flashBag->add('success', 'sylius.pay_pal.order_cancelled'); + FlashBagProvider::getFlashBag($this->flashBagOrRequestStack)->add('success', 'sylius.pay_pal.order_cancelled'); return new Response('', Response::HTTP_NO_CONTENT); } diff --git a/src/Controller/CancelPayPalPaymentAction.php b/src/Controller/CancelPayPalPaymentAction.php index b8e7c06d..005d3414 100644 --- a/src/Controller/CancelPayPalPaymentAction.php +++ b/src/Controller/CancelPayPalPaymentAction.php @@ -9,8 +9,10 @@ use Sylius\Component\Core\Model\OrderInterface; use Sylius\Component\Order\Processor\OrderProcessorInterface; use Sylius\Component\Payment\PaymentTransitions; +use Sylius\PayPalPlugin\Provider\FlashBagProvider; use Sylius\PayPalPlugin\Provider\PaymentProviderInterface; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Session\Flash\FlashBag; @@ -20,7 +22,7 @@ final class CancelPayPalPaymentAction private ObjectManager $objectManager; - private FlashBag $flashBag; + private FlashBag|RequestStack $flashBagOrRequestStack; private FactoryInterface $stateMachineFactory; @@ -29,13 +31,13 @@ final class CancelPayPalPaymentAction public function __construct( PaymentProviderInterface $paymentProvider, ObjectManager $objectManager, - FlashBag $flashBag, + FlashBag|RequestStack $flashBagOrRequestStack, FactoryInterface $stateMachineFactory, OrderProcessorInterface $orderPaymentProcessor ) { $this->paymentProvider = $paymentProvider; $this->objectManager = $objectManager; - $this->flashBag = $flashBag; + $this->flashBagOrRequestStack = $flashBagOrRequestStack; $this->stateMachineFactory = $stateMachineFactory; $this->orderPaymentProcessor = $orderPaymentProcessor; } @@ -55,7 +57,9 @@ public function __invoke(Request $request): Response $this->orderPaymentProcessor->process($order); $this->objectManager->flush(); - $this->flashBag->add('success', 'sylius.pay_pal.payment_cancelled'); + FlashBagProvider::getFlashBag($this->flashBagOrRequestStack) + ->add('success', 'sylius.pay_pal.payment_cancelled') + ; return new Response('', Response::HTTP_NO_CONTENT); } diff --git a/src/Controller/PayPalPaymentOnErrorAction.php b/src/Controller/PayPalPaymentOnErrorAction.php index a5c70232..d4198597 100644 --- a/src/Controller/PayPalPaymentOnErrorAction.php +++ b/src/Controller/PayPalPaymentOnErrorAction.php @@ -5,26 +5,30 @@ namespace Sylius\PayPalPlugin\Controller; use Psr\Log\LoggerInterface; +use Sylius\PayPalPlugin\Provider\FlashBagProvider; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface; final class PayPalPaymentOnErrorAction { - private FlashBagInterface $flashBag; + private FlashBagInterface|RequestStack $flashBagOrRequestStack; private LoggerInterface $logger; - public function __construct(FlashBagInterface $flashBag, LoggerInterface $logger) + public function __construct(FlashBagInterface|RequestStack $flashBagOrRequestStack, LoggerInterface $logger) { - $this->flashBag = $flashBag; + $this->flashBagOrRequestStack = $flashBagOrRequestStack; $this->logger = $logger; } public function __invoke(Request $request): Response { $this->logger->error((string) $request->getContent()); - $this->flashBag->add('error', 'sylius.pay_pal.something_went_wrong'); + FlashBagProvider::getFlashBag($this->flashBagOrRequestStack) + ->add('error', 'sylius.pay_pal.something_went_wrong') + ; return new Response(); } diff --git a/src/Listener/PayPalPaymentMethodListener.php b/src/Listener/PayPalPaymentMethodListener.php index 3023508a..592d4128 100644 --- a/src/Listener/PayPalPaymentMethodListener.php +++ b/src/Listener/PayPalPaymentMethodListener.php @@ -9,8 +9,10 @@ use Sylius\Component\Core\Model\PaymentMethodInterface; use Sylius\PayPalPlugin\Exception\PayPalPaymentMethodNotFoundException; use Sylius\PayPalPlugin\Onboarding\Initiator\OnboardingInitiatorInterface; +use Sylius\PayPalPlugin\Provider\FlashBagProvider; use Sylius\PayPalPlugin\Provider\PayPalPaymentMethodProviderInterface; use Symfony\Component\HttpFoundation\RedirectResponse; +use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; use Webmozart\Assert\Assert; @@ -21,19 +23,19 @@ final class PayPalPaymentMethodListener private UrlGeneratorInterface $urlGenerator; - private FlashBagInterface $flashBag; + private FlashBagInterface|RequestStack $flashBagOrRequestStack; private PayPalPaymentMethodProviderInterface $payPalPaymentMethodProvider; public function __construct( OnboardingInitiatorInterface $onboardingInitiator, UrlGeneratorInterface $urlGenerator, - FlashBagInterface $flashBag, + FlashBagInterface|RequestStack $flashBagOrRequestStack, PayPalPaymentMethodProviderInterface $payPalPaymentMethodProvider ) { $this->onboardingInitiator = $onboardingInitiator; $this->urlGenerator = $urlGenerator; - $this->flashBag = $flashBag; + $this->flashBagOrRequestStack = $flashBagOrRequestStack; $this->payPalPaymentMethodProvider = $payPalPaymentMethodProvider; } @@ -49,7 +51,9 @@ public function initializeCreate(ResourceControllerEvent $event): void } if ($this->isTherePayPalPaymentMethod()) { - $this->flashBag->add('error', 'sylius.pay_pal.more_than_one_seller_not_allowed'); + FlashBagProvider::getFlashBag($this->flashBagOrRequestStack) + ->add('error', 'sylius.pay_pal.more_than_one_seller_not_allowed') + ; $event->setResponse(new RedirectResponse($this->urlGenerator->generate('sylius_admin_payment_method_index'))); diff --git a/src/Provider/FlashBagProvider.php b/src/Provider/FlashBagProvider.php new file mode 100644 index 00000000..271dc4c8 --- /dev/null +++ b/src/Provider/FlashBagProvider.php @@ -0,0 +1,32 @@ +getSession()->getBag('flashes'); + + return $flashBag; + } +} diff --git a/src/Resources/config/services.xml b/src/Resources/config/services.xml index d191f9ea..94ac7197 100644 --- a/src/Resources/config/services.xml +++ b/src/Resources/config/services.xml @@ -35,7 +35,7 @@ - + diff --git a/src/Resources/config/services/controller.xml b/src/Resources/config/services/controller.xml index 9922677d..29cf3473 100644 --- a/src/Resources/config/services/controller.xml +++ b/src/Resources/config/services/controller.xml @@ -14,13 +14,13 @@ - + - + @@ -132,7 +132,7 @@ - + From 32ef0ab173e4aa70c90ac89947b1253253f907df Mon Sep 17 00:00:00 2001 From: Jan Goralski Date: Tue, 18 Oct 2022 13:36:26 +0200 Subject: [PATCH 5/7] [Maintenance] Allow usage with sylius 1.12 and symfony 6 --- .github/workflows/build.yml | 10 ++++++--- composer.json | 22 ++++++++++--------- phpstan.neon | 7 +++++- phpunit.xml.dist | 2 +- ...PalPaymentMethodNewResourceFactorySpec.php | 10 +++------ src/Resources/config/shop_routing.yaml | 6 ++--- src/Resources/views/Buttons/cart.html.twig | 2 +- src/Resources/views/Buttons/payment.html.twig | 2 +- .../views/Buttons/productDetails.html.twig | 2 +- tests/Application/config/bootstrap.php | 4 ++++ .../config/packages/security_checker.yaml | 9 -------- .../config/packages/test/framework.yaml | 2 +- .../packages/test_cached/framework.yaml | 6 ++--- tests/Behat/Resources/suites.yml | 6 ++--- 14 files changed, 45 insertions(+), 45 deletions(-) delete mode 100644 tests/Application/config/packages/security_checker.yaml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 44f1e9e7..e309c31e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -22,8 +22,12 @@ jobs: php: ["8.0", "8.1"] node: ["16.x"] mysql: ["5.7", "8.0"] - symfony: ["^5.4"] - sylius: ["1.11.*", "~1.12.x-dev"] + symfony: ["^5.4", "^6.0"] + sylius: ["~1.11.0", "~1.12.x-dev"] + exclude: + - + symfony: "^6.0" + sylius: "~1.11.0" env: APP_ENV: test DATABASE_URL: "mysql://root:root@127.0.0.1/sylius?serverVersion=${{ matrix.mysql }}" @@ -96,7 +100,7 @@ jobs: - name: Install PHP dependencies - run: composer update --no-interaction + run: composer install --no-interaction - name: Get Yarn cache directory diff --git a/composer.json b/composer.json index f02ca9ab..df0a9933 100644 --- a/composer.json +++ b/composer.json @@ -11,7 +11,7 @@ "polishsymfonycommunity/symfony-mocker-container": "^1.0", "sylius-labs/doctrine-migrations-extra-bundle": "^0.1.4 || ^0.2", "sylius/sylius": "~1.11.0 || 1.12.x-dev", - "symfony/mailer": "^5.4" + "symfony/mailer": "^5.4 || ^6.0" }, "require-dev": { "behat/behat": "^3.6.1", @@ -31,13 +31,12 @@ "phpstan/phpstan-doctrine": "0.12.33", "phpstan/phpstan-webmozart-assert": "0.12.12", "phpunit/phpunit": "^8.5", - "sensiolabs/security-checker": "^6.0", "sylius-labs/coding-standard": "^4.0", - "symfony/browser-kit": "^5.4", - "symfony/debug-bundle": "^5.4", - "symfony/dotenv": "^5.4", - "symfony/intl": "^5.4", - "symfony/web-profiler-bundle": "^5.4", + "symfony/browser-kit": "^5.4 || ^6.0", + "symfony/debug-bundle": "^5.4 || ^6.0", + "symfony/dotenv": "^5.4 || ^6.0", + "symfony/intl": "^5.4 || ^6.0", + "symfony/web-profiler-bundle": "^5.4 || ^6.0", "vimeo/psalm": "4.27.0", "rector/rector": "^0.11.53", "lchrusciel/api-test-case": "^5.1", @@ -61,8 +60,9 @@ "sort-packages": true, "allow-plugins": { "dealerdirect/phpcodesniffer-composer-installer": false, - "ocramius/package-versions": false, - "symfony/flex": true + "ocramius/package-versions": false, + "symfony/flex": true, + "symfony/thanks": false } }, "extra": { @@ -79,5 +79,7 @@ "fix": [ "vendor/bin/ecs check src/ spec/ --fix" ] - } + }, + "prefer-stable": true, + "minimum-stability": "dev" } diff --git a/phpstan.neon b/phpstan.neon index 71b3ff4c..4492da04 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -7,9 +7,14 @@ parameters: checkMissingIterableValueType: false checkGenericClassInNonGenericObjectType: false - excludes_analyse: + paths: + - 'src/' + + excludePaths: # Makes PHPStan crash - 'src/DependencyInjection/Configuration.php' + - 'src/DependencyInjection/SyliusPayPalExtension.php' + - 'src/Command/CompletePaidPaymentsCommand.php' # Test dependencies - 'tests/Application/app/**.php' diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 2eec8a0e..953d6fba 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -15,7 +15,7 @@ - + diff --git a/spec/Factory/PayPalPaymentMethodNewResourceFactorySpec.php b/spec/Factory/PayPalPaymentMethodNewResourceFactorySpec.php index 74f0acec..81aa4c8d 100644 --- a/spec/Factory/PayPalPaymentMethodNewResourceFactorySpec.php +++ b/spec/Factory/PayPalPaymentMethodNewResourceFactorySpec.php @@ -12,16 +12,14 @@ use Sylius\Component\Resource\Model\ResourceInterface; use Sylius\PayPalPlugin\Onboarding\Processor\OnboardingProcessorInterface; use Symfony\Component\HttpFoundation\Request; -use Symfony\Contracts\HttpClient\HttpClientInterface; final class PayPalPaymentMethodNewResourceFactorySpec extends ObjectBehavior { function let( NewResourceFactoryInterface $newResourceFactory, OnboardingProcessorInterface $onboardingProcessor, - HttpClientInterface $httpClient ): void { - $this->beConstructedWith($newResourceFactory, $onboardingProcessor, $httpClient, 'test-url'); + $this->beConstructedWith($newResourceFactory, $onboardingProcessor); } function it_is_a_new_resource_factory(): void @@ -37,7 +35,6 @@ function it_processes_onboarding_if_payment_method_and_request_are_supported( FactoryInterface $factory, PaymentMethodInterface $paymentMethod, PaymentMethodInterface $processedPaymentMethod, - HttpClientInterface $httpClient ): void { $newResourceFactory->create($requestConfiguration, $factory)->willReturn($paymentMethod); @@ -56,7 +53,6 @@ function it_does_nothing_if_payment_method_and_request_are_unsupported( Request $request, FactoryInterface $factory, PaymentMethodInterface $paymentMethod, - HttpClientInterface $httpClient ): void { $newResourceFactory->create($requestConfiguration, $factory)->willReturn($paymentMethod); @@ -66,14 +62,14 @@ function it_does_nothing_if_payment_method_and_request_are_unsupported( $this->create($requestConfiguration, $factory)->shouldReturn($paymentMethod); - $onboardingProcessor->process($paymentMethod, $request, $httpClient, 'test-url')->shouldNotHaveBeenCalled(); + $onboardingProcessor->process($paymentMethod, $request)->shouldNotHaveBeenCalled(); } function it_does_nothing_if_created_resource_is_not_a_payment_method( NewResourceFactoryInterface $newResourceFactory, RequestConfiguration $requestConfiguration, FactoryInterface $factory, - ResourceInterface $resource + ResourceInterface $resource, ): void { $newResourceFactory->create($requestConfiguration, $factory)->willReturn($resource); diff --git a/src/Resources/config/shop_routing.yaml b/src/Resources/config/shop_routing.yaml index 678d9654..acd87ad7 100644 --- a/src/Resources/config/shop_routing.yaml +++ b/src/Resources/config/shop_routing.yaml @@ -56,7 +56,7 @@ sylius_paypal_plugin_create_paypal_order_from_product: path: /create-pay-pal-order-from-product/{productId} methods: [POST] defaults: - _controller: sylius.controller.order_item:createFromProductDetailsAction + _controller: sylius.controller.order_item::createFromProductDetailsAction _sylius: factory: method: createForProduct @@ -70,7 +70,7 @@ sylius_shop_checkout_select_payment: path: /checkout/select-payment methods: [GET, PUT] defaults: - _controller: sylius.controller.order:updateAction + _controller: sylius.controller.order::updateAction _sylius: event: payment flash: false @@ -88,7 +88,7 @@ sylius_shop_order_show: path: /order/{tokenValue} methods: [GET, PUT] defaults: - _controller: sylius.controller.order:updateAction + _controller: sylius.controller.order::updateAction _sylius: template: "@SyliusShop/Order/show.html.twig" repository: diff --git a/src/Resources/views/Buttons/cart.html.twig b/src/Resources/views/Buttons/cart.html.twig index f7e1e1df..f6086172 100644 --- a/src/Resources/views/Buttons/cart.html.twig +++ b/src/Resources/views/Buttons/cart.html.twig @@ -1 +1 @@ -{{ render(controller('Sylius\\PayPalPlugin\\Controller\\PayPalButtonsController:renderCartPageButtonsAction', {'orderId': cart.id})) }} +{{ render(controller('Sylius\\PayPalPlugin\\Controller\\PayPalButtonsController::renderCartPageButtonsAction', {'orderId': cart.id})) }} diff --git a/src/Resources/views/Buttons/payment.html.twig b/src/Resources/views/Buttons/payment.html.twig index c115a20e..961ea4ce 100644 --- a/src/Resources/views/Buttons/payment.html.twig +++ b/src/Resources/views/Buttons/payment.html.twig @@ -1 +1 @@ -{{ render(controller('Sylius\\PayPalPlugin\\Controller\\PayPalButtonsController:renderPaymentPageButtonsAction', {'orderId': cart.id})) }} +{{ render(controller('Sylius\\PayPalPlugin\\Controller\\PayPalButtonsController::renderPaymentPageButtonsAction', {'orderId': cart.id})) }} diff --git a/src/Resources/views/Buttons/productDetails.html.twig b/src/Resources/views/Buttons/productDetails.html.twig index 52515c7e..3b2f3ba8 100644 --- a/src/Resources/views/Buttons/productDetails.html.twig +++ b/src/Resources/views/Buttons/productDetails.html.twig @@ -1 +1 @@ -{{ render(controller('Sylius\\PayPalPlugin\\Controller\\PayPalButtonsController:renderProductPageButtonsAction', {'productId': product.id})) }} +{{ render(controller('Sylius\\PayPalPlugin\\Controller\\PayPalButtonsController::renderProductPageButtonsAction', {'productId': product.id})) }} diff --git a/tests/Application/config/bootstrap.php b/tests/Application/config/bootstrap.php index 8ea2af23..3d89c860 100644 --- a/tests/Application/config/bootstrap.php +++ b/tests/Application/config/bootstrap.php @@ -11,6 +11,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'); diff --git a/tests/Application/config/packages/security_checker.yaml b/tests/Application/config/packages/security_checker.yaml deleted file mode 100644 index 0f9cf00f..00000000 --- a/tests/Application/config/packages/security_checker.yaml +++ /dev/null @@ -1,9 +0,0 @@ -services: - SensioLabs\Security\SecurityChecker: - public: false - - SensioLabs\Security\Command\SecurityCheckerCommand: - arguments: ['@SensioLabs\Security\SecurityChecker'] - public: false - tags: - - { name: console.command, command: 'security:check' } diff --git a/tests/Application/config/packages/test/framework.yaml b/tests/Application/config/packages/test/framework.yaml index 76d7e5e1..fc1d3c13 100644 --- a/tests/Application/config/packages/test/framework.yaml +++ b/tests/Application/config/packages/test/framework.yaml @@ -1,4 +1,4 @@ framework: test: ~ session: - storage_id: session.storage.mock_file + storage_factory_id: session.storage.factory.mock_file diff --git a/tests/Application/config/packages/test_cached/framework.yaml b/tests/Application/config/packages/test_cached/framework.yaml index 76d7e5e1..e9dd6eea 100644 --- a/tests/Application/config/packages/test_cached/framework.yaml +++ b/tests/Application/config/packages/test_cached/framework.yaml @@ -1,4 +1,2 @@ -framework: - test: ~ - session: - storage_id: session.storage.mock_file +imports: + - { resource: ../test/framework.yaml } diff --git a/tests/Behat/Resources/suites.yml b/tests/Behat/Resources/suites.yml index db8795b4..d995f373 100644 --- a/tests/Behat/Resources/suites.yml +++ b/tests/Behat/Resources/suites.yml @@ -63,7 +63,7 @@ default: - sylius.behat.context.ui.shop.locale filters: - tags: "@checkout && @ui" + tags: "@checkout&&@ui" ui_managing_payment_methods: contexts: - sylius.behat.context.hook.doctrine_orm @@ -99,7 +99,7 @@ default: - Tests\Sylius\PayPalPlugin\Behat\Context\Admin\ManagingPaymentMethodsContext filters: - tags: "@managing_payment_methods && @ui" + tags: "@managing_payment_methods&&@ui" ui_managing_orders: contexts: - Sylius\Calendar\Tests\Behat\Context\Hook\CalendarContext @@ -160,4 +160,4 @@ default: - Tests\Sylius\PayPalPlugin\Behat\Context\Admin\ManagingOrdersContext filters: - tags: "@managing_orders && @ui" + tags: "@managing_orders&&@ui" From d045553541fe9b15dc23e4539d54ab886fe4c88c Mon Sep 17 00:00:00 2001 From: Jan Goralski Date: Wed, 19 Oct 2022 17:58:21 +0200 Subject: [PATCH 6/7] [Maintenance] Use only the new security config file --- .../{sylius/1.12 => }/packages/security.yaml | 0 .../config/sylius/1.11/packages/security.yaml | 148 ------------------ 2 files changed, 148 deletions(-) rename tests/Application/config/{sylius/1.12 => }/packages/security.yaml (100%) delete mode 100644 tests/Application/config/sylius/1.11/packages/security.yaml diff --git a/tests/Application/config/sylius/1.12/packages/security.yaml b/tests/Application/config/packages/security.yaml similarity index 100% rename from tests/Application/config/sylius/1.12/packages/security.yaml rename to tests/Application/config/packages/security.yaml diff --git a/tests/Application/config/sylius/1.11/packages/security.yaml b/tests/Application/config/sylius/1.11/packages/security.yaml deleted file mode 100644 index 61e1a2dc..00000000 --- a/tests/Application/config/sylius/1.11/packages/security.yaml +++ /dev/null @@ -1,148 +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 - - 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 } From e28781562883531440570253f646b625c7311408 Mon Sep 17 00:00:00 2001 From: Jan Goralski Date: Thu, 20 Oct 2022 12:45:51 +0200 Subject: [PATCH 7/7] [Maintenance] Add deprecation notices for flash bags --- src/Controller/CancelPayPalOrderAction.php | 4 ++++ src/Controller/CancelPayPalPaymentAction.php | 4 ++++ src/Controller/PayPalPaymentOnErrorAction.php | 4 ++++ src/Listener/PayPalPaymentMethodListener.php | 4 ++++ 4 files changed, 16 insertions(+) diff --git a/src/Controller/CancelPayPalOrderAction.php b/src/Controller/CancelPayPalOrderAction.php index c76e0239..a2c1dcd1 100644 --- a/src/Controller/CancelPayPalOrderAction.php +++ b/src/Controller/CancelPayPalOrderAction.php @@ -26,6 +26,10 @@ public function __construct( OrderRepositoryInterface $orderRepository, FlashBag|RequestStack $flashBagOrRequestStack ) { + if ($flashBagOrRequestStack instanceof FlashBag) { + trigger_deprecation('sylius/paypal-plugin', '1.5', sprintf('Passing an instance of %s as constructor argument for %s is deprecated as of PayPalPlugin 1.5 and will be removed in 2.0. Pass an instance of %s instead.', FlashBag::class, self::class, RequestStack::class)); + } + $this->paymentProvider = $paymentProvider; $this->orderRepository = $orderRepository; $this->flashBagOrRequestStack = $flashBagOrRequestStack; diff --git a/src/Controller/CancelPayPalPaymentAction.php b/src/Controller/CancelPayPalPaymentAction.php index 005d3414..125f043b 100644 --- a/src/Controller/CancelPayPalPaymentAction.php +++ b/src/Controller/CancelPayPalPaymentAction.php @@ -35,6 +35,10 @@ public function __construct( FactoryInterface $stateMachineFactory, OrderProcessorInterface $orderPaymentProcessor ) { + if ($flashBagOrRequestStack instanceof FlashBag) { + trigger_deprecation('sylius/paypal-plugin', '1.5', sprintf('Passing an instance of %s as constructor argument for %s is deprecated as of PayPalPlugin 1.5 and will be removed in 2.0. Pass an instance of %s instead.', FlashBag::class, self::class, RequestStack::class)); + } + $this->paymentProvider = $paymentProvider; $this->objectManager = $objectManager; $this->flashBagOrRequestStack = $flashBagOrRequestStack; diff --git a/src/Controller/PayPalPaymentOnErrorAction.php b/src/Controller/PayPalPaymentOnErrorAction.php index d4198597..c3ddb52b 100644 --- a/src/Controller/PayPalPaymentOnErrorAction.php +++ b/src/Controller/PayPalPaymentOnErrorAction.php @@ -19,6 +19,10 @@ final class PayPalPaymentOnErrorAction public function __construct(FlashBagInterface|RequestStack $flashBagOrRequestStack, LoggerInterface $logger) { + if ($flashBagOrRequestStack instanceof FlashBagInterface) { + trigger_deprecation('sylius/paypal-plugin', '1.5', sprintf('Passing an instance of %s as constructor argument for %s is deprecated as of PayPalPlugin 1.5 and will be removed in 2.0. Pass an instance of %s instead.', FlashBagInterface::class, self::class, RequestStack::class)); + } + $this->flashBagOrRequestStack = $flashBagOrRequestStack; $this->logger = $logger; } diff --git a/src/Listener/PayPalPaymentMethodListener.php b/src/Listener/PayPalPaymentMethodListener.php index 592d4128..bb6cc99d 100644 --- a/src/Listener/PayPalPaymentMethodListener.php +++ b/src/Listener/PayPalPaymentMethodListener.php @@ -33,6 +33,10 @@ public function __construct( FlashBagInterface|RequestStack $flashBagOrRequestStack, PayPalPaymentMethodProviderInterface $payPalPaymentMethodProvider ) { + if ($flashBagOrRequestStack instanceof FlashBagInterface) { + trigger_deprecation('sylius/paypal-plugin', '1.5', sprintf('Passing an instance of %s as constructor argument for %s is deprecated as of PayPalPlugin 1.5 and will be removed in 2.0. Pass an instance of %s instead.', FlashBagInterface::class, self::class, RequestStack::class)); + } + $this->onboardingInitiator = $onboardingInitiator; $this->urlGenerator = $urlGenerator; $this->flashBagOrRequestStack = $flashBagOrRequestStack;