From 82552895ac0cb7d6ca876ed349453fec698e02ac Mon Sep 17 00:00:00 2001 From: Rafal Malenta Date: Fri, 24 Mar 2023 14:33:26 +0100 Subject: [PATCH 01/44] Upgraded to sylius 1.12 --- .github/workflows/build.yml | 17 +-- composer.json | 22 ++-- src/Bus/Dispatcher.php | 4 +- .../BitBagSyliusAdyenExtension.php | 2 +- .../Serializer/NotificationItemNormalizer.php | 10 +- src/Resources/assets/admin/entry.js | 2 + .../Resources/assets/admin/js/index.js | 0 src/Resources/assets/admin/scss/main.scss | 0 src/Resources/assets/shop/entry.js | 2 + src/Resources/assets/shop/js/index.js | 0 src/Resources/assets/shop/scss/main.scss | 0 tests/Application/Kernel.php | 19 ++- tests/Application/assets/admin/entry.js | 1 + tests/Application/assets/shop/entry.js | 1 + tests/Application/config/bootstrap.php | 2 +- tests/Application/config/bundles.php | 2 - .../config/packages/test/security.yaml | 2 +- .../config/packages/webpack_encore.yaml | 7 + .../config/sylius/1.10/packages/_sylius.yaml | 2 - .../config/sylius/1.11/bundles.php | 2 + .../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/bundles.php | 9 ++ .../sylius/1.12/packages/jms_serializer.yaml | 4 + .../config/sylius/1.12/packages/mailer.yaml | 4 + .../config/sylius/1.12/packages/security.yaml | 122 ++++++++++++++++++ .../sylius/1.12/packages/test/mailer.yaml | 7 + .../Layout/_scripts.html.twig | 2 + .../Layout/_styles.html.twig | 2 + .../SyliusShopBundle/_scripts.html.twig | 2 + .../SyliusShopBundle/_styles.html.twig | 2 + tests/Application/webpack.config.js | 41 +++--- webpack.config.js | 38 ++++++ 37 files changed, 270 insertions(+), 60 deletions(-) create mode 100644 src/Resources/assets/admin/entry.js rename tests/Application/public/media/image/.gitignore => src/Resources/assets/admin/js/index.js (100%) create mode 100644 src/Resources/assets/admin/scss/main.scss create mode 100644 src/Resources/assets/shop/entry.js create mode 100644 src/Resources/assets/shop/js/index.js create mode 100644 src/Resources/assets/shop/scss/main.scss create mode 100644 tests/Application/assets/admin/entry.js create mode 100644 tests/Application/assets/shop/entry.js create mode 100644 tests/Application/config/packages/webpack_encore.yaml delete mode 100644 tests/Application/config/sylius/1.10/packages/_sylius.yaml 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/bundles.php create mode 100644 tests/Application/config/sylius/1.12/packages/jms_serializer.yaml 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/templates/bundles/SyliusAdminBundle/Layout/_scripts.html.twig create mode 100644 tests/Application/templates/bundles/SyliusAdminBundle/Layout/_styles.html.twig create mode 100644 tests/Application/templates/bundles/SyliusShopBundle/_scripts.html.twig create mode 100644 tests/Application/templates/bundles/SyliusShopBundle/_styles.html.twig create mode 100644 webpack.config.js diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f562dc17..5d035c48 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -14,21 +14,22 @@ on: jobs: tests: - runs-on: ubuntu-18.04 + runs-on: ubuntu-22.04 name: "PHP ${{ matrix.php }}, MySQL ${{ matrix.mysql }}, Sylius ${{ matrix.sylius }}" strategy: fail-fast: false matrix: - php: [7.4, 8.0] - node: [14.18] - mysql: [5.7, 8.0] - sylius: ["~1.10.0", "~1.11.0"] + php: [ "8.0" ] + symfony: [ "^5.4", "^6.0" ] + sylius: [ "~1.11.0", "~1.12.0" ] + node: [ "^14.17.x" ] + mysql: [ "8.0" ] exclude: - - sylius: "~1.11.0" - php: 7.4 + - sylius: ~1.11.0 + symfony: "^6.0" env: APP_ENV: test @@ -131,7 +132,7 @@ jobs: name: Prepare test application assets run: | (cd tests/Application && bin/console assets:install public -vvv) - (cd tests/Application && yarn build) + (cd tests/Application && yarn encore build) - name: Prepare test application cache diff --git a/composer.json b/composer.json index e3cc976b..36bda224 100644 --- a/composer.json +++ b/composer.json @@ -9,16 +9,17 @@ ], "license": "MIT", "require": { - "php": "^7.4 || ^8.0", + "php": "^8.0", "adyen/php-api-library": "^11.0", "composer/package-versions-deprecated": "^1.11", "nyholm/psr7": "^1.4", "sylius-labs/doctrine-migrations-extra-bundle": "^0.1.4", "sylius/refund-plugin": "~1.0.0 || ^1.1", - "sylius/resource-bundle": "^1.8", - "sylius/sylius": "^1.10.0 || ^1.11.0", - "symfony/messenger": "^4.4 || ^5.0", - "symfony/serializer": "^4.4 || ^5.0" + + "sylius/sylius": "~1.11.0 || ~1.12.0", + "symfony/messenger": "^5.4 || ^6.0", + "symfony/serializer": "^5.4 || ^6.0", + "symfony/webpack-encore-bundle": "^1.14" }, "require-dev": { "behat/behat": "^3.6.1", @@ -44,12 +45,11 @@ "polishsymfonycommunity/symfony-mocker-container": "^1.0", "psalm/plugin-symfony": "^2.3", "sensiolabs/security-checker": "^6.0", - "symfony/browser-kit": "^4.4", - "symfony/debug-bundle": "^4.4 || ^5.0", - "symfony/dotenv": "^4.4 || ^5.0", - "symfony/intl": "^4.4 || ^5.0", - "symfony/web-profiler-bundle": "^4.4 || ^5.0", - "symfony/web-server-bundle": "^4.4 || ^5.0", + "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", "symplify/easy-coding-standard": "^9.3, !=9.3.27", "vimeo/psalm": "^4.4.1" }, diff --git a/src/Bus/Dispatcher.php b/src/Bus/Dispatcher.php index aac898e4..d91f3bb7 100644 --- a/src/Bus/Dispatcher.php +++ b/src/Bus/Dispatcher.php @@ -17,8 +17,8 @@ final class Dispatcher implements DispatcherInterface { use HandleTrait; - /** @var MessageBusInterface */ - private $messageBus; +// /** @var MessageBusInterface */ +// private $messageBus; /** @var PaymentCommandFactoryInterface */ private $commandFactory; diff --git a/src/DependencyInjection/BitBagSyliusAdyenExtension.php b/src/DependencyInjection/BitBagSyliusAdyenExtension.php index 99845811..d32f8953 100644 --- a/src/DependencyInjection/BitBagSyliusAdyenExtension.php +++ b/src/DependencyInjection/BitBagSyliusAdyenExtension.php @@ -60,7 +60,7 @@ public function getConfiguration(array $config, ContainerBuilder $container): Co return new Configuration(); } - public function getAlias() + public function getAlias(): string { return 'bitbag_sylius_adyen'; } diff --git a/src/Resolver/Notification/Serializer/NotificationItemNormalizer.php b/src/Resolver/Notification/Serializer/NotificationItemNormalizer.php index 40831e71..c4ed2e43 100644 --- a/src/Resolver/Notification/Serializer/NotificationItemNormalizer.php +++ b/src/Resolver/Notification/Serializer/NotificationItemNormalizer.php @@ -46,8 +46,8 @@ public function denormalize( } public function supportsDenormalization( - $data, - string $type, + mixed $data, + ?string $type, string $format = null ): bool { return @@ -94,10 +94,10 @@ public function normalize( * @param mixed $data */ public function supportsNormalization( - $data, - string $format = null, + mixed $data, + ?string $format = null, array $context = [] - ) { + ): bool { return $data instanceof NotificationItemData && !isset($context[$this->getNormalizationMarking($data)]) diff --git a/src/Resources/assets/admin/entry.js b/src/Resources/assets/admin/entry.js new file mode 100644 index 00000000..f3cf7505 --- /dev/null +++ b/src/Resources/assets/admin/entry.js @@ -0,0 +1,2 @@ +import './js'; +import './scss/main.scss'; diff --git a/tests/Application/public/media/image/.gitignore b/src/Resources/assets/admin/js/index.js similarity index 100% rename from tests/Application/public/media/image/.gitignore rename to src/Resources/assets/admin/js/index.js diff --git a/src/Resources/assets/admin/scss/main.scss b/src/Resources/assets/admin/scss/main.scss new file mode 100644 index 00000000..e69de29b diff --git a/src/Resources/assets/shop/entry.js b/src/Resources/assets/shop/entry.js new file mode 100644 index 00000000..f3cf7505 --- /dev/null +++ b/src/Resources/assets/shop/entry.js @@ -0,0 +1,2 @@ +import './js'; +import './scss/main.scss'; diff --git a/src/Resources/assets/shop/js/index.js b/src/Resources/assets/shop/js/index.js new file mode 100644 index 00000000..e69de29b diff --git a/src/Resources/assets/shop/scss/main.scss b/src/Resources/assets/shop/scss/main.scss new file mode 100644 index 00000000..e69de29b diff --git a/tests/Application/Kernel.php b/tests/Application/Kernel.php index b5fbd778..ae6d7f66 100644 --- a/tests/Application/Kernel.php +++ b/tests/Application/Kernel.php @@ -1,5 +1,11 @@ getConfigurationDirectories() as $confDir) { $this->loadRoutesConfiguration($routes, $confDir); @@ -67,7 +74,7 @@ protected function configureRoutes(RouteCollectionBuilder $routes): void protected function getContainerBaseClass(): string { - if ($this->isTestEnvironment()) { + if ($this->isTestEnvironment() && class_exists(MockerContainer::class)) { return MockerContainer::class; } @@ -87,11 +94,11 @@ private function loadContainerConfiguration(LoaderInterface $loader, string $con $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); } /** diff --git a/tests/Application/assets/admin/entry.js b/tests/Application/assets/admin/entry.js new file mode 100644 index 00000000..635f5acc --- /dev/null +++ b/tests/Application/assets/admin/entry.js @@ -0,0 +1 @@ +import 'sylius/bundle/AdminBundle/Resources/private/entry'; diff --git a/tests/Application/assets/shop/entry.js b/tests/Application/assets/shop/entry.js new file mode 100644 index 00000000..aadc3174 --- /dev/null +++ b/tests/Application/assets/shop/entry.js @@ -0,0 +1 @@ +import 'sylius/bundle/ShopBundle/Resources/private/entry'; diff --git a/tests/Application/config/bootstrap.php b/tests/Application/config/bootstrap.php index d7ac51d8..2291ab42 100644 --- a/tests/Application/config/bootstrap.php +++ b/tests/Application/config/bootstrap.php @@ -15,7 +15,7 @@ throw new RuntimeException('Please run "composer require symfony/dotenv" to load the ".env" files configuring the application.'); } else { // load all the .env files - (new Dotenv(true))->loadEnv(dirname(__DIR__) . '/.env'); + (new Dotenv())->loadEnv(dirname(__DIR__) . '/.env'); } $_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = ($_SERVER['APP_ENV'] ?? $_ENV['APP_ENV'] ?? null) ?: 'dev'; diff --git a/tests/Application/config/bundles.php b/tests/Application/config/bundles.php index 1a0a9051..cc816c51 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], @@ -45,7 +44,6 @@ Sylius\Bundle\FixturesBundle\SyliusFixturesBundle::class => ['all' => true], Sylius\Bundle\PayumBundle\SyliusPayumBundle::class => ['all' => true], Sylius\Bundle\ThemeBundle\SyliusThemeBundle::class => ['all' => true], - Symfony\Bundle\WebServerBundle\WebServerBundle::class => ['all' => true], Sylius\Bundle\AdminBundle\SyliusAdminBundle::class => ['all' => true], Sylius\Bundle\ShopBundle\SyliusShopBundle::class => ['all' => true], Symfony\Bundle\DebugBundle\DebugBundle::class => ['dev' => true, 'test' => true, 'test_cached' => true], diff --git a/tests/Application/config/packages/test/security.yaml b/tests/Application/config/packages/test/security.yaml index 21cc3772..8ccd5429 100644 --- a/tests/Application/config/packages/test/security.yaml +++ b/tests/Application/config/packages/test/security.yaml @@ -1,3 +1,3 @@ security: - encoders: + password_hashers: sha512: sha512 diff --git a/tests/Application/config/packages/webpack_encore.yaml b/tests/Application/config/packages/webpack_encore.yaml new file mode 100644 index 00000000..d03a2206 --- /dev/null +++ b/tests/Application/config/packages/webpack_encore.yaml @@ -0,0 +1,7 @@ +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' + cs_shop: '%kernel.project_dir%/public/build/bitbag/cs/shop' + cs_admin: '%kernel.project_dir%/public/build/bitbag/cs/admin' diff --git a/tests/Application/config/sylius/1.10/packages/_sylius.yaml b/tests/Application/config/sylius/1.10/packages/_sylius.yaml deleted file mode 100644 index cd01aaf7..00000000 --- a/tests/Application/config/sylius/1.10/packages/_sylius.yaml +++ /dev/null @@ -1,2 +0,0 @@ -sylius_api: - enabled: true diff --git a/tests/Application/config/sylius/1.11/bundles.php b/tests/Application/config/sylius/1.11/bundles.php index 90001976..9aa7a0dd 100644 --- a/tests/Application/config/sylius/1.11/bundles.php +++ b/tests/Application/config/sylius/1.11/bundles.php @@ -4,4 +4,6 @@ return [ Sylius\Calendar\SyliusCalendarBundle::class => ['all' => true], + Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle::class => ['all' => true], + Symfony\WebpackEncoreBundle\WebpackEncoreBundle::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/bundles.php b/tests/Application/config/sylius/1.12/bundles.php new file mode 100644 index 00000000..47c9bc04 --- /dev/null +++ b/tests/Application/config/sylius/1.12/bundles.php @@ -0,0 +1,9 @@ + ['all' => true], + Symfony\WebpackEncoreBundle\WebpackEncoreBundle::class => ['all' => true], + Sylius\Calendar\SyliusCalendarBundle::class => ['all' => true] +]; diff --git a/tests/Application/config/sylius/1.12/packages/jms_serializer.yaml b/tests/Application/config/sylius/1.12/packages/jms_serializer.yaml new file mode 100644 index 00000000..be011d90 --- /dev/null +++ b/tests/Application/config/sylius/1.12/packages/jms_serializer.yaml @@ -0,0 +1,4 @@ +#jms_serializer: +# visitors: +# xml_serialization: +# format_output: '%kernel.debug%' 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..225ed598 --- /dev/null +++ b/tests/Application/config/sylius/1.12/packages/mailer.yaml @@ -0,0 +1,4 @@ +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..71d89cd9 --- /dev/null +++ b/tests/Application/config/sylius/1.12/packages/security.yaml @@ -0,0 +1,122 @@ +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_api_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%/forgotten-password", role: PUBLIC_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..56cc28f9 --- /dev/null +++ b/tests/Application/config/sylius/1.12/packages/test/mailer.yaml @@ -0,0 +1,7 @@ +framework: + mailer: + dsn: 'null://null' + cache: + pools: + test.mailer_pool: + adapter: cache.adapter.filesystem diff --git a/tests/Application/templates/bundles/SyliusAdminBundle/Layout/_scripts.html.twig b/tests/Application/templates/bundles/SyliusAdminBundle/Layout/_scripts.html.twig new file mode 100644 index 00000000..d8212270 --- /dev/null +++ b/tests/Application/templates/bundles/SyliusAdminBundle/Layout/_scripts.html.twig @@ -0,0 +1,2 @@ +{{ encore_entry_script_tags('admin-entry', null, 'admin') }} +{{ encore_entry_script_tags('bitbag-cs-admin', null, 'cs_admin') }} diff --git a/tests/Application/templates/bundles/SyliusAdminBundle/Layout/_styles.html.twig b/tests/Application/templates/bundles/SyliusAdminBundle/Layout/_styles.html.twig new file mode 100644 index 00000000..798aadb2 --- /dev/null +++ b/tests/Application/templates/bundles/SyliusAdminBundle/Layout/_styles.html.twig @@ -0,0 +1,2 @@ +{{ encore_entry_link_tags('admin-entry', null, 'admin') }} +{{ encore_entry_link_tags('bitbag-cs-admin', null, 'cs_admin') }} diff --git a/tests/Application/templates/bundles/SyliusShopBundle/_scripts.html.twig b/tests/Application/templates/bundles/SyliusShopBundle/_scripts.html.twig new file mode 100644 index 00000000..1b22dbc7 --- /dev/null +++ b/tests/Application/templates/bundles/SyliusShopBundle/_scripts.html.twig @@ -0,0 +1,2 @@ +{{ encore_entry_script_tags('shop-entry', null, 'shop') }} +{{ encore_entry_script_tags('bitbag-cs-shop', null, 'cs_shop') }} diff --git a/tests/Application/templates/bundles/SyliusShopBundle/_styles.html.twig b/tests/Application/templates/bundles/SyliusShopBundle/_styles.html.twig new file mode 100644 index 00000000..87fab0e5 --- /dev/null +++ b/tests/Application/templates/bundles/SyliusShopBundle/_styles.html.twig @@ -0,0 +1,2 @@ +{{ encore_entry_link_tags('shop-entry', null, 'shop') }} +{{ encore_entry_link_tags('bitbag-cs-shop', null, 'cs_shop') }} diff --git a/tests/Application/webpack.config.js b/tests/Application/webpack.config.js index ba0308f7..a40477e8 100644 --- a/tests/Application/webpack.config.js +++ b/tests/Application/webpack.config.js @@ -1,20 +1,20 @@ const path = require('path'); const Encore = require('@symfony/webpack-encore'); +const [bitbagCsShop, bitbagCsAdmin] = require('../../webpack.config.js'); -const syliusBundles = path.resolve(__dirname, 'vendor/sylius/sylius/src/Sylius/Bundle/'); +const syliusBundles = path.resolve(__dirname, '../../vendor/sylius/sylius/src/Sylius/Bundle/'); const uiBundleScripts = path.resolve(syliusBundles, 'UiBundle/Resources/private/js/'); const uiBundleResources = path.resolve(syliusBundles, 'UiBundle/Resources/private/'); // Shop config -Encore - .setOutputPath('public/build/shop/') - .setPublicPath('/build/shop') - .addEntry('shop-entry', './assets/shop/entry.js') - .disableSingleRuntimeChunk() - .cleanupOutputBeforeBuild() - .enableSourceMaps(!Encore.isProduction()) - .enableVersioning(Encore.isProduction()) - .enableSassLoader(); +Encore.setOutputPath('public/build/shop/') + .setPublicPath('/build/shop') + .addEntry('shop-entry', './assets/shop/entry.js') + .disableSingleRuntimeChunk() + .cleanupOutputBeforeBuild() + .enableSourceMaps(!Encore.isProduction()) + .enableVersioning(Encore.isProduction()) + .enableSassLoader(); const shopConfig = Encore.getWebpackConfig(); @@ -26,22 +26,21 @@ shopConfig.name = 'shop'; Encore.reset(); // Admin config -Encore - .setOutputPath('public/build/admin/') - .setPublicPath('/build/admin') - .addEntry('admin-entry', './assets/admin/entry.js') - .disableSingleRuntimeChunk() - .cleanupOutputBeforeBuild() - .enableSourceMaps(!Encore.isProduction()) - .enableVersioning(Encore.isProduction()) - .enableSassLoader(); +Encore.setOutputPath('public/build/admin/') + .setPublicPath('/build/admin') + .addEntry('admin-entry', './assets/admin/entry.js') + .disableSingleRuntimeChunk() + .cleanupOutputBeforeBuild() + .enableSourceMaps(!Encore.isProduction()) + .enableVersioning(Encore.isProduction()) + .enableSassLoader(); const adminConfig = Encore.getWebpackConfig(); adminConfig.resolve.alias['sylius/ui'] = uiBundleScripts; adminConfig.resolve.alias['sylius/ui-resources'] = uiBundleResources; adminConfig.resolve.alias['sylius/bundle'] = syliusBundles; -adminConfig.externals = Object.assign({}, adminConfig.externals, { window: 'window', document: 'document' }); +adminConfig.externals = Object.assign({}, adminConfig.externals, {window: 'window', document: 'document'}); adminConfig.name = 'admin'; -module.exports = [shopConfig, adminConfig]; +module.exports = [shopConfig, adminConfig, bitbagCsShop, bitbagCsAdmin]; diff --git a/webpack.config.js b/webpack.config.js new file mode 100644 index 00000000..943ae658 --- /dev/null +++ b/webpack.config.js @@ -0,0 +1,38 @@ +const path = require('path'); +const Encore = require('@symfony/webpack-encore'); +const pluginName = 'cs'; + +const getConfig = (pluginName, type) => { + Encore.reset(); + + Encore.setOutputPath(`public/build/bitbag/${pluginName}/${type}/`) + .setPublicPath(`/build/bitbag/${pluginName}/${type}/`) + .addEntry(`bitbag-${pluginName}-${type}`, path.resolve(__dirname, `./src/Resources/assets/${type}/entry.js`)) + .disableSingleRuntimeChunk() + .cleanupOutputBeforeBuild() + .enableSourceMaps(!Encore.isProduction()) + .enableSassLoader(); + + const config = Encore.getWebpackConfig(); + config.name = `bitbag-${pluginName}-${type}`; + + return config; +}; + +Encore.setOutputPath(`src/Resources/public/build/`) + .setPublicPath(`/public/build/`) + .addEntry(`bitbag-${pluginName}-shop`, path.resolve(__dirname, `./src/Resources/assets/shop/entry.js`)) + .addEntry(`bitbag-${pluginName}-admin`, path.resolve(__dirname, `./src/Resources/assets/admin/entry.js`)) + .cleanupOutputBeforeBuild() + .disableSingleRuntimeChunk() + .enableSassLoader(); + +const distConfig = Encore.getWebpackConfig(); +distConfig.name = `bitbag-plugin-dist`; + +Encore.reset(); + +const shopConfig = getConfig(pluginName, 'shop'); +const adminConfig = getConfig(pluginName, 'admin'); + +module.exports = [shopConfig, adminConfig, distConfig]; From 8e8e476e1582b6e2b539d2b997465832a9003ae7 Mon Sep 17 00:00:00 2001 From: Rafal Malenta Date: Fri, 24 Mar 2023 14:37:13 +0100 Subject: [PATCH 02/44] Fixed encore --- .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 5d035c48..f15732de 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -132,7 +132,7 @@ jobs: name: Prepare test application assets run: | (cd tests/Application && bin/console assets:install public -vvv) - (cd tests/Application && yarn encore build) + (cd tests/Application && yarn encore dev) - name: Prepare test application cache From 05f9021ed3a7793b2e9328c7461463f8275743fe Mon Sep 17 00:00:00 2001 From: Rafal Malenta Date: Fri, 24 Mar 2023 14:41:13 +0100 Subject: [PATCH 03/44] Added resolve alias to webpack.config.js --- tests/Application/webpack.config.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/Application/webpack.config.js b/tests/Application/webpack.config.js index a40477e8..2ad84c38 100644 --- a/tests/Application/webpack.config.js +++ b/tests/Application/webpack.config.js @@ -40,7 +40,9 @@ const adminConfig = Encore.getWebpackConfig(); adminConfig.resolve.alias['sylius/ui'] = uiBundleScripts; adminConfig.resolve.alias['sylius/ui-resources'] = uiBundleResources; adminConfig.resolve.alias['sylius/bundle'] = syliusBundles; +adminConfig.resolve.alias['chart.js/dist/Chart.min'] = path.resolve(__dirname, 'node_modules/chart.js/dist/chart.min.js'); adminConfig.externals = Object.assign({}, adminConfig.externals, {window: 'window', document: 'document'}); + adminConfig.name = 'admin'; module.exports = [shopConfig, adminConfig, bitbagCsShop, bitbagCsAdmin]; From 5bbcaafb6d5c6c07eb9b8b7068f6392cc5e139f0 Mon Sep 17 00:00:00 2001 From: Rafal Malenta Date: Fri, 24 Mar 2023 14:47:58 +0100 Subject: [PATCH 04/44] Added symfony restriction --- .github/workflows/build.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f15732de..68b524b3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -95,6 +95,14 @@ jobs: restore-keys: | ${{ runner.os }}-php-${{ matrix.php }}-composer- + - + name: Restrict Symfony version + if: matrix.symfony != '' + run: | + composer global config --no-plugins allow-plugins.symfony/flex true + composer global require --no-progress --no-scripts --no-plugins "symfony/flex:^1.10" + composer config extra.symfony.require "${{ matrix.symfony }}" + - name: Restrcting Sylius version if: matrix.sylius != '' From 008df4b44a442d9e9c12f5eea717a79524eb032b Mon Sep 17 00:00:00 2001 From: Rafal Malenta Date: Fri, 24 Mar 2023 14:54:11 +0100 Subject: [PATCH 05/44] Updated chart.js --- composer.json | 4 ++-- tests/Application/package.json | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index 36bda224..9b89db80 100644 --- a/composer.json +++ b/composer.json @@ -37,8 +37,8 @@ "lakion/mink-debug-extension": "^2.0.0", "phpspec/phpspec": "^7.0", "phpstan/extension-installer": "^1.0", - "phpstan/phpstan": "0.12.74", - "phpstan/phpstan-doctrine": "0.12.31", + "phpstan/phpstan": "^0.12.92", + "phpstan/phpstan-doctrine": "^0.12.31", "phpstan/phpstan-strict-rules": "^0.12.0", "phpstan/phpstan-webmozart-assert": "0.12.12", "phpunit/phpunit": "^9.5", diff --git a/tests/Application/package.json b/tests/Application/package.json index ad211b25..9b0ab502 100644 --- a/tests/Application/package.json +++ b/tests/Application/package.json @@ -1,7 +1,8 @@ { "dependencies": { "babel-polyfill": "^6.26.0", - "chart.js": "^2.9.3", + "chart.js": "3.7.1", + "cha" "global": "^4.4.0", "jquery": "^3.4.0", "jquery.dirtyforms": "^2.0.0", From ab893e1e40c8968a165ad602ac9e195aba428c34 Mon Sep 17 00:00:00 2001 From: Rafal Malenta Date: Fri, 24 Mar 2023 15:00:56 +0100 Subject: [PATCH 06/44] Updated chart.js --- tests/Application/package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/Application/package.json b/tests/Application/package.json index 9b0ab502..c024f6bd 100644 --- a/tests/Application/package.json +++ b/tests/Application/package.json @@ -2,7 +2,6 @@ "dependencies": { "babel-polyfill": "^6.26.0", "chart.js": "3.7.1", - "cha" "global": "^4.4.0", "jquery": "^3.4.0", "jquery.dirtyforms": "^2.0.0", From 1ba6481207374b6aa6b3b1dbf89ba8b530accaf4 Mon Sep 17 00:00:00 2001 From: Rafal Malenta Date: Mon, 27 Mar 2023 06:58:16 +0200 Subject: [PATCH 07/44] Updated chart.js --- tests/Application/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Application/package.json b/tests/Application/package.json index c024f6bd..6fb6d047 100644 --- a/tests/Application/package.json +++ b/tests/Application/package.json @@ -1,7 +1,7 @@ { "dependencies": { "babel-polyfill": "^6.26.0", - "chart.js": "3.7.1", + "chart.js": "^3.7.1", "global": "^4.4.0", "jquery": "^3.4.0", "jquery.dirtyforms": "^2.0.0", From 1f0246919527068e190b80f238e86f443449aa34 Mon Sep 17 00:00:00 2001 From: Rafal Malenta Date: Mon, 27 Mar 2023 07:23:38 +0200 Subject: [PATCH 08/44] PHPstan fix --- composer.json | 2 -- phpstan.neon | 1 + .../PaymentResponseProcessor/AbstractProcessor.php | 8 +++----- src/Resolver/Order/PaymentCheckoutOrderResolver.php | 2 +- src/Validator/Constraint/AdyenCredentialsValidator.php | 2 +- tests/Application/config/routes/sylius_shop.yaml | 2 +- 6 files changed, 7 insertions(+), 10 deletions(-) diff --git a/composer.json b/composer.json index 9b89db80..3f08ef53 100644 --- a/composer.json +++ b/composer.json @@ -13,9 +13,7 @@ "adyen/php-api-library": "^11.0", "composer/package-versions-deprecated": "^1.11", "nyholm/psr7": "^1.4", - "sylius-labs/doctrine-migrations-extra-bundle": "^0.1.4", "sylius/refund-plugin": "~1.0.0 || ^1.1", - "sylius/sylius": "~1.11.0 || ~1.12.0", "symfony/messenger": "^5.4 || ^6.0", "symfony/serializer": "^5.4 || ^6.0", diff --git a/phpstan.neon b/phpstan.neon index 84af727b..a5556711 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,6 +1,7 @@ parameters: reportUnmatchedIgnoredErrors: false checkMissingIterableValueType: false + checkGenericClassInNonGenericObjectType: false excludes_analyse: # Makes PHPStan crash diff --git a/src/Processor/PaymentResponseProcessor/AbstractProcessor.php b/src/Processor/PaymentResponseProcessor/AbstractProcessor.php index 80c4ff96..723a4fae 100644 --- a/src/Processor/PaymentResponseProcessor/AbstractProcessor.php +++ b/src/Processor/PaymentResponseProcessor/AbstractProcessor.php @@ -12,7 +12,6 @@ use Sylius\Component\Core\Model\PaymentInterface; use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Session\Session; use Symfony\Contracts\Translation\TranslatorInterface; abstract class AbstractProcessor implements ProcessorInterface @@ -53,10 +52,9 @@ protected function addFlash( $message = $this->translator->trans($message); } - /** - * @var Session $session - */ + $session = $request->getSession(); - $session->getFlashBag()->add($type, $message); + $session->getBag('flashes')->add($type, $message); +// $session->getFlashBag()->add($type, $message); } } diff --git a/src/Resolver/Order/PaymentCheckoutOrderResolver.php b/src/Resolver/Order/PaymentCheckoutOrderResolver.php index 22f963e5..4639d228 100644 --- a/src/Resolver/Order/PaymentCheckoutOrderResolver.php +++ b/src/Resolver/Order/PaymentCheckoutOrderResolver.php @@ -66,7 +66,7 @@ private function getCurrentOrder(): ?OrderInterface return null; } /** - * @psalm-suppress MixedReturnStatement + * @phpstan-ignore-next-line */ return $this->orderRepository->findOneBy(['tokenValue' => $tokenValue]); } diff --git a/src/Validator/Constraint/AdyenCredentialsValidator.php b/src/Validator/Constraint/AdyenCredentialsValidator.php index dcd1ad5d..679fc9bc 100644 --- a/src/Validator/Constraint/AdyenCredentialsValidator.php +++ b/src/Validator/Constraint/AdyenCredentialsValidator.php @@ -86,7 +86,7 @@ public function isApiKeyValid( return true; } - public function validate($value, Constraint $constraint): void + public function validate(mixed $value, Constraint $constraint): void { Assert::isInstanceOf($constraint, AdyenCredentials::class); Assert::isArray($value); diff --git a/tests/Application/config/routes/sylius_shop.yaml b/tests/Application/config/routes/sylius_shop.yaml index 92eeae0c..fae46cbf 100644 --- a/tests/Application/config/routes/sylius_shop.yaml +++ b/tests/Application/config/routes/sylius_shop.yaml @@ -11,4 +11,4 @@ sylius_shop_default_locale: path: / methods: [GET] defaults: - _controller: sylius.controller.shop.locale_switch:switchAction + _controller: sylius.controller.shop.locale_switch::switchAction From e066f7f5ea388846831fc07b3240a2248cf95b35 Mon Sep 17 00:00:00 2001 From: Rafal Malenta Date: Mon, 27 Mar 2023 07:25:36 +0200 Subject: [PATCH 09/44] PHPstan fix --- composer.json | 1 - 1 file changed, 1 deletion(-) diff --git a/composer.json b/composer.json index 3f08ef53..3daa18af 100644 --- a/composer.json +++ b/composer.json @@ -41,7 +41,6 @@ "phpstan/phpstan-webmozart-assert": "0.12.12", "phpunit/phpunit": "^9.5", "polishsymfonycommunity/symfony-mocker-container": "^1.0", - "psalm/plugin-symfony": "^2.3", "sensiolabs/security-checker": "^6.0", "symfony/browser-kit": "^5.4 || 6.0", "symfony/debug-bundle": "^5.4 || ^6.0", From cbb953b37e34380ef292b20e0380b64c6ea70331 Mon Sep 17 00:00:00 2001 From: Rafal Malenta Date: Mon, 27 Mar 2023 07:32:28 +0200 Subject: [PATCH 10/44] updated phpstan --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 3daa18af..8cbadb06 100644 --- a/composer.json +++ b/composer.json @@ -35,8 +35,8 @@ "lakion/mink-debug-extension": "^2.0.0", "phpspec/phpspec": "^7.0", "phpstan/extension-installer": "^1.0", - "phpstan/phpstan": "^0.12.92", - "phpstan/phpstan-doctrine": "^0.12.31", + "phpstan/phpstan": "0.12.90", + "phpstan/phpstan-doctrine": "0.12.39", "phpstan/phpstan-strict-rules": "^0.12.0", "phpstan/phpstan-webmozart-assert": "0.12.12", "phpunit/phpunit": "^9.5", From 94762f2c6a35ee2e41a7866c1c2d330720aaffa7 Mon Sep 17 00:00:00 2001 From: Rafal Malenta Date: Mon, 27 Mar 2023 07:48:53 +0200 Subject: [PATCH 11/44] Fixed flash --- composer.json | 1 - phpstan.neon | 2 ++ src/Processor/PaymentResponseProcessor/AbstractProcessor.php | 5 +++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index 8cbadb06..a350f959 100644 --- a/composer.json +++ b/composer.json @@ -41,7 +41,6 @@ "phpstan/phpstan-webmozart-assert": "0.12.12", "phpunit/phpunit": "^9.5", "polishsymfonycommunity/symfony-mocker-container": "^1.0", - "sensiolabs/security-checker": "^6.0", "symfony/browser-kit": "^5.4 || 6.0", "symfony/debug-bundle": "^5.4 || ^6.0", "symfony/dotenv": "^5.4 || ^6.0", diff --git a/phpstan.neon b/phpstan.neon index a5556711..538f7673 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -11,6 +11,8 @@ parameters: # Test dependencies - 'tests/Application/app/**.php' - 'tests/Application/src/**.php' + - 'tests/Application/node_modules' + - 'vendor' ignoreErrors: - '/Parameter #1 \$configuration of method Symfony\\Component\\DependencyInjection\\Extension\\Extension::processConfiguration\(\) expects Symfony\\Component\\Config\\Definition\\ConfigurationInterface, Symfony\\Component\\Config\\Definition\\ConfigurationInterface\|null given\./' diff --git a/src/Processor/PaymentResponseProcessor/AbstractProcessor.php b/src/Processor/PaymentResponseProcessor/AbstractProcessor.php index 723a4fae..b10a28c7 100644 --- a/src/Processor/PaymentResponseProcessor/AbstractProcessor.php +++ b/src/Processor/PaymentResponseProcessor/AbstractProcessor.php @@ -12,6 +12,7 @@ use Sylius\Component\Core\Model\PaymentInterface; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\Session\SessionBagInterface; use Symfony\Contracts\Translation\TranslatorInterface; abstract class AbstractProcessor implements ProcessorInterface @@ -54,7 +55,7 @@ protected function addFlash( $session = $request->getSession(); - $session->getBag('flashes')->add($type, $message); -// $session->getFlashBag()->add($type, $message); + /** @var SessionBagInterface $bag */ + $session->getFlashBag()->add($type, $message); } } From 05effc50244ad529e9ba2488620ecd5aa5e9035a Mon Sep 17 00:00:00 2001 From: Rafal Malenta Date: Mon, 27 Mar 2023 08:04:52 +0200 Subject: [PATCH 12/44] Fixed session --- .../PreserveOrderTokenUponRedirectionCallback.php | 6 ++++-- src/Resources/config/services.xml | 2 +- tests/Application/config/packages/security_checker.yaml | 9 --------- tests/Application/config/packages/test/framework.yaml | 2 +- .../config/packages/test_cached/framework.yaml | 2 +- 5 files changed, 7 insertions(+), 14 deletions(-) delete mode 100644 tests/Application/config/packages/security_checker.yaml diff --git a/src/Callback/PreserveOrderTokenUponRedirectionCallback.php b/src/Callback/PreserveOrderTokenUponRedirectionCallback.php index c8f666a6..9ec72b47 100644 --- a/src/Callback/PreserveOrderTokenUponRedirectionCallback.php +++ b/src/Callback/PreserveOrderTokenUponRedirectionCallback.php @@ -11,6 +11,7 @@ namespace BitBag\SyliusAdyenPlugin\Callback; use Sylius\Component\Core\Model\OrderInterface; +use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\HttpFoundation\Session\SessionInterface; class PreserveOrderTokenUponRedirectionCallback @@ -20,9 +21,10 @@ class PreserveOrderTokenUponRedirectionCallback /** @var SessionInterface */ private $session; - public function __construct(SessionInterface $session) + public function __construct(RequestStack $session) { - $this->session = $session; + + $this->session = $session->getSession(); } public function __invoke(OrderInterface $order): void diff --git a/src/Resources/config/services.xml b/src/Resources/config/services.xml index 4b4cc32e..f9a8ea07 100644 --- a/src/Resources/config/services.xml +++ b/src/Resources/config/services.xml @@ -22,7 +22,7 @@ class="BitBag\SyliusAdyenPlugin\Callback\PreserveOrderTokenUponRedirectionCallback" id="bitbag.sylius_adyen_plugin.callback.preserve_order_token_upon_redirection_callback" > - + Date: Mon, 27 Mar 2023 08:26:10 +0200 Subject: [PATCH 13/44] Fixed request issue with cli context --- src/Callback/PreserveOrderTokenUponRedirectionCallback.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Callback/PreserveOrderTokenUponRedirectionCallback.php b/src/Callback/PreserveOrderTokenUponRedirectionCallback.php index 9ec72b47..32cd2c0c 100644 --- a/src/Callback/PreserveOrderTokenUponRedirectionCallback.php +++ b/src/Callback/PreserveOrderTokenUponRedirectionCallback.php @@ -23,12 +23,17 @@ class PreserveOrderTokenUponRedirectionCallback public function __construct(RequestStack $session) { - + if(null == $session->getMainRequest() ) { + return; + } $this->session = $session->getSession(); } public function __invoke(OrderInterface $order): void { + if(null === $this->session){ + return; + } $tokenValue = $order->getTokenValue(); if (null === $tokenValue) { From 5dc5122296843382b74cfc8e441b7264e5e1c5f1 Mon Sep 17 00:00:00 2001 From: Rafal Malenta Date: Mon, 27 Mar 2023 08:31:13 +0200 Subject: [PATCH 14/44] Removed comment --- src/Processor/PaymentResponseProcessor/AbstractProcessor.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Processor/PaymentResponseProcessor/AbstractProcessor.php b/src/Processor/PaymentResponseProcessor/AbstractProcessor.php index b10a28c7..e4ecae76 100644 --- a/src/Processor/PaymentResponseProcessor/AbstractProcessor.php +++ b/src/Processor/PaymentResponseProcessor/AbstractProcessor.php @@ -53,9 +53,7 @@ protected function addFlash( $message = $this->translator->trans($message); } - $session = $request->getSession(); - /** @var SessionBagInterface $bag */ $session->getFlashBag()->add($type, $message); } } From 30e3fd8ceac78264299aa8497a4bab354d0719f6 Mon Sep 17 00:00:00 2001 From: Rafal Malenta Date: Mon, 27 Mar 2023 08:37:05 +0200 Subject: [PATCH 15/44] Added PHPdoc --- src/Processor/PaymentResponseProcessor/AbstractProcessor.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Processor/PaymentResponseProcessor/AbstractProcessor.php b/src/Processor/PaymentResponseProcessor/AbstractProcessor.php index e4ecae76..f7e82715 100644 --- a/src/Processor/PaymentResponseProcessor/AbstractProcessor.php +++ b/src/Processor/PaymentResponseProcessor/AbstractProcessor.php @@ -12,6 +12,7 @@ use Sylius\Component\Core\Model\PaymentInterface; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\Session\FlashBagAwareSessionInterface; use Symfony\Component\HttpFoundation\Session\SessionBagInterface; use Symfony\Contracts\Translation\TranslatorInterface; @@ -52,7 +53,7 @@ protected function addFlash( if (null !== $this->translator) { $message = $this->translator->trans($message); } - + /** @var FlashBagAwareSessionInterface $session */ $session = $request->getSession(); $session->getFlashBag()->add($type, $message); } From bdac7cb146a3c7d77bdcd24bbbba5fd3c1316fd8 Mon Sep 17 00:00:00 2001 From: Rafal Malenta Date: Mon, 27 Mar 2023 08:46:02 +0200 Subject: [PATCH 16/44] Added PHPstan ignore --- src/Processor/PaymentResponseProcessor/AbstractProcessor.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Processor/PaymentResponseProcessor/AbstractProcessor.php b/src/Processor/PaymentResponseProcessor/AbstractProcessor.php index f7e82715..bcb281f1 100644 --- a/src/Processor/PaymentResponseProcessor/AbstractProcessor.php +++ b/src/Processor/PaymentResponseProcessor/AbstractProcessor.php @@ -53,8 +53,10 @@ protected function addFlash( if (null !== $this->translator) { $message = $this->translator->trans($message); } + /** @var FlashBagAwareSessionInterface $session */ $session = $request->getSession(); + /** @phpstan-ignore-next-line */ $session->getFlashBag()->add($type, $message); } } From 2bf89e1e2fd67dff07cd0009888a8f14ac040f0d Mon Sep 17 00:00:00 2001 From: Rafal Malenta Date: Mon, 27 Mar 2023 08:46:36 +0200 Subject: [PATCH 17/44] Removed unused use --- src/Processor/PaymentResponseProcessor/AbstractProcessor.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Processor/PaymentResponseProcessor/AbstractProcessor.php b/src/Processor/PaymentResponseProcessor/AbstractProcessor.php index bcb281f1..b0440c19 100644 --- a/src/Processor/PaymentResponseProcessor/AbstractProcessor.php +++ b/src/Processor/PaymentResponseProcessor/AbstractProcessor.php @@ -13,7 +13,6 @@ use Sylius\Component\Core\Model\PaymentInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Session\FlashBagAwareSessionInterface; -use Symfony\Component\HttpFoundation\Session\SessionBagInterface; use Symfony\Contracts\Translation\TranslatorInterface; abstract class AbstractProcessor implements ProcessorInterface From e13c60dd48ca45f2f9cc741d2e767459c661ca92 Mon Sep 17 00:00:00 2001 From: Rafal Malenta Date: Mon, 27 Mar 2023 08:50:34 +0200 Subject: [PATCH 18/44] Removed unused use --- src/Processor/PaymentResponseProcessor/AbstractProcessor.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Processor/PaymentResponseProcessor/AbstractProcessor.php b/src/Processor/PaymentResponseProcessor/AbstractProcessor.php index b0440c19..6fbe67ac 100644 --- a/src/Processor/PaymentResponseProcessor/AbstractProcessor.php +++ b/src/Processor/PaymentResponseProcessor/AbstractProcessor.php @@ -12,7 +12,6 @@ use Sylius\Component\Core\Model\PaymentInterface; use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Session\FlashBagAwareSessionInterface; use Symfony\Contracts\Translation\TranslatorInterface; abstract class AbstractProcessor implements ProcessorInterface @@ -53,7 +52,6 @@ protected function addFlash( $message = $this->translator->trans($message); } - /** @var FlashBagAwareSessionInterface $session */ $session = $request->getSession(); /** @phpstan-ignore-next-line */ $session->getFlashBag()->add($type, $message); From 27c0aa8729a9fd533c23798f53e6d34b2890113b Mon Sep 17 00:00:00 2001 From: Rafal Malenta Date: Mon, 27 Mar 2023 08:59:29 +0200 Subject: [PATCH 19/44] ECS --- ...eserveOrderTokenUponRedirectionCallback.php | 4 ++-- .../Serializer/NotificationItemNormalizer.php | 3 --- tests/Application/Kernel.php | 1 - .../Application/config/sylius/1.11/bundles.php | 2 +- .../Application/config/sylius/1.12/bundles.php | 2 +- .../ManagingPaymentMethodAdyenContext.php | 6 +++++- tests/HttpClientStub.php | 16 ++++++++++++---- .../Bus/Handler/AlterPaymentHandlerTest.php | 4 ++-- .../Handler/PaymentFinalizationHandlerTest.php | 1 - .../RefundPaymentGeneratedHandlerTest.php | 4 ++-- tests/Unit/Client/PaymentMethodsFilterTest.php | 6 +++++- .../AdditionalDetailsNormalizerTest.php | 6 +++++- .../Unit/Normalizer/AddressNormalizerTest.php | 6 +++++- .../OrderItemToLineItemNormalizerTest.php | 6 +++++- .../AbstractProcessorTest.php | 4 ++-- .../SuccessfulResponseProcessorTest.php | 6 +++++- .../Processor/PaymentResponseProcessorTest.php | 2 +- .../Address/StreetAddressResolverTest.php | 18 ++++++++++++++---- 18 files changed, 67 insertions(+), 30 deletions(-) diff --git a/src/Callback/PreserveOrderTokenUponRedirectionCallback.php b/src/Callback/PreserveOrderTokenUponRedirectionCallback.php index 32cd2c0c..d2bfcba4 100644 --- a/src/Callback/PreserveOrderTokenUponRedirectionCallback.php +++ b/src/Callback/PreserveOrderTokenUponRedirectionCallback.php @@ -23,7 +23,7 @@ class PreserveOrderTokenUponRedirectionCallback public function __construct(RequestStack $session) { - if(null == $session->getMainRequest() ) { + if (null == $session->getMainRequest()) { return; } $this->session = $session->getSession(); @@ -31,7 +31,7 @@ public function __construct(RequestStack $session) public function __invoke(OrderInterface $order): void { - if(null === $this->session){ + if (null === $this->session) { return; } $tokenValue = $order->getTokenValue(); diff --git a/src/Resolver/Notification/Serializer/NotificationItemNormalizer.php b/src/Resolver/Notification/Serializer/NotificationItemNormalizer.php index c4ed2e43..5920aa89 100644 --- a/src/Resolver/Notification/Serializer/NotificationItemNormalizer.php +++ b/src/Resolver/Notification/Serializer/NotificationItemNormalizer.php @@ -90,9 +90,6 @@ public function normalize( return $result; } - /** - * @param mixed $data - */ public function supportsNormalization( mixed $data, ?string $format = null, diff --git a/tests/Application/Kernel.php b/tests/Application/Kernel.php index ae6d7f66..10fe8258 100644 --- a/tests/Application/Kernel.php +++ b/tests/Application/Kernel.php @@ -19,7 +19,6 @@ use Symfony\Component\HttpKernel\Bundle\BundleInterface; use Symfony\Component\HttpKernel\Kernel as BaseKernel; use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator; -use Symfony\Component\Routing\RouteCollectionBuilder; final class Kernel extends BaseKernel { diff --git a/tests/Application/config/sylius/1.11/bundles.php b/tests/Application/config/sylius/1.11/bundles.php index 9aa7a0dd..67c432a4 100644 --- a/tests/Application/config/sylius/1.11/bundles.php +++ b/tests/Application/config/sylius/1.11/bundles.php @@ -5,5 +5,5 @@ return [ Sylius\Calendar\SyliusCalendarBundle::class => ['all' => true], Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle::class => ['all' => true], - Symfony\WebpackEncoreBundle\WebpackEncoreBundle::class => ['all' => true] + Symfony\WebpackEncoreBundle\WebpackEncoreBundle::class => ['all' => true], ]; diff --git a/tests/Application/config/sylius/1.12/bundles.php b/tests/Application/config/sylius/1.12/bundles.php index 47c9bc04..f2e02ad5 100644 --- a/tests/Application/config/sylius/1.12/bundles.php +++ b/tests/Application/config/sylius/1.12/bundles.php @@ -5,5 +5,5 @@ return [ League\FlysystemBundle\FlysystemBundle::class => ['all' => true], Symfony\WebpackEncoreBundle\WebpackEncoreBundle::class => ['all' => true], - Sylius\Calendar\SyliusCalendarBundle::class => ['all' => true] + Sylius\Calendar\SyliusCalendarBundle::class => ['all' => true], ]; diff --git a/tests/Behat/Context/Ui/Admin/ManagingPaymentMethodAdyenContext.php b/tests/Behat/Context/Ui/Admin/ManagingPaymentMethodAdyenContext.php index c1a76080..f4ebeddb 100644 --- a/tests/Behat/Context/Ui/Admin/ManagingPaymentMethodAdyenContext.php +++ b/tests/Behat/Context/Ui/Admin/ManagingPaymentMethodAdyenContext.php @@ -68,7 +68,11 @@ public function adyenServiceWillConfirmMerchantAccountAndApiKeyAreValid(string $ $this->kernel ->getContainer() ->get('tests.bitbag.sylius_adyen_plugin.behat.context.api_mock_client') - ->setJsonHandler(function (Service $service, string $url, array $payload) use ($merchantAccount, $apiKey) { + ->setJsonHandler(function ( + Service $service, + string $url, + array $payload + ) use ($merchantAccount, $apiKey) { $config = $service->getClient()->getConfig(); if ($config->getXApiKey() !== $apiKey) { diff --git a/tests/HttpClientStub.php b/tests/HttpClientStub.php index 9a28cd29..c45c9044 100644 --- a/tests/HttpClientStub.php +++ b/tests/HttpClientStub.php @@ -32,9 +32,13 @@ public function setPostHandler(?callable $postHandler): void self::$postHandler = $postHandler; } - public function requestJson(Service $service, $requestUrl, $params) + public function requestJson( + Service $service, + $requestUrl, + $params + ) { - if (self::$jsonHandler !== null) { + if (null !== self::$jsonHandler) { return call_user_func(static::$jsonHandler, $service, $requestUrl, $params); } @@ -43,9 +47,13 @@ public function requestJson(Service $service, $requestUrl, $params) return $client->requestJson($service, $requestUrl, $params); } - public function requestPost(Service $service, $requestUrl, $params) + public function requestPost( + Service $service, + $requestUrl, + $params + ) { - if (self::$postHandler !== null) { + if (null !== self::$postHandler) { return call_user_func(static::$postHandler, $service, $requestUrl, $params); } diff --git a/tests/Unit/Bus/Handler/AlterPaymentHandlerTest.php b/tests/Unit/Bus/Handler/AlterPaymentHandlerTest.php index 8820ef01..aae81080 100644 --- a/tests/Unit/Bus/Handler/AlterPaymentHandlerTest.php +++ b/tests/Unit/Bus/Handler/AlterPaymentHandlerTest.php @@ -83,11 +83,11 @@ public function testForNonApplicablePayment(?PaymentInterface $payment = null, ? ; $order = new Order(); - if ($orderPaymentState !== null) { + if (null !== $orderPaymentState) { $order->setPaymentState($orderPaymentState); } - if ($payment !== null) { + if (null !== $payment) { $order->addPayment($payment); } diff --git a/tests/Unit/Bus/Handler/PaymentFinalizationHandlerTest.php b/tests/Unit/Bus/Handler/PaymentFinalizationHandlerTest.php index c8caf32d..5951bb62 100644 --- a/tests/Unit/Bus/Handler/PaymentFinalizationHandlerTest.php +++ b/tests/Unit/Bus/Handler/PaymentFinalizationHandlerTest.php @@ -19,7 +19,6 @@ use Sylius\Component\Core\Model\Order; use Sylius\Component\Core\Model\Payment; use Sylius\Component\Core\OrderPaymentStates; -use Symfony\Component\Messenger\MessageBusInterface; class PaymentFinalizationHandlerTest extends TestCase { diff --git a/tests/Unit/Bus/Handler/RefundPaymentGeneratedHandlerTest.php b/tests/Unit/Bus/Handler/RefundPaymentGeneratedHandlerTest.php index a03a8fc9..c800508b 100644 --- a/tests/Unit/Bus/Handler/RefundPaymentGeneratedHandlerTest.php +++ b/tests/Unit/Bus/Handler/RefundPaymentGeneratedHandlerTest.php @@ -101,7 +101,7 @@ public function testUnacceptable(?PaymentInterface $payment = null): void ->method('find') ->willReturn($payment); - if ($payment !== null) { + if (null !== $payment) { $this->paymentMethodRepository ->method('find') ->willReturn($payment->getMethod()) @@ -183,7 +183,7 @@ public function testAffirmative(): void ->expects($this->once()) ->method('dispatch') ->with($this->callback(static function (CreateReferenceForRefund $command) { - return $command->getRefundReference() === self::NEW_PSP_REFERENCE; + return self::NEW_PSP_REFERENCE === $command->getRefundReference(); })); ($this->handler)($command); diff --git a/tests/Unit/Client/PaymentMethodsFilterTest.php b/tests/Unit/Client/PaymentMethodsFilterTest.php index a23b90d5..817a4e07 100644 --- a/tests/Unit/Client/PaymentMethodsFilterTest.php +++ b/tests/Unit/Client/PaymentMethodsFilterTest.php @@ -53,7 +53,11 @@ public static function provideForTestFilter(): array /** * @dataProvider provideForTestFilter */ - public function testFilter(array $paymentMethodsResponseList, ?array $supportedMethodsList, array $expected): void + public function testFilter( + array $paymentMethodsResponseList, + ?array $supportedMethodsList, + array $expected + ): void { $response = [ 'paymentMethods' => $paymentMethodsResponseList, diff --git a/tests/Unit/Normalizer/AdditionalDetailsNormalizerTest.php b/tests/Unit/Normalizer/AdditionalDetailsNormalizerTest.php index 57fa41ad..f4fe4ae4 100644 --- a/tests/Unit/Normalizer/AdditionalDetailsNormalizerTest.php +++ b/tests/Unit/Normalizer/AdditionalDetailsNormalizerTest.php @@ -58,7 +58,11 @@ public static function provideForSupportsNormalization(): array /** * @dataProvider provideForSupportsNormalization */ - public function testSupportsNormalization(array $context, ?OrderInterface $order, bool $pass): void + public function testSupportsNormalization( + array $context, + ?OrderInterface $order, + bool $pass + ): void { $this->assertEquals($pass, $this->normalizer->supportsNormalization($order, null, $context)); } diff --git a/tests/Unit/Normalizer/AddressNormalizerTest.php b/tests/Unit/Normalizer/AddressNormalizerTest.php index 6303fc51..f059269a 100644 --- a/tests/Unit/Normalizer/AddressNormalizerTest.php +++ b/tests/Unit/Normalizer/AddressNormalizerTest.php @@ -56,7 +56,11 @@ public static function provideForSupportsNormalization(): array /** * @dataProvider provideForSupportsNormalization */ - public function testSupportsNormalization(array $context, ?AddressInterface $order, bool $pass): void + public function testSupportsNormalization( + array $context, + ?AddressInterface $order, + bool $pass + ): void { $this->assertEquals($pass, $this->normalizer->supportsNormalization($order, null, $context)); } diff --git a/tests/Unit/Normalizer/OrderItemToLineItemNormalizerTest.php b/tests/Unit/Normalizer/OrderItemToLineItemNormalizerTest.php index 4fad1ab0..dfad2b1a 100644 --- a/tests/Unit/Normalizer/OrderItemToLineItemNormalizerTest.php +++ b/tests/Unit/Normalizer/OrderItemToLineItemNormalizerTest.php @@ -60,7 +60,11 @@ public static function provideForSupportsNormalization(): array /** * @dataProvider provideForSupportsNormalization */ - public function testSupportsNormalization(array $context, ?OrderItemInterface $order, bool $pass): void + public function testSupportsNormalization( + array $context, + ?OrderItemInterface $order, + bool $pass + ): void { $this->assertEquals($pass, $this->normalizer->supportsNormalization($order, null, $context)); } diff --git a/tests/Unit/Processor/PaymentResponseProcessor/AbstractProcessorTest.php b/tests/Unit/Processor/PaymentResponseProcessor/AbstractProcessorTest.php index 41d04d08..cb4e2ddb 100644 --- a/tests/Unit/Processor/PaymentResponseProcessor/AbstractProcessorTest.php +++ b/tests/Unit/Processor/PaymentResponseProcessor/AbstractProcessorTest.php @@ -70,7 +70,7 @@ protected function createRequestWithSession(): Request protected function getPayment(?string $resultCode = null, ?string $orderToken = null): PaymentInterface { $details = []; - if ($resultCode !== null) { + if (null !== $resultCode) { $details['resultCode'] = $resultCode; } @@ -80,7 +80,7 @@ protected function getPayment(?string $resultCode = null, ?string $orderToken = ->willReturn($details) ; - if ($orderToken !== null) { + if (null !== $orderToken) { $order = $this->createMock(OrderInterface::class); $order ->method('getTokenValue') diff --git a/tests/Unit/Processor/PaymentResponseProcessor/SuccessfulResponseProcessorTest.php b/tests/Unit/Processor/PaymentResponseProcessor/SuccessfulResponseProcessorTest.php index 5ec8f84e..ba23f378 100644 --- a/tests/Unit/Processor/PaymentResponseProcessor/SuccessfulResponseProcessorTest.php +++ b/tests/Unit/Processor/PaymentResponseProcessor/SuccessfulResponseProcessorTest.php @@ -54,7 +54,11 @@ public static function provideForTestRedirect(): array /** * @dataProvider provideForTestRedirect */ - public function testRedirect(Request $request, string $expectedUrlEnding, bool $expectFlash = false) + public function testRedirect( + Request $request, + string $expectedUrlEnding, + bool $expectFlash = false + ) { $payment = $this->createMock(PaymentInterface::class); diff --git a/tests/Unit/Processor/PaymentResponseProcessorTest.php b/tests/Unit/Processor/PaymentResponseProcessorTest.php index 6caf47f7..55d8e930 100644 --- a/tests/Unit/Processor/PaymentResponseProcessorTest.php +++ b/tests/Unit/Processor/PaymentResponseProcessorTest.php @@ -45,7 +45,7 @@ private function getProcessor(bool $accepts, ?string $response = null): Processo ; } - if ($response !== null) { + if (null !== $response) { $result ->method('process') ->willReturn($response) diff --git a/tests/Unit/Resolver/Address/StreetAddressResolverTest.php b/tests/Unit/Resolver/Address/StreetAddressResolverTest.php index 6c398dd0..f035be34 100644 --- a/tests/Unit/Resolver/Address/StreetAddressResolverTest.php +++ b/tests/Unit/Resolver/Address/StreetAddressResolverTest.php @@ -1,4 +1,6 @@ -streetAddressResolver->resolve($streetAddress); @@ -30,7 +36,11 @@ public function testResolveHouseNumberFirst(string $streetAddress, string $stree } /** @dataProvider provideHouseNumberLast */ - public function testResolveHouseNumberLast(string $streetAddress, string $street, string $houseNumber): void + public function testResolveHouseNumberLast( + string $streetAddress, + string $street, + string $houseNumber + ): void { $model = $this->streetAddressResolver->resolve($streetAddress); @@ -73,7 +83,7 @@ public function provideHouseNumberFirst(): array ['1 Montfortanenlaan', 'Montfortanenlaan', '1'], ['2D Gasthuislaan', 'Gasthuislaan', '2D'], ['98 W Molstraat', 'Molstraat', '98 W'], - ['76B/2 ul. Akacjowa', 'ul. Akacjowa', '76B/2'] + ['76B/2 ul. Akacjowa', 'ul. Akacjowa', '76B/2'], ]; } } From 4a7b557e99b12f531a988816bf2f53abf1260bd4 Mon Sep 17 00:00:00 2001 From: Rafal Malenta Date: Mon, 27 Mar 2023 09:08:51 +0200 Subject: [PATCH 20/44] Psalm --- .github/workflows/build.yml | 6 +++--- composer.json | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 68b524b3..78caed9c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -166,9 +166,9 @@ jobs: name: Run ECS run: vendor/bin/ecs check src - - - name: Run Psalm - run: vendor/bin/psalm +# - +# name: Run Psalm +# run: vendor/bin/psalm - name: Run PHPSpec diff --git a/composer.json b/composer.json index a350f959..468b8ff7 100644 --- a/composer.json +++ b/composer.json @@ -13,6 +13,7 @@ "adyen/php-api-library": "^11.0", "composer/package-versions-deprecated": "^1.11", "nyholm/psr7": "^1.4", + "psalm/plugin-symfony": "^4.0", "sylius/refund-plugin": "~1.0.0 || ^1.1", "sylius/sylius": "~1.11.0 || ~1.12.0", "symfony/messenger": "^5.4 || ^6.0", From 396fe792c09d8efc82694da73e99891ae6419a98 Mon Sep 17 00:00:00 2001 From: Rafal Malenta Date: Mon, 27 Mar 2023 09:22:39 +0200 Subject: [PATCH 21/44] Added doctrine annotations --- .github/workflows/build.yml | 2 +- composer.json | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 78caed9c..5efa0915 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -16,7 +16,7 @@ jobs: tests: runs-on: ubuntu-22.04 - name: "PHP ${{ matrix.php }}, MySQL ${{ matrix.mysql }}, Sylius ${{ matrix.sylius }}" + name: "Sylius ${{ matrix.sylius }}, PHP ${{ matrix.php }}, Symfony ${{ matrix.symfony }}, MySQL ${{ matrix.mysql }}" strategy: fail-fast: false diff --git a/composer.json b/composer.json index 468b8ff7..484a480b 100644 --- a/composer.json +++ b/composer.json @@ -12,6 +12,7 @@ "php": "^8.0", "adyen/php-api-library": "^11.0", "composer/package-versions-deprecated": "^1.11", + "doctrine/annotations": "^1.14", "nyholm/psr7": "^1.4", "psalm/plugin-symfony": "^4.0", "sylius/refund-plugin": "~1.0.0 || ^1.1", @@ -48,7 +49,7 @@ "symfony/intl": "^5.4 || ^6.0", "symfony/web-profiler-bundle": "^5.4 || ^6.0", "symplify/easy-coding-standard": "^9.3, !=9.3.27", - "vimeo/psalm": "^4.4.1" + "vimeo/psalm": "^4.4.1 || ^5.0.0" }, "config": { "sort-packages": true, From 52f207c609ae13860fdd833d98ca691a934f4ebd Mon Sep 17 00:00:00 2001 From: Rafal Malenta Date: Mon, 27 Mar 2023 10:16:15 +0200 Subject: [PATCH 22/44] Restored psalm to build.yml --- .github/workflows/build.yml | 6 +++--- phpstan.neon | 1 - 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5efa0915..1f0a814b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -166,9 +166,9 @@ jobs: name: Run ECS run: vendor/bin/ecs check src -# - -# name: Run Psalm -# run: vendor/bin/psalm + - + name: Run Psalm + run: vendor/bin/psalm - name: Run PHPSpec diff --git a/phpstan.neon b/phpstan.neon index 538f7673..b64e4155 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,7 +1,6 @@ parameters: reportUnmatchedIgnoredErrors: false checkMissingIterableValueType: false - checkGenericClassInNonGenericObjectType: false excludes_analyse: # Makes PHPStan crash From 3c07b18cc3a96397e26b97baf3e3399387b3aef8 Mon Sep 17 00:00:00 2001 From: Rafal Malenta Date: Mon, 27 Mar 2023 11:08:28 +0200 Subject: [PATCH 23/44] Fixed tests ,psalm and phpstan --- composer.json | 2 +- phpstan.neon | 3 +-- .../PreserveOrderTokenUponRedirectionCallback.php | 2 +- src/Controller/Shop/AdyenDetailsAction.php | 1 - .../PaymentResponseProcessor/AbstractProcessor.php | 7 ++++--- .../FallbackResponseProcessor.php | 4 ++++ src/Resolver/Order/PaymentCheckoutOrderResolver.php | 7 ++++--- src/Resolver/Version/VersionResolver.php | 2 +- .../FailedResponseProcessorTest.php | 4 ++-- .../SuccessfulResponseProcessorTest.php | 8 ++++---- tests/Unit/Processor/PaymentResponseProcessorTest.php | 3 ++- 11 files changed, 24 insertions(+), 19 deletions(-) diff --git a/composer.json b/composer.json index 484a480b..e367a1c1 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,7 @@ "nyholm/psr7": "^1.4", "psalm/plugin-symfony": "^4.0", "sylius/refund-plugin": "~1.0.0 || ^1.1", - "sylius/sylius": "~1.11.0 || ~1.12.0", + "sylius/sylius": " ~1.12.0", "symfony/messenger": "^5.4 || ^6.0", "symfony/serializer": "^5.4 || ^6.0", "symfony/webpack-encore-bundle": "^1.14" diff --git a/phpstan.neon b/phpstan.neon index b64e4155..a5556711 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,6 +1,7 @@ parameters: reportUnmatchedIgnoredErrors: false checkMissingIterableValueType: false + checkGenericClassInNonGenericObjectType: false excludes_analyse: # Makes PHPStan crash @@ -10,8 +11,6 @@ parameters: # Test dependencies - 'tests/Application/app/**.php' - 'tests/Application/src/**.php' - - 'tests/Application/node_modules' - - 'vendor' ignoreErrors: - '/Parameter #1 \$configuration of method Symfony\\Component\\DependencyInjection\\Extension\\Extension::processConfiguration\(\) expects Symfony\\Component\\Config\\Definition\\ConfigurationInterface, Symfony\\Component\\Config\\Definition\\ConfigurationInterface\|null given\./' diff --git a/src/Callback/PreserveOrderTokenUponRedirectionCallback.php b/src/Callback/PreserveOrderTokenUponRedirectionCallback.php index d2bfcba4..954b1511 100644 --- a/src/Callback/PreserveOrderTokenUponRedirectionCallback.php +++ b/src/Callback/PreserveOrderTokenUponRedirectionCallback.php @@ -18,7 +18,7 @@ class PreserveOrderTokenUponRedirectionCallback { public const NON_FINALIZED_CART_SESSION_KEY = '_ADYEN_PAYMENT_IN_PROGRESS'; - /** @var SessionInterface */ + /** @var ?SessionInterface */ private $session; public function __construct(RequestStack $session) diff --git a/src/Controller/Shop/AdyenDetailsAction.php b/src/Controller/Shop/AdyenDetailsAction.php index 541e7cc7..3f140c2d 100644 --- a/src/Controller/Shop/AdyenDetailsAction.php +++ b/src/Controller/Shop/AdyenDetailsAction.php @@ -30,7 +30,6 @@ public function __construct( public function __invoke(Request $request, string $code): Response { - /** @var ?string $referenceId */ $referenceId = $request->query->get(self::REFERENCE_ID_KEY); if (null === $referenceId) { diff --git a/src/Processor/PaymentResponseProcessor/AbstractProcessor.php b/src/Processor/PaymentResponseProcessor/AbstractProcessor.php index 6fbe67ac..ea46224e 100644 --- a/src/Processor/PaymentResponseProcessor/AbstractProcessor.php +++ b/src/Processor/PaymentResponseProcessor/AbstractProcessor.php @@ -12,6 +12,7 @@ use Sylius\Component\Core\Model\PaymentInterface; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\Session\Session; use Symfony\Contracts\Translation\TranslatorInterface; abstract class AbstractProcessor implements ProcessorInterface @@ -23,7 +24,7 @@ abstract class AbstractProcessor implements ProcessorInterface public const FLASH_ERROR = 'error'; /** @var TranslatorInterface|null */ - protected $translator; + protected ?TranslatorInterface $translator; protected function isResultCodeSupportedForPayment(?PaymentInterface $payment, array $resultCodes): bool { @@ -51,9 +52,9 @@ protected function addFlash( if (null !== $this->translator) { $message = $this->translator->trans($message); } - + /** @var Session $session */ $session = $request->getSession(); - /** @phpstan-ignore-next-line */ + $session->getFlashBag()->add($type, $message); } } diff --git a/src/Processor/PaymentResponseProcessor/FallbackResponseProcessor.php b/src/Processor/PaymentResponseProcessor/FallbackResponseProcessor.php index ad5bbe48..dd9d681a 100644 --- a/src/Processor/PaymentResponseProcessor/FallbackResponseProcessor.php +++ b/src/Processor/PaymentResponseProcessor/FallbackResponseProcessor.php @@ -14,6 +14,10 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; +/** + * @psalm-suppress PropertyNotSetInConstructor + */ + final class FallbackResponseProcessor extends AbstractProcessor { public const REDIRECT_TARGET_ACTION = 'bitbag_adyen_thank_you'; diff --git a/src/Resolver/Order/PaymentCheckoutOrderResolver.php b/src/Resolver/Order/PaymentCheckoutOrderResolver.php index 4639d228..12bc8da5 100644 --- a/src/Resolver/Order/PaymentCheckoutOrderResolver.php +++ b/src/Resolver/Order/PaymentCheckoutOrderResolver.php @@ -12,6 +12,7 @@ use Sylius\Component\Core\Model\OrderInterface; use Sylius\Component\Order\Context\CartContextInterface; +use Sylius\Component\Order\Repository\OrderRepositoryInterface; use Sylius\Component\Resource\Repository\RepositoryInterface; use Symfony\Component\HttpFoundation\Exception\BadRequestException; use Symfony\Component\HttpFoundation\Request; @@ -26,13 +27,13 @@ final class PaymentCheckoutOrderResolver implements PaymentCheckoutOrderResolver /** @var CartContextInterface */ private $cartContext; - /** @var RepositoryInterface */ - private $orderRepository; + + private OrderRepositoryInterface $orderRepository; public function __construct( RequestStack $requestStack, CartContextInterface $cartContext, - RepositoryInterface $orderRepository + OrderRepositoryInterface $orderRepository ) { $this->requestStack = $requestStack; $this->cartContext = $cartContext; diff --git a/src/Resolver/Version/VersionResolver.php b/src/Resolver/Version/VersionResolver.php index 85f2e432..0e82eb1c 100644 --- a/src/Resolver/Version/VersionResolver.php +++ b/src/Resolver/Version/VersionResolver.php @@ -11,7 +11,7 @@ namespace BitBag\SyliusAdyenPlugin\Resolver\Version; use PackageVersions\FallbackVersions; -use Sylius\Bundle\CoreBundle\Application\Kernel; +use Sylius\Bundle\CoreBundle\SyliusCoreBundle as Kernel; final class VersionResolver implements VersionResolverInterface { diff --git a/tests/Unit/Processor/PaymentResponseProcessor/FailedResponseProcessorTest.php b/tests/Unit/Processor/PaymentResponseProcessor/FailedResponseProcessorTest.php index 79e6c4d4..100d27ab 100644 --- a/tests/Unit/Processor/PaymentResponseProcessor/FailedResponseProcessorTest.php +++ b/tests/Unit/Processor/PaymentResponseProcessor/FailedResponseProcessorTest.php @@ -27,8 +27,8 @@ protected function setUp(): void $this->dispatcher = $this->createMock(DispatcherInterface::class); $this->processor = new FailedResponseProcessor( - self::getRouter(self::$container), - self::$container->get('translator'), + self::getRouter($this->getContainer()), + $this->getContainer()->get('translator'), $this->dispatcher ); } diff --git a/tests/Unit/Processor/PaymentResponseProcessor/SuccessfulResponseProcessorTest.php b/tests/Unit/Processor/PaymentResponseProcessor/SuccessfulResponseProcessorTest.php index ba23f378..32fe02a1 100644 --- a/tests/Unit/Processor/PaymentResponseProcessor/SuccessfulResponseProcessorTest.php +++ b/tests/Unit/Processor/PaymentResponseProcessor/SuccessfulResponseProcessorTest.php @@ -22,9 +22,9 @@ protected function setUp(): void parent::setUp(); $this->processor = new SuccessfulResponseProcessor( - self::$container->get('tests.bitbag.sylius_adyen_plugin.bus.dispatcher'), - self::getRouter(self::$container), - self::$container->get('translator') + $this->getContainer()->get('tests.bitbag.sylius_adyen_plugin.bus.dispatcher'), + self::getRouter($this->getContainer()), + $this->getContainer()->get('translator') ); } @@ -76,7 +76,7 @@ public function testRedirect( private function assertIsPaymentScheduledForFinalization(): void { - $messenger = self::$container->get('tests.bitbag.sylius_adyen_plugin.message_bus'); + $messenger = $this->getContainer()->get('tests.bitbag.sylius_adyen_plugin.message_bus'); $commands = $messenger->getDispatchedMessages(); $this->assertNotEmpty($commands); diff --git a/tests/Unit/Processor/PaymentResponseProcessorTest.php b/tests/Unit/Processor/PaymentResponseProcessorTest.php index 55d8e930..d2b038ad 100644 --- a/tests/Unit/Processor/PaymentResponseProcessorTest.php +++ b/tests/Unit/Processor/PaymentResponseProcessorTest.php @@ -24,6 +24,7 @@ class PaymentResponseProcessorTest extends KernelTestCase protected function setUp(): void { +// $this->bootKernel(); self::bootKernel(); } @@ -31,7 +32,7 @@ private function getPaymentResponseProcessor(array $processors = []): PaymentRes { return new PaymentResponseProcessor( $processors, - AbstractProcessorTest::getRouter(self::$container) + AbstractProcessorTest::getRouter($this->getContainer()) ); } From b18be246b053131a83670876b06e2ccbda1a9bf6 Mon Sep 17 00:00:00 2001 From: Rafal Malenta Date: Mon, 27 Mar 2023 11:15:25 +0200 Subject: [PATCH 24/44] ECS --- .../PaymentResponseProcessor/AbstractProcessor.php | 1 - .../PaymentResponseProcessor/FallbackResponseProcessor.php | 1 - src/Resolver/Order/PaymentCheckoutOrderResolver.php | 2 -- .../Context/Ui/Admin/ManagingPaymentMethodAdyenContext.php | 4 ++-- tests/HttpClientStub.php | 6 ++---- tests/Unit/Client/PaymentMethodsFilterTest.php | 3 +-- tests/Unit/Normalizer/AdditionalDetailsNormalizerTest.php | 3 +-- tests/Unit/Normalizer/AddressNormalizerTest.php | 3 +-- tests/Unit/Normalizer/OrderItemToLineItemNormalizerTest.php | 3 +-- .../SuccessfulResponseProcessorTest.php | 3 +-- tests/Unit/Resolver/Address/StreetAddressResolverTest.php | 6 ++---- 11 files changed, 11 insertions(+), 24 deletions(-) diff --git a/src/Processor/PaymentResponseProcessor/AbstractProcessor.php b/src/Processor/PaymentResponseProcessor/AbstractProcessor.php index ea46224e..d610621a 100644 --- a/src/Processor/PaymentResponseProcessor/AbstractProcessor.php +++ b/src/Processor/PaymentResponseProcessor/AbstractProcessor.php @@ -23,7 +23,6 @@ abstract class AbstractProcessor implements ProcessorInterface public const FLASH_ERROR = 'error'; - /** @var TranslatorInterface|null */ protected ?TranslatorInterface $translator; protected function isResultCodeSupportedForPayment(?PaymentInterface $payment, array $resultCodes): bool diff --git a/src/Processor/PaymentResponseProcessor/FallbackResponseProcessor.php b/src/Processor/PaymentResponseProcessor/FallbackResponseProcessor.php index dd9d681a..7b1b9973 100644 --- a/src/Processor/PaymentResponseProcessor/FallbackResponseProcessor.php +++ b/src/Processor/PaymentResponseProcessor/FallbackResponseProcessor.php @@ -17,7 +17,6 @@ /** * @psalm-suppress PropertyNotSetInConstructor */ - final class FallbackResponseProcessor extends AbstractProcessor { public const REDIRECT_TARGET_ACTION = 'bitbag_adyen_thank_you'; diff --git a/src/Resolver/Order/PaymentCheckoutOrderResolver.php b/src/Resolver/Order/PaymentCheckoutOrderResolver.php index 12bc8da5..12eee838 100644 --- a/src/Resolver/Order/PaymentCheckoutOrderResolver.php +++ b/src/Resolver/Order/PaymentCheckoutOrderResolver.php @@ -13,7 +13,6 @@ use Sylius\Component\Core\Model\OrderInterface; use Sylius\Component\Order\Context\CartContextInterface; use Sylius\Component\Order\Repository\OrderRepositoryInterface; -use Sylius\Component\Resource\Repository\RepositoryInterface; use Symfony\Component\HttpFoundation\Exception\BadRequestException; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\RequestStack; @@ -27,7 +26,6 @@ final class PaymentCheckoutOrderResolver implements PaymentCheckoutOrderResolver /** @var CartContextInterface */ private $cartContext; - private OrderRepositoryInterface $orderRepository; public function __construct( diff --git a/tests/Behat/Context/Ui/Admin/ManagingPaymentMethodAdyenContext.php b/tests/Behat/Context/Ui/Admin/ManagingPaymentMethodAdyenContext.php index f4ebeddb..5a0e6c5f 100644 --- a/tests/Behat/Context/Ui/Admin/ManagingPaymentMethodAdyenContext.php +++ b/tests/Behat/Context/Ui/Admin/ManagingPaymentMethodAdyenContext.php @@ -69,10 +69,10 @@ public function adyenServiceWillConfirmMerchantAccountAndApiKeyAreValid(string $ ->getContainer() ->get('tests.bitbag.sylius_adyen_plugin.behat.context.api_mock_client') ->setJsonHandler(function ( - Service $service, + Service $service, string $url, array $payload - ) use ($merchantAccount, $apiKey) { + ) use ($merchantAccount, $apiKey) { $config = $service->getClient()->getConfig(); if ($config->getXApiKey() !== $apiKey) { diff --git a/tests/HttpClientStub.php b/tests/HttpClientStub.php index c45c9044..ed6fa6ff 100644 --- a/tests/HttpClientStub.php +++ b/tests/HttpClientStub.php @@ -36,8 +36,7 @@ public function requestJson( Service $service, $requestUrl, $params - ) - { + ) { if (null !== self::$jsonHandler) { return call_user_func(static::$jsonHandler, $service, $requestUrl, $params); } @@ -51,8 +50,7 @@ public function requestPost( Service $service, $requestUrl, $params - ) - { + ) { if (null !== self::$postHandler) { return call_user_func(static::$postHandler, $service, $requestUrl, $params); } diff --git a/tests/Unit/Client/PaymentMethodsFilterTest.php b/tests/Unit/Client/PaymentMethodsFilterTest.php index 817a4e07..fe237b01 100644 --- a/tests/Unit/Client/PaymentMethodsFilterTest.php +++ b/tests/Unit/Client/PaymentMethodsFilterTest.php @@ -57,8 +57,7 @@ public function testFilter( array $paymentMethodsResponseList, ?array $supportedMethodsList, array $expected - ): void - { + ): void { $response = [ 'paymentMethods' => $paymentMethodsResponseList, ]; diff --git a/tests/Unit/Normalizer/AdditionalDetailsNormalizerTest.php b/tests/Unit/Normalizer/AdditionalDetailsNormalizerTest.php index f4fe4ae4..f49c33ff 100644 --- a/tests/Unit/Normalizer/AdditionalDetailsNormalizerTest.php +++ b/tests/Unit/Normalizer/AdditionalDetailsNormalizerTest.php @@ -62,8 +62,7 @@ public function testSupportsNormalization( array $context, ?OrderInterface $order, bool $pass - ): void - { + ): void { $this->assertEquals($pass, $this->normalizer->supportsNormalization($order, null, $context)); } diff --git a/tests/Unit/Normalizer/AddressNormalizerTest.php b/tests/Unit/Normalizer/AddressNormalizerTest.php index f059269a..93dc8ceb 100644 --- a/tests/Unit/Normalizer/AddressNormalizerTest.php +++ b/tests/Unit/Normalizer/AddressNormalizerTest.php @@ -60,8 +60,7 @@ public function testSupportsNormalization( array $context, ?AddressInterface $order, bool $pass - ): void - { + ): void { $this->assertEquals($pass, $this->normalizer->supportsNormalization($order, null, $context)); } diff --git a/tests/Unit/Normalizer/OrderItemToLineItemNormalizerTest.php b/tests/Unit/Normalizer/OrderItemToLineItemNormalizerTest.php index dfad2b1a..407864a1 100644 --- a/tests/Unit/Normalizer/OrderItemToLineItemNormalizerTest.php +++ b/tests/Unit/Normalizer/OrderItemToLineItemNormalizerTest.php @@ -64,8 +64,7 @@ public function testSupportsNormalization( array $context, ?OrderItemInterface $order, bool $pass - ): void - { + ): void { $this->assertEquals($pass, $this->normalizer->supportsNormalization($order, null, $context)); } diff --git a/tests/Unit/Processor/PaymentResponseProcessor/SuccessfulResponseProcessorTest.php b/tests/Unit/Processor/PaymentResponseProcessor/SuccessfulResponseProcessorTest.php index 32fe02a1..38a57969 100644 --- a/tests/Unit/Processor/PaymentResponseProcessor/SuccessfulResponseProcessorTest.php +++ b/tests/Unit/Processor/PaymentResponseProcessor/SuccessfulResponseProcessorTest.php @@ -58,8 +58,7 @@ public function testRedirect( Request $request, string $expectedUrlEnding, bool $expectFlash = false - ) - { + ) { $payment = $this->createMock(PaymentInterface::class); $result = $this->processor->process('Szczebrzeszyn', $request, $payment); diff --git a/tests/Unit/Resolver/Address/StreetAddressResolverTest.php b/tests/Unit/Resolver/Address/StreetAddressResolverTest.php index f035be34..16ac0696 100644 --- a/tests/Unit/Resolver/Address/StreetAddressResolverTest.php +++ b/tests/Unit/Resolver/Address/StreetAddressResolverTest.php @@ -27,8 +27,7 @@ public function testResolveHouseNumberFirst( string $streetAddress, string $street, string $houseNumber - ): void - { + ): void { $model = $this->streetAddressResolver->resolve($streetAddress); self::assertEquals($street, $model->getStreet()); @@ -40,8 +39,7 @@ public function testResolveHouseNumberLast( string $streetAddress, string $street, string $houseNumber - ): void - { + ): void { $model = $this->streetAddressResolver->resolve($streetAddress); self::assertEquals($street, $model->getStreet()); From 2a33cd573a1564ad14ae3d671642c37a1f660c28 Mon Sep 17 00:00:00 2001 From: Rafal Malenta Date: Mon, 27 Mar 2023 11:38:54 +0200 Subject: [PATCH 25/44] Added conditional VersionResolver.php --- composer.json | 2 +- src/Resolver/Version/VersionResolver.php | 16 ++++++++++++++-- .../Processor/PaymentResponseProcessorTest.php | 1 - 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index e367a1c1..484a480b 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,7 @@ "nyholm/psr7": "^1.4", "psalm/plugin-symfony": "^4.0", "sylius/refund-plugin": "~1.0.0 || ^1.1", - "sylius/sylius": " ~1.12.0", + "sylius/sylius": "~1.11.0 || ~1.12.0", "symfony/messenger": "^5.4 || ^6.0", "symfony/serializer": "^5.4 || ^6.0", "symfony/webpack-encore-bundle": "^1.14" diff --git a/src/Resolver/Version/VersionResolver.php b/src/Resolver/Version/VersionResolver.php index 0e82eb1c..5ea7db33 100644 --- a/src/Resolver/Version/VersionResolver.php +++ b/src/Resolver/Version/VersionResolver.php @@ -11,7 +11,11 @@ namespace BitBag\SyliusAdyenPlugin\Resolver\Version; use PackageVersions\FallbackVersions; -use Sylius\Bundle\CoreBundle\SyliusCoreBundle as Kernel; + +use Symfony\Component\HttpKernel\Kernel as Symfony; +use Sylius\Bundle\CoreBundle\Application\Kernel; + +use Sylius\Bundle\CoreBundle\SyliusCoreBundle as SyliusKernel; final class VersionResolver implements VersionResolverInterface { @@ -44,6 +48,14 @@ private function getPluginVersion(): string private function resolveApplicationInfo(): array { + $version = ''; + if(Symfony::MAJOR_VERSION === 5) { + $version = Kernel::VERSION; + } + else if(defined('SyliusKernel::VERSION')){ + /** @var string $version */ + $version = constant('SyliusKernel::VERSION'); + } return [ 'merchantApplication' => [ 'name' => 'adyen-sylius', @@ -51,7 +63,7 @@ private function resolveApplicationInfo(): array ], 'externalPlatform' => [ 'name' => 'Sylius', - 'version' => Kernel::VERSION, + 'version' => $version, 'integrator' => 'BitBag', ], ]; diff --git a/tests/Unit/Processor/PaymentResponseProcessorTest.php b/tests/Unit/Processor/PaymentResponseProcessorTest.php index d2b038ad..c1bd9b7f 100644 --- a/tests/Unit/Processor/PaymentResponseProcessorTest.php +++ b/tests/Unit/Processor/PaymentResponseProcessorTest.php @@ -24,7 +24,6 @@ class PaymentResponseProcessorTest extends KernelTestCase protected function setUp(): void { -// $this->bootKernel(); self::bootKernel(); } From a633196a043250f02fc1c986c8e80b729feb0e87 Mon Sep 17 00:00:00 2001 From: Rafal Malenta Date: Mon, 27 Mar 2023 11:42:54 +0200 Subject: [PATCH 26/44] Added conditional VersionResolver.php --- src/Resolver/Version/VersionResolver.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Resolver/Version/VersionResolver.php b/src/Resolver/Version/VersionResolver.php index 5ea7db33..c76f5f7f 100644 --- a/src/Resolver/Version/VersionResolver.php +++ b/src/Resolver/Version/VersionResolver.php @@ -49,8 +49,8 @@ private function getPluginVersion(): string private function resolveApplicationInfo(): array { $version = ''; - if(Symfony::MAJOR_VERSION === 5) { - $version = Kernel::VERSION; + if(constant('Kernel::VERSION') === 5) { + $version = constant('Kernel::VERSION'); } else if(defined('SyliusKernel::VERSION')){ /** @var string $version */ From df9e8165ac4e2f4c599bade01383cef0b6a23ebb Mon Sep 17 00:00:00 2001 From: Rafal Malenta Date: Mon, 27 Mar 2023 11:47:15 +0200 Subject: [PATCH 27/44] ECS --- src/Resolver/Version/VersionResolver.php | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/Resolver/Version/VersionResolver.php b/src/Resolver/Version/VersionResolver.php index c76f5f7f..28d75e62 100644 --- a/src/Resolver/Version/VersionResolver.php +++ b/src/Resolver/Version/VersionResolver.php @@ -12,11 +12,6 @@ use PackageVersions\FallbackVersions; -use Symfony\Component\HttpKernel\Kernel as Symfony; -use Sylius\Bundle\CoreBundle\Application\Kernel; - -use Sylius\Bundle\CoreBundle\SyliusCoreBundle as SyliusKernel; - final class VersionResolver implements VersionResolverInterface { private const PACKAGE_NAME = 'bitbag/sylius-adyen-plugin'; @@ -49,13 +44,13 @@ private function getPluginVersion(): string private function resolveApplicationInfo(): array { $version = ''; - if(constant('Kernel::VERSION') === 5) { + if (5 === constant('Kernel::VERSION')) { $version = constant('Kernel::VERSION'); - } - else if(defined('SyliusKernel::VERSION')){ + } elseif (defined('SyliusKernel::VERSION')) { /** @var string $version */ $version = constant('SyliusKernel::VERSION'); } + return [ 'merchantApplication' => [ 'name' => 'adyen-sylius', From 0ca3c628d969b395c0e7ebc0f87e68f098c14e74 Mon Sep 17 00:00:00 2001 From: Rafal Malenta Date: Mon, 27 Mar 2023 11:54:07 +0200 Subject: [PATCH 28/44] Psalm fix --- src/Resolver/Version/VersionResolver.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Resolver/Version/VersionResolver.php b/src/Resolver/Version/VersionResolver.php index 28d75e62..d772179f 100644 --- a/src/Resolver/Version/VersionResolver.php +++ b/src/Resolver/Version/VersionResolver.php @@ -45,6 +45,7 @@ private function resolveApplicationInfo(): array { $version = ''; if (5 === constant('Kernel::VERSION')) { + /** @var string $version */ $version = constant('Kernel::VERSION'); } elseif (defined('SyliusKernel::VERSION')) { /** @var string $version */ From 8d5c0054c83fd85631eb42ed9d9f2db2e59c66de Mon Sep 17 00:00:00 2001 From: Rafal Malenta Date: Mon, 27 Mar 2023 14:41:37 +0200 Subject: [PATCH 29/44] Fixed namespaces --- src/Resolver/Version/VersionResolver.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Resolver/Version/VersionResolver.php b/src/Resolver/Version/VersionResolver.php index d772179f..c63b225a 100644 --- a/src/Resolver/Version/VersionResolver.php +++ b/src/Resolver/Version/VersionResolver.php @@ -44,12 +44,12 @@ private function getPluginVersion(): string private function resolveApplicationInfo(): array { $version = ''; - if (5 === constant('Kernel::VERSION')) { + if (5 === constant('Symfony\Component\HttpKernel\Kernel::VERSION')) { /** @var string $version */ - $version = constant('Kernel::VERSION'); - } elseif (defined('SyliusKernel::VERSION')) { + $version = constant('Sylius\Bundle\CoreBundle\Application\Kernel::VERSION'); + } elseif (defined('Sylius\Bundle\CoreBundle\SyliusCoreBundle::VERSION')) { /** @var string $version */ - $version = constant('SyliusKernel::VERSION'); + $version = constant('Sylius\Bundle\CoreBundle\SyliusCoreBundle::VERSION'); } return [ From 61250736e9c3e70bcd1d607e3411d73be8f24309 Mon Sep 17 00:00:00 2001 From: Rafal Malenta Date: Mon, 27 Mar 2023 14:46:03 +0200 Subject: [PATCH 30/44] Fixed namespaces --- src/Resolver/Version/VersionResolver.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Resolver/Version/VersionResolver.php b/src/Resolver/Version/VersionResolver.php index c63b225a..c046a59f 100644 --- a/src/Resolver/Version/VersionResolver.php +++ b/src/Resolver/Version/VersionResolver.php @@ -44,7 +44,7 @@ private function getPluginVersion(): string private function resolveApplicationInfo(): array { $version = ''; - if (5 === constant('Symfony\Component\HttpKernel\Kernel::VERSION')) { + if (5 === constant('Symfony\Component\HttpKernel\Kernel::MAJOR_VERSION')) { /** @var string $version */ $version = constant('Sylius\Bundle\CoreBundle\Application\Kernel::VERSION'); } elseif (defined('Sylius\Bundle\CoreBundle\SyliusCoreBundle::VERSION')) { From e347108521a57acc2fb4da303e56525a6d3dd66a Mon Sep 17 00:00:00 2001 From: Rafal Malenta Date: Tue, 28 Mar 2023 07:42:01 +0200 Subject: [PATCH 31/44] Removed line breake --- src/Resolver/Version/VersionResolver.php | 8 ++++---- tests/Application/package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Resolver/Version/VersionResolver.php b/src/Resolver/Version/VersionResolver.php index c046a59f..69235633 100644 --- a/src/Resolver/Version/VersionResolver.php +++ b/src/Resolver/Version/VersionResolver.php @@ -43,13 +43,13 @@ private function getPluginVersion(): string private function resolveApplicationInfo(): array { - $version = ''; + $syliusVersion = ''; if (5 === constant('Symfony\Component\HttpKernel\Kernel::MAJOR_VERSION')) { /** @var string $version */ - $version = constant('Sylius\Bundle\CoreBundle\Application\Kernel::VERSION'); + $syliusVersion = constant('Sylius\Bundle\CoreBundle\Application\Kernel::VERSION'); } elseif (defined('Sylius\Bundle\CoreBundle\SyliusCoreBundle::VERSION')) { /** @var string $version */ - $version = constant('Sylius\Bundle\CoreBundle\SyliusCoreBundle::VERSION'); + $syliusVersion = constant('Sylius\Bundle\CoreBundle\SyliusCoreBundle::VERSION'); } return [ @@ -59,7 +59,7 @@ private function resolveApplicationInfo(): array ], 'externalPlatform' => [ 'name' => 'Sylius', - 'version' => $version, + 'version' => $syliusVersion, 'integrator' => 'BitBag', ], ]; diff --git a/tests/Application/package.json b/tests/Application/package.json index 6fb6d047..9bf5590f 100644 --- a/tests/Application/package.json +++ b/tests/Application/package.json @@ -46,7 +46,7 @@ "yargs": "^6.4.0" }, "scripts": { - "build": "gulp build", + "build": "yarn encore prod", "gulp": "gulp build", "lint": "yarn lint:js", "lint:js": "eslint gulpfile.babel.js" From 883a5726537a101146f7416aaf9b7a3c12b7ab9c Mon Sep 17 00:00:00 2001 From: Rafal Malenta Date: Tue, 28 Mar 2023 07:51:35 +0200 Subject: [PATCH 32/44] Fixed PHPdoc --- src/Resolver/Version/VersionResolver.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Resolver/Version/VersionResolver.php b/src/Resolver/Version/VersionResolver.php index 69235633..8e98f82e 100644 --- a/src/Resolver/Version/VersionResolver.php +++ b/src/Resolver/Version/VersionResolver.php @@ -45,10 +45,10 @@ private function resolveApplicationInfo(): array { $syliusVersion = ''; if (5 === constant('Symfony\Component\HttpKernel\Kernel::MAJOR_VERSION')) { - /** @var string $version */ + /** @var string $syliusVersion */ $syliusVersion = constant('Sylius\Bundle\CoreBundle\Application\Kernel::VERSION'); } elseif (defined('Sylius\Bundle\CoreBundle\SyliusCoreBundle::VERSION')) { - /** @var string $version */ + /** @var string $syliusVersion */ $syliusVersion = constant('Sylius\Bundle\CoreBundle\SyliusCoreBundle::VERSION'); } From e6be554faa581f442dd82937a8c987766cd42894 Mon Sep 17 00:00:00 2001 From: Rafal Malenta Date: Thu, 13 Apr 2023 07:32:45 +0200 Subject: [PATCH 33/44] Removed comment --- src/Bus/Dispatcher.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Bus/Dispatcher.php b/src/Bus/Dispatcher.php index d91f3bb7..aac898e4 100644 --- a/src/Bus/Dispatcher.php +++ b/src/Bus/Dispatcher.php @@ -17,8 +17,8 @@ final class Dispatcher implements DispatcherInterface { use HandleTrait; -// /** @var MessageBusInterface */ -// private $messageBus; + /** @var MessageBusInterface */ + private $messageBus; /** @var PaymentCommandFactoryInterface */ private $commandFactory; From f668a268219f185839419b87dffe0ae11a41422e Mon Sep 17 00:00:00 2001 From: Rafal Malenta Date: Thu, 13 Apr 2023 07:44:18 +0200 Subject: [PATCH 34/44] Added OS header and fixed formating --- tests/Application/config/bundles.php | 7 +++++++ tests/Application/config/sylius/1.11/bundles.php | 7 +++++++ tests/Application/config/sylius/1.12/bundles.php | 7 +++++++ .../Context/Ui/Admin/ManagingPaymentMethodAdyenContext.php | 4 ++-- 4 files changed, 23 insertions(+), 2 deletions(-) diff --git a/tests/Application/config/bundles.php b/tests/Application/config/bundles.php index cc816c51..6c62174e 100644 --- a/tests/Application/config/bundles.php +++ b/tests/Application/config/bundles.php @@ -1,5 +1,12 @@ get('tests.bitbag.sylius_adyen_plugin.behat.context.api_mock_client') ->setJsonHandler(function ( Service $service, - string $url, - array $payload + string $url, + array $payload ) use ($merchantAccount, $apiKey) { $config = $service->getClient()->getConfig(); From 4fa18a83c97788dba8b9f685810801a8cefa5f72 Mon Sep 17 00:00:00 2001 From: Rafal Malenta Date: Thu, 13 Apr 2023 08:17:16 +0200 Subject: [PATCH 35/44] Added return type, and exeptions instead early return --- .../PreserveOrderTokenUponRedirectionCallback.php | 6 ++++-- src/Resolver/Order/PaymentCheckoutOrderResolver.php | 9 +++++---- tests/HttpClientStub.php | 3 ++- .../Unit/Resolver/Address/StreetAddressResolverTest.php | 7 +++++++ 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/Callback/PreserveOrderTokenUponRedirectionCallback.php b/src/Callback/PreserveOrderTokenUponRedirectionCallback.php index 954b1511..373b6ffe 100644 --- a/src/Callback/PreserveOrderTokenUponRedirectionCallback.php +++ b/src/Callback/PreserveOrderTokenUponRedirectionCallback.php @@ -11,8 +11,10 @@ namespace BitBag\SyliusAdyenPlugin\Callback; use Sylius\Component\Core\Model\OrderInterface; +use Symfony\Component\HttpFoundation\Exception\SessionNotFoundException; use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\HttpFoundation\Session\SessionInterface; +use Symfony\Component\Security\Core\Exception\TokenNotFoundException; class PreserveOrderTokenUponRedirectionCallback { @@ -32,12 +34,12 @@ public function __construct(RequestStack $session) public function __invoke(OrderInterface $order): void { if (null === $this->session) { - return; + throw new SessionNotFoundException(); } $tokenValue = $order->getTokenValue(); if (null === $tokenValue) { - return; + throw new TokenNotFoundException(); } $this->session->set( diff --git a/src/Resolver/Order/PaymentCheckoutOrderResolver.php b/src/Resolver/Order/PaymentCheckoutOrderResolver.php index 12eee838..b06a9401 100644 --- a/src/Resolver/Order/PaymentCheckoutOrderResolver.php +++ b/src/Resolver/Order/PaymentCheckoutOrderResolver.php @@ -64,10 +64,11 @@ private function getCurrentOrder(): ?OrderInterface if (null === $tokenValue) { return null; } - /** - * @phpstan-ignore-next-line - */ - return $this->orderRepository->findOneBy(['tokenValue' => $tokenValue]); + + /** @var OrderInterface $order */ + $order = $this->orderRepository->findOneBy(['tokenValue' => $tokenValue]); + + return $order; } public function resolve(): OrderInterface diff --git a/tests/HttpClientStub.php b/tests/HttpClientStub.php index ed6fa6ff..758d4481 100644 --- a/tests/HttpClientStub.php +++ b/tests/HttpClientStub.php @@ -1,4 +1,5 @@ Date: Thu, 13 Apr 2023 08:28:02 +0200 Subject: [PATCH 36/44] Removed unused config file --- .../config/sylius/1.12/packages/jms_serializer.yaml | 4 ---- 1 file changed, 4 deletions(-) delete mode 100644 tests/Application/config/sylius/1.12/packages/jms_serializer.yaml diff --git a/tests/Application/config/sylius/1.12/packages/jms_serializer.yaml b/tests/Application/config/sylius/1.12/packages/jms_serializer.yaml deleted file mode 100644 index be011d90..00000000 --- a/tests/Application/config/sylius/1.12/packages/jms_serializer.yaml +++ /dev/null @@ -1,4 +0,0 @@ -#jms_serializer: -# visitors: -# xml_serialization: -# format_output: '%kernel.debug%' From 76d88cbfe8970a6c800ebc96c4ac12f172646dbf Mon Sep 17 00:00:00 2001 From: Rafal Malenta Date: Thu, 13 Apr 2023 08:40:10 +0200 Subject: [PATCH 37/44] Restored return instead throws --- src/Callback/PreserveOrderTokenUponRedirectionCallback.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Callback/PreserveOrderTokenUponRedirectionCallback.php b/src/Callback/PreserveOrderTokenUponRedirectionCallback.php index 373b6ffe..ab509646 100644 --- a/src/Callback/PreserveOrderTokenUponRedirectionCallback.php +++ b/src/Callback/PreserveOrderTokenUponRedirectionCallback.php @@ -34,12 +34,12 @@ public function __construct(RequestStack $session) public function __invoke(OrderInterface $order): void { if (null === $this->session) { - throw new SessionNotFoundException(); + return; } $tokenValue = $order->getTokenValue(); if (null === $tokenValue) { - throw new TokenNotFoundException(); + return; } $this->session->set( From f7fe257be0529ebbef068427bf2f8039b01810a0 Mon Sep 17 00:00:00 2001 From: Rafal Malenta Date: Thu, 13 Apr 2023 08:56:14 +0200 Subject: [PATCH 38/44] ECS fix --- src/Callback/PreserveOrderTokenUponRedirectionCallback.php | 2 -- tests/HttpClientStub.php | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Callback/PreserveOrderTokenUponRedirectionCallback.php b/src/Callback/PreserveOrderTokenUponRedirectionCallback.php index ab509646..954b1511 100644 --- a/src/Callback/PreserveOrderTokenUponRedirectionCallback.php +++ b/src/Callback/PreserveOrderTokenUponRedirectionCallback.php @@ -11,10 +11,8 @@ namespace BitBag\SyliusAdyenPlugin\Callback; use Sylius\Component\Core\Model\OrderInterface; -use Symfony\Component\HttpFoundation\Exception\SessionNotFoundException; use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\HttpFoundation\Session\SessionInterface; -use Symfony\Component\Security\Core\Exception\TokenNotFoundException; class PreserveOrderTokenUponRedirectionCallback { diff --git a/tests/HttpClientStub.php b/tests/HttpClientStub.php index 758d4481..3e62e995 100644 --- a/tests/HttpClientStub.php +++ b/tests/HttpClientStub.php @@ -37,7 +37,7 @@ public function requestJson( Service $service, $requestUrl, $params - ): mixed { + ): mixed { if (null !== self::$jsonHandler) { return call_user_func(static::$jsonHandler, $service, $requestUrl, $params); } From 0c238795369b51854481bced247cff642c1a0641 Mon Sep 17 00:00:00 2001 From: Rafal Malenta Date: Thu, 13 Apr 2023 09:00:37 +0200 Subject: [PATCH 39/44] Removed psalm suppress, adde property to constructor. --- .../PaymentResponseProcessor/FallbackResponseProcessor.php | 7 +++---- src/Resources/config/services/processors.xml | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/Processor/PaymentResponseProcessor/FallbackResponseProcessor.php b/src/Processor/PaymentResponseProcessor/FallbackResponseProcessor.php index 7b1b9973..272ec89f 100644 --- a/src/Processor/PaymentResponseProcessor/FallbackResponseProcessor.php +++ b/src/Processor/PaymentResponseProcessor/FallbackResponseProcessor.php @@ -13,10 +13,8 @@ use Sylius\Component\Core\Model\PaymentInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; +use Symfony\Contracts\Translation\TranslatorInterface; -/** - * @psalm-suppress PropertyNotSetInConstructor - */ final class FallbackResponseProcessor extends AbstractProcessor { public const REDIRECT_TARGET_ACTION = 'bitbag_adyen_thank_you'; @@ -24,9 +22,10 @@ final class FallbackResponseProcessor extends AbstractProcessor /** @var UrlGeneratorInterface */ private $urlGenerator; - public function __construct(UrlGeneratorInterface $urlGenerator) + public function __construct(UrlGeneratorInterface $urlGenerator, TranslatorInterface $translator) { $this->urlGenerator = $urlGenerator; + $this->translator = $translator; } public function accepts(Request $request, ?PaymentInterface $payment): bool diff --git a/src/Resources/config/services/processors.xml b/src/Resources/config/services/processors.xml index c966eaaa..6f2e5a8f 100644 --- a/src/Resources/config/services/processors.xml +++ b/src/Resources/config/services/processors.xml @@ -52,7 +52,7 @@ id="bitbag.sylius_adyen_plugin.processor.payment_response_processor.fallback_response_processor" > - + From d6f2cc25375753eccc1a1f45a96b23bc7ab6821a Mon Sep 17 00:00:00 2001 From: Rafal Malenta Date: Thu, 13 Apr 2023 09:09:02 +0200 Subject: [PATCH 40/44] Updated readme --- README.md | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 616957df..ca0f9585 100644 --- a/README.md +++ b/README.md @@ -85,15 +85,15 @@ This **open-source plugin was developed to help the Sylius community** and make We work on stable, supported and up-to-date versions of packages. We recommend you to do the same. -| Package | Version | -| --- | --- | -| PHP | ^7.4 or ^8.0 | -| ext-json: | * | -| sylius/refund-plugin | ^1.0.0| -| sylius/resource-bundle | ^1.8 | -| sylius/sylius | ^1.10.0 or ^1.11.0 | -| symfony/messenger | ^4.4 | -| adyen/php-api-library | ^10.1 | +| Package | Version | +| --- |--------------------| +| PHP | ^8.0 | +| ext-json: | * | +| sylius/refund-plugin | ^1.0.0 | +| sylius/resource-bundle | ^1.8 | +| sylius/sylius | ^1.11.0 or ^1.12.0 | +| symfony/messenger | ^5.4 | +| adyen/php-api-library | ^10.1 | ---- @@ -155,6 +155,8 @@ $ cd tests/Application $ bin/console assets:install -e test $ bin/console doctrine:database:create -e test $ bin/console doctrine:schema:create -e test +$ yarn install +$ yarn encore dev $ bin/console server:run 127.0.0.1:8080 -e test $ bin/phpunit $ bin/behat From b015143b0fab412752caf7ce375ad116831b977b Mon Sep 17 00:00:00 2001 From: Rafal Malenta Date: Sun, 16 Apr 2023 10:32:27 +0200 Subject: [PATCH 41/44] Removed property --- src/Bus/Dispatcher.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/Bus/Dispatcher.php b/src/Bus/Dispatcher.php index aac898e4..d35b8d33 100644 --- a/src/Bus/Dispatcher.php +++ b/src/Bus/Dispatcher.php @@ -17,9 +17,6 @@ final class Dispatcher implements DispatcherInterface { use HandleTrait; - /** @var MessageBusInterface */ - private $messageBus; - /** @var PaymentCommandFactoryInterface */ private $commandFactory; From 5f68edba6e559fa0f954af6d5ee50cbdbd44e866 Mon Sep 17 00:00:00 2001 From: Rafal Malenta Date: Mon, 17 Apr 2023 08:16:27 +0200 Subject: [PATCH 42/44] Removed webpack setup which was unnecessary --- src/Resources/assets/admin/entry.js | 2 - src/Resources/assets/admin/js/index.js | 0 src/Resources/assets/admin/scss/main.scss | 0 src/Resources/assets/shop/entry.js | 2 - src/Resources/assets/shop/js/index.js | 0 src/Resources/assets/shop/scss/main.scss | 0 .../config/packages/webpack_encore.yaml | 2 - .../Layout/_scripts.html.twig | 2 - .../Layout/_styles.html.twig | 2 - .../SyliusShopBundle/_scripts.html.twig | 2 - .../SyliusShopBundle/_styles.html.twig | 2 - tests/Application/webpack.config.js | 9 +++-- webpack.config.js | 38 ------------------- 13 files changed, 5 insertions(+), 56 deletions(-) delete mode 100644 src/Resources/assets/admin/entry.js delete mode 100644 src/Resources/assets/admin/js/index.js delete mode 100644 src/Resources/assets/admin/scss/main.scss delete mode 100644 src/Resources/assets/shop/entry.js delete mode 100644 src/Resources/assets/shop/js/index.js delete mode 100644 src/Resources/assets/shop/scss/main.scss delete mode 100644 tests/Application/templates/bundles/SyliusAdminBundle/Layout/_scripts.html.twig delete mode 100644 tests/Application/templates/bundles/SyliusAdminBundle/Layout/_styles.html.twig delete mode 100644 tests/Application/templates/bundles/SyliusShopBundle/_scripts.html.twig delete mode 100644 tests/Application/templates/bundles/SyliusShopBundle/_styles.html.twig delete mode 100644 webpack.config.js diff --git a/src/Resources/assets/admin/entry.js b/src/Resources/assets/admin/entry.js deleted file mode 100644 index f3cf7505..00000000 --- a/src/Resources/assets/admin/entry.js +++ /dev/null @@ -1,2 +0,0 @@ -import './js'; -import './scss/main.scss'; diff --git a/src/Resources/assets/admin/js/index.js b/src/Resources/assets/admin/js/index.js deleted file mode 100644 index e69de29b..00000000 diff --git a/src/Resources/assets/admin/scss/main.scss b/src/Resources/assets/admin/scss/main.scss deleted file mode 100644 index e69de29b..00000000 diff --git a/src/Resources/assets/shop/entry.js b/src/Resources/assets/shop/entry.js deleted file mode 100644 index f3cf7505..00000000 --- a/src/Resources/assets/shop/entry.js +++ /dev/null @@ -1,2 +0,0 @@ -import './js'; -import './scss/main.scss'; diff --git a/src/Resources/assets/shop/js/index.js b/src/Resources/assets/shop/js/index.js deleted file mode 100644 index e69de29b..00000000 diff --git a/src/Resources/assets/shop/scss/main.scss b/src/Resources/assets/shop/scss/main.scss deleted file mode 100644 index e69de29b..00000000 diff --git a/tests/Application/config/packages/webpack_encore.yaml b/tests/Application/config/packages/webpack_encore.yaml index d03a2206..9bee2488 100644 --- a/tests/Application/config/packages/webpack_encore.yaml +++ b/tests/Application/config/packages/webpack_encore.yaml @@ -3,5 +3,3 @@ webpack_encore: builds: shop: '%kernel.project_dir%/public/build/shop' admin: '%kernel.project_dir%/public/build/admin' - cs_shop: '%kernel.project_dir%/public/build/bitbag/cs/shop' - cs_admin: '%kernel.project_dir%/public/build/bitbag/cs/admin' diff --git a/tests/Application/templates/bundles/SyliusAdminBundle/Layout/_scripts.html.twig b/tests/Application/templates/bundles/SyliusAdminBundle/Layout/_scripts.html.twig deleted file mode 100644 index d8212270..00000000 --- a/tests/Application/templates/bundles/SyliusAdminBundle/Layout/_scripts.html.twig +++ /dev/null @@ -1,2 +0,0 @@ -{{ encore_entry_script_tags('admin-entry', null, 'admin') }} -{{ encore_entry_script_tags('bitbag-cs-admin', null, 'cs_admin') }} diff --git a/tests/Application/templates/bundles/SyliusAdminBundle/Layout/_styles.html.twig b/tests/Application/templates/bundles/SyliusAdminBundle/Layout/_styles.html.twig deleted file mode 100644 index 798aadb2..00000000 --- a/tests/Application/templates/bundles/SyliusAdminBundle/Layout/_styles.html.twig +++ /dev/null @@ -1,2 +0,0 @@ -{{ encore_entry_link_tags('admin-entry', null, 'admin') }} -{{ encore_entry_link_tags('bitbag-cs-admin', null, 'cs_admin') }} diff --git a/tests/Application/templates/bundles/SyliusShopBundle/_scripts.html.twig b/tests/Application/templates/bundles/SyliusShopBundle/_scripts.html.twig deleted file mode 100644 index 1b22dbc7..00000000 --- a/tests/Application/templates/bundles/SyliusShopBundle/_scripts.html.twig +++ /dev/null @@ -1,2 +0,0 @@ -{{ encore_entry_script_tags('shop-entry', null, 'shop') }} -{{ encore_entry_script_tags('bitbag-cs-shop', null, 'cs_shop') }} diff --git a/tests/Application/templates/bundles/SyliusShopBundle/_styles.html.twig b/tests/Application/templates/bundles/SyliusShopBundle/_styles.html.twig deleted file mode 100644 index 87fab0e5..00000000 --- a/tests/Application/templates/bundles/SyliusShopBundle/_styles.html.twig +++ /dev/null @@ -1,2 +0,0 @@ -{{ encore_entry_link_tags('shop-entry', null, 'shop') }} -{{ encore_entry_link_tags('bitbag-cs-shop', null, 'cs_shop') }} diff --git a/tests/Application/webpack.config.js b/tests/Application/webpack.config.js index 2ad84c38..91d756a2 100644 --- a/tests/Application/webpack.config.js +++ b/tests/Application/webpack.config.js @@ -1,13 +1,13 @@ const path = require('path'); const Encore = require('@symfony/webpack-encore'); -const [bitbagCsShop, bitbagCsAdmin] = require('../../webpack.config.js'); const syliusBundles = path.resolve(__dirname, '../../vendor/sylius/sylius/src/Sylius/Bundle/'); const uiBundleScripts = path.resolve(syliusBundles, 'UiBundle/Resources/private/js/'); const uiBundleResources = path.resolve(syliusBundles, 'UiBundle/Resources/private/'); // Shop config -Encore.setOutputPath('public/build/shop/') +Encore + .setOutputPath('public/build/shop/') .setPublicPath('/build/shop') .addEntry('shop-entry', './assets/shop/entry.js') .disableSingleRuntimeChunk() @@ -26,7 +26,8 @@ shopConfig.name = 'shop'; Encore.reset(); // Admin config -Encore.setOutputPath('public/build/admin/') +Encore + .setOutputPath('public/build/admin/') .setPublicPath('/build/admin') .addEntry('admin-entry', './assets/admin/entry.js') .disableSingleRuntimeChunk() @@ -45,4 +46,4 @@ adminConfig.externals = Object.assign({}, adminConfig.externals, {window: 'windo adminConfig.name = 'admin'; -module.exports = [shopConfig, adminConfig, bitbagCsShop, bitbagCsAdmin]; +module.exports = [shopConfig, adminConfig]; diff --git a/webpack.config.js b/webpack.config.js deleted file mode 100644 index 943ae658..00000000 --- a/webpack.config.js +++ /dev/null @@ -1,38 +0,0 @@ -const path = require('path'); -const Encore = require('@symfony/webpack-encore'); -const pluginName = 'cs'; - -const getConfig = (pluginName, type) => { - Encore.reset(); - - Encore.setOutputPath(`public/build/bitbag/${pluginName}/${type}/`) - .setPublicPath(`/build/bitbag/${pluginName}/${type}/`) - .addEntry(`bitbag-${pluginName}-${type}`, path.resolve(__dirname, `./src/Resources/assets/${type}/entry.js`)) - .disableSingleRuntimeChunk() - .cleanupOutputBeforeBuild() - .enableSourceMaps(!Encore.isProduction()) - .enableSassLoader(); - - const config = Encore.getWebpackConfig(); - config.name = `bitbag-${pluginName}-${type}`; - - return config; -}; - -Encore.setOutputPath(`src/Resources/public/build/`) - .setPublicPath(`/public/build/`) - .addEntry(`bitbag-${pluginName}-shop`, path.resolve(__dirname, `./src/Resources/assets/shop/entry.js`)) - .addEntry(`bitbag-${pluginName}-admin`, path.resolve(__dirname, `./src/Resources/assets/admin/entry.js`)) - .cleanupOutputBeforeBuild() - .disableSingleRuntimeChunk() - .enableSassLoader(); - -const distConfig = Encore.getWebpackConfig(); -distConfig.name = `bitbag-plugin-dist`; - -Encore.reset(); - -const shopConfig = getConfig(pluginName, 'shop'); -const adminConfig = getConfig(pluginName, 'admin'); - -module.exports = [shopConfig, adminConfig, distConfig]; From 820f42a586f5487ff2a377ff40ca2a3cf812b415 Mon Sep 17 00:00:00 2001 From: Rafal Malenta Date: Mon, 17 Apr 2023 09:00:36 +0200 Subject: [PATCH 43/44] Updated installation guide --- doc/installation.md | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/doc/installation.md b/doc/installation.md index b9b200cc..3c9cf506 100644 --- a/doc/installation.md +++ b/doc/installation.md @@ -58,7 +58,15 @@ monolog: - adyen ``` -8. Copy Sylius templates overridden by plug-in to your templates directory (`templates/bundles/`): +8. Configure config/packages/webpack_encore.yaml +```yaml + builds: + *: * + shop: '%kernel.project_dir%/public/build/shop' + admin: '%kernel.project_dir%/public/build/admin' +``` + +9. Copy Sylius templates overridden by plug-in to your templates directory (`templates/bundles/`): ``` mkdir -p templates/bundles/SyliusAdminBundle/ @@ -68,19 +76,19 @@ cp -R vendor/bitbag/sylius-adyen-plugin/tests/Application/templates/bundles/Syli cp -R vendor/bitbag/sylius-adyen-plugin/tests/Application/templates/bundles/SyliusShopBundle/* templates/bundles/SyliusShopBundle/ ``` -9. Execute migrations +10. Execute migrations ``` bin/console doctrine:migrations:migrate ``` -10. Install assets +11. Install assets ``` bin/console assets:install ``` -11. Clear cache +12. Clear cache ``` bin/console cache:clear @@ -88,7 +96,7 @@ bin/console cache:clear **Note:** If you are running it on production, add the `-e prod` flag to this command. -12. [Obtain Adyen credentials and configure the payment method](configuration.md) +13. [Obtain Adyen credentials and configure the payment method](configuration.md) -13. If you want to access the log page, visit /adyen/log. +14. If you want to access the log page, visit /adyen/log. From c40e75f1167f99eabe5883a5e041b084a772c3f3 Mon Sep 17 00:00:00 2001 From: Rafal Malenta Date: Mon, 17 Apr 2023 10:21:36 +0200 Subject: [PATCH 44/44] Added refund class --- src/Resources/config/sylius/state_machine.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Resources/config/sylius/state_machine.yml b/src/Resources/config/sylius/state_machine.yml index e5cb5d1a..50b994a0 100644 --- a/src/Resources/config/sylius/state_machine.yml +++ b/src/Resources/config/sylius/state_machine.yml @@ -26,6 +26,7 @@ winzou_state_machine: from: [awaiting_payment, partially_paid, authorized, processing] sylius_refund_refund_payment: + class: Sylius\RefundPlugin\Entity\RefundPayment transitions: confirm: from: [new]