diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8386795..ed85ea5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -14,23 +14,22 @@ on: jobs: tests: - runs-on: ubuntu-22.04 - + runs-on: ubuntu-latest + name: "Sylius ${{ matrix.sylius }}, PHP ${{ matrix.php }}, Symfony ${{ matrix.symfony }}, MySQL ${{ matrix.mysql }}" - + strategy: fail-fast: false matrix: - php: [8.0] + php: [8.0, 8.1, 8.2, 8.3] symfony: [^5.4, ^6.0] - sylius: [~1.11.0, ~1.12.0] - node: [14.19] + sylius: [~1.12.0, ~1.13.0] + node: [18.x, 20.x] mysql: [5.7, 8.0] - + exclude: - - - sylius: ~1.11.0 - symfony: ^6.0 + - sylius: "~1.13.0" + php: "8.0" env: APP_ENV: test @@ -38,7 +37,7 @@ jobs: steps: - - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Setup PHP @@ -51,7 +50,7 @@ jobs: - name: Setup Node - uses: actions/setup-node@v1 + uses: actions/setup-node@v4 with: node-version: "${{ matrix.node }}" @@ -135,7 +134,7 @@ jobs: name: Prepare test application database run: | (cd tests/Application && bin/console doctrine:database:create -vvv) - (cd tests/Application && bin/console doctrine:schema:create -vvv) + (cd tests/Application && bin/console doctrine:schema:create -vvv) - name: Prepare test application assets @@ -161,7 +160,7 @@ jobs: - name: Run PHPStan - run: vendor/bin/phpstan analyse -c phpstan.neon -l max src/ + run: vendor/bin/phpstan analyse -c phpstan.neon -l 8 src/ # TODO: Temporary disabled! # - diff --git a/composer.json b/composer.json index 1eec631..996d680 100644 --- a/composer.json +++ b/composer.json @@ -6,13 +6,13 @@ "require": { "php": "^8.0", "doctrine/dbal": "^2.7 || ^3.0", - "sylius/sylius": "~1.11.0 || ~1.12.0" + "sylius/sylius": "~1.12.0 || ~1.13.0" }, "require-dev": { - "behat/behat": "^3.6.1", + "behat/behat": "^3.7", + "behat/mink-selenium2-driver": "~1.6.0", "symfony/webpack-encore-bundle": "^1.15", "bitbag/coding-standard": "^1.0.1 || ^2.0.0", - "behat/mink-selenium2-driver": "^1.4", "dmore/behat-chrome-extension": "^1.3", "dmore/chrome-mink-driver": "^2.7", "friends-of-behat/mink": "^1.8", @@ -25,10 +25,10 @@ "friends-of-behat/variadic-extension": "^1.3", "phpspec/phpspec": "^7.0", "phpstan/extension-installer": "^1.0", - "phpstan/phpstan": "0.12.85 || ^1.4", - "phpstan/phpstan-doctrine": "0.12.33", - "phpstan/phpstan-strict-rules": "^0.12.0 || ^1.0", - "phpstan/phpstan-webmozart-assert": "0.12.12 || ^1.0", + "phpstan/phpstan": "^1.8.1", + "phpstan/phpstan-doctrine": "1.3.69", + "phpstan/phpstan-strict-rules": "^1.3.0", + "phpstan/phpstan-webmozart-assert": "^1.2.0", "phpunit/phpunit": "^9.5", "sylius-labs/coding-standard": "^4.0", "symfony/browser-kit": "^5.4 || ^6.0", @@ -40,7 +40,7 @@ "polishsymfonycommunity/symfony-mocker-container": "^1.0" }, "conflict": { - "behat/mink-selenium2-driver": ">=1.7.0" + "doctrine/persistence": "<3.0" }, "config": { "sort-packages": true, diff --git a/features/exporting_shipping_data_to_api.feature b/features/exporting_shipping_data_to_api.feature index 8d84371..fd452e7 100644 --- a/features/exporting_shipping_data_to_api.feature +++ b/features/exporting_shipping_data_to_api.feature @@ -11,7 +11,7 @@ Feature: Managing shipping gateway And there is a registered "frank_martin_shipping_gateway" shipping gateway for this shipping method named "Transporter Gateway" And it has "IBAN" field set to "GB29 RBOS 6016 1331 9268 19" And it has "Address" field set to "Nick King, Main Square 27, Opole 45015, Poland" - And the store has a product "Chicken" priced at "$2" in "Web-US" channel + And the store has a product "Chicken" priced at "$2.00" in "Web-US" channel And customer "mikolaj.krol@bitbag.pl" has placed 5 orders on the "Web-US" channel in each buying 5 "Chicken" products And those orders were placed with "Frank Martin Parcels" shipping method diff --git a/features/placing_an_order_for_shipping_gateway.feature b/features/placing_an_order_for_shipping_gateway.feature index 40db7a1..e206bc9 100644 --- a/features/placing_an_order_for_shipping_gateway.feature +++ b/features/placing_an_order_for_shipping_gateway.feature @@ -6,7 +6,7 @@ Feature: Preparing shipping export after processing order with shipping gateway Background: Given the store operates on a single channel in "United States" - And the store has a product "Ferrari Testarossa" priced at "$250000.00" + And the store has a product "Ferrari Testarossa" priced at "$250,000.00" And the store has "Frank Martin Parcels" shipping method with "$10.00" fee And there is a registered "frank_martin_shipping_gateway" shipping gateway for this shipping method named "Transporter Gateway" And the store allows paying "Cash on Delivery" diff --git a/phpstan.neon b/phpstan.neon index 9fa76d1..82e343c 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,9 +1,10 @@ parameters: - reportUnmatchedIgnoredErrors: false - checkMissingIterableValueType: false - checkGenericClassInNonGenericObjectType: false + level: 8 - excludes_analyse: + paths: + - src + + excludePaths: # Makes PHPStan crash - 'src/DependencyInjection/Configuration.php' @@ -12,6 +13,5 @@ parameters: - 'tests/Application/src/**.php' 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\./' - - '/Cannot call method [a-z]+Node\(\) on Symfony\\Component\\Config\\Definition\\Builder\\NodeParentInterface\|null\./' - + - identifier: missingType.iterableValue + - identifier: missingType.generics diff --git a/src/Repository/ShippingGatewayRepositoryInterface.php b/src/Repository/ShippingGatewayRepositoryInterface.php index 110d0be..02a4a11 100644 --- a/src/Repository/ShippingGatewayRepositoryInterface.php +++ b/src/Repository/ShippingGatewayRepositoryInterface.php @@ -12,7 +12,6 @@ use BitBag\SyliusShippingExportPlugin\Entity\ShippingGatewayInterface; use Doctrine\ORM\QueryBuilder; -use Doctrine\Persistence\ObjectRepository; use Sylius\Component\Resource\Model\ResourceInterface; use Sylius\Component\Resource\Repository\RepositoryInterface; use Sylius\Component\Shipping\Model\ShippingMethodInterface; diff --git a/tests/Application/Kernel.php b/tests/Application/Kernel.php index 15db127..c660c95 100644 --- a/tests/Application/Kernel.php +++ b/tests/Application/Kernel.php @@ -13,7 +13,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 { @@ -104,7 +103,6 @@ private function registerBundlesFromFile(string $bundlesFile): iterable foreach ($contents as $class => $envs) { if (isset($envs['all']) || isset($envs[$this->environment])) { yield new $class(); - } } } diff --git a/tests/Application/config/bootstrap.php b/tests/Application/config/bootstrap.php index ae509ac..2291ab4 100644 --- a/tests/Application/config/bootstrap.php +++ b/tests/Application/config/bootstrap.php @@ -4,7 +4,7 @@ use Symfony\Component\Dotenv\Dotenv; -require dirname(__DIR__).'../../../vendor/autoload.php'; +require dirname(__DIR__) . '../../../vendor/autoload.php'; // Load cached env vars if the .env.local.php file exists // Run "composer dump-env prod" to create it (requires symfony/flex >=1.2) diff --git a/tests/Application/config/bundles.php b/tests/Application/config/bundles.php index ac59ec5..35b3ef0 100644 --- a/tests/Application/config/bundles.php +++ b/tests/Application/config/bundles.php @@ -6,6 +6,8 @@ * We are hiring developers from all over the world. Join us and start your new, exciting adventure and become part of us: https://bitbag.io/career */ +declare(strict_types=1); + return [ Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true], Symfony\Bundle\MonologBundle\MonologBundle::class => ['all' => true], @@ -59,5 +61,5 @@ Lexik\Bundle\JWTAuthenticationBundle\LexikJWTAuthenticationBundle::class => ['all' => true], Sylius\Bundle\ApiBundle\SyliusApiBundle::class => ['all' => true], SyliusLabs\DoctrineMigrationsExtraBundle\SyliusLabsDoctrineMigrationsExtraBundle::class => ['all' => true], - Symfony\WebpackEncoreBundle\WebpackEncoreBundle::class => ['all'=> true], + Symfony\WebpackEncoreBundle\WebpackEncoreBundle::class => ['all' => true], ]; diff --git a/tests/Application/config/sylius/1.11/packages/dev/jms_serializer.yaml b/tests/Application/config/sylius/1.11/packages/dev/jms_serializer.yaml deleted file mode 100644 index 2f32a9b..0000000 --- a/tests/Application/config/sylius/1.11/packages/dev/jms_serializer.yaml +++ /dev/null @@ -1,12 +0,0 @@ -jms_serializer: - visitors: - json_serialization: - options: - - JSON_PRETTY_PRINT - - JSON_UNESCAPED_SLASHES - - JSON_PRESERVE_ZERO_FRACTION - json_deserialization: - options: - - JSON_PRETTY_PRINT - - JSON_UNESCAPED_SLASHES - - JSON_PRESERVE_ZERO_FRACTION diff --git a/tests/Application/config/sylius/1.11/packages/dev/swiftmailer.yaml b/tests/Application/config/sylius/1.11/packages/dev/swiftmailer.yaml deleted file mode 100644 index f438078..0000000 --- a/tests/Application/config/sylius/1.11/packages/dev/swiftmailer.yaml +++ /dev/null @@ -1,2 +0,0 @@ -swiftmailer: - disable_delivery: true diff --git a/tests/Application/config/sylius/1.11/packages/jms_serializer.yaml b/tests/Application/config/sylius/1.11/packages/jms_serializer.yaml deleted file mode 100644 index ed7bc61..0000000 --- a/tests/Application/config/sylius/1.11/packages/jms_serializer.yaml +++ /dev/null @@ -1,4 +0,0 @@ -jms_serializer: - visitors: - xml_serialization: - format_output: '%kernel.debug%' diff --git a/tests/Application/config/sylius/1.11/packages/prod/jms_serializer.yaml b/tests/Application/config/sylius/1.11/packages/prod/jms_serializer.yaml deleted file mode 100644 index c288182..0000000 --- a/tests/Application/config/sylius/1.11/packages/prod/jms_serializer.yaml +++ /dev/null @@ -1,10 +0,0 @@ -jms_serializer: - visitors: - json_serialization: - options: - - JSON_UNESCAPED_SLASHES - - JSON_PRESERVE_ZERO_FRACTION - json_deserialization: - options: - - JSON_UNESCAPED_SLASHES - - JSON_PRESERVE_ZERO_FRACTION diff --git a/tests/Application/config/sylius/1.11/packages/security.yaml b/tests/Application/config/sylius/1.11/packages/security.yaml deleted file mode 100644 index 1062810..0000000 --- a/tests/Application/config/sylius/1.11/packages/security.yaml +++ /dev/null @@ -1,148 +0,0 @@ -parameters: - sylius.security.admin_regex: "^/%sylius_admin.path_name%" - sylius.security.api_regex: "^/api" - sylius.security.shop_regex: "^/(?!%sylius_admin.path_name%|new-api|api/.*|api$|media/.*)[^/]++" - sylius.security.new_api_route: "/new-api" - sylius.security.new_api_regex: "^%sylius.security.new_api_route%" - sylius.security.new_api_admin_route: "%sylius.security.new_api_route%/admin" - sylius.security.new_api_admin_regex: "^%sylius.security.new_api_admin_route%" - sylius.security.new_api_shop_route: "%sylius.security.new_api_route%/shop" - sylius.security.new_api_shop_regex: "^%sylius.security.new_api_shop_route%" - -security: - always_authenticate_before_granting: true - providers: - sylius_admin_user_provider: - id: sylius.admin_user_provider.email_or_name_based - sylius_api_admin_user_provider: - id: sylius.admin_user_provider.email_or_name_based - sylius_shop_user_provider: - id: sylius.shop_user_provider.email_or_name_based - sylius_api_shop_user_provider: - id: sylius.shop_user_provider.email_or_name_based - sylius_api_chain_provider: - chain: - providers: [sylius_api_shop_user_provider, sylius_api_admin_user_provider] - - encoders: - Sylius\Component\User\Model\UserInterface: argon2i - firewalls: - admin: - switch_user: true - context: admin - pattern: "%sylius.security.admin_regex%" - provider: sylius_admin_user_provider - form_login: - provider: sylius_admin_user_provider - login_path: sylius_admin_login - check_path: sylius_admin_login_check - failure_path: sylius_admin_login - default_target_path: sylius_admin_dashboard - use_forward: false - use_referer: true - csrf_token_generator: security.csrf.token_manager - csrf_parameter: _csrf_admin_security_token - csrf_token_id: admin_authenticate - remember_me: - secret: "%env(APP_SECRET)%" - path: "/%sylius_admin.path_name%" - name: APP_ADMIN_REMEMBER_ME - lifetime: 31536000 - remember_me_parameter: _remember_me - logout: - path: sylius_admin_logout - target: sylius_admin_login - anonymous: true - - new_api_admin_user: - pattern: "%sylius.security.new_api_route%/admin-user-authentication-token" - provider: sylius_admin_user_provider - stateless: true - anonymous: true - json_login: - check_path: "%sylius.security.new_api_route%/admin-user-authentication-token" - username_path: email - password_path: password - success_handler: lexik_jwt_authentication.handler.authentication_success - failure_handler: lexik_jwt_authentication.handler.authentication_failure - guard: - authenticators: - - lexik_jwt_authentication.jwt_token_authenticator - - new_api_shop_user: - pattern: "%sylius.security.new_api_route%/shop-user-authentication-token" - provider: sylius_shop_user_provider - stateless: true - anonymous: true - json_login: - check_path: "%sylius.security.new_api_route%/shop-user-authentication-token" - username_path: email - password_path: password - success_handler: lexik_jwt_authentication.handler.authentication_success - failure_handler: lexik_jwt_authentication.handler.authentication_failure - guard: - authenticators: - - lexik_jwt_authentication.jwt_token_authenticator - - new_api: - pattern: "%sylius.security.new_api_regex%/*" - provider: sylius_api_chain_provider - stateless: true - anonymous: lazy - guard: - authenticators: - - lexik_jwt_authentication.jwt_token_authenticator - - shop: - switch_user: { role: ROLE_ALLOWED_TO_SWITCH } - context: shop - pattern: "%sylius.security.shop_regex%" - provider: sylius_shop_user_provider - form_login: - success_handler: sylius.authentication.success_handler - failure_handler: sylius.authentication.failure_handler - provider: sylius_shop_user_provider - login_path: sylius_shop_login - check_path: sylius_shop_login_check - failure_path: sylius_shop_login - default_target_path: sylius_shop_homepage - use_forward: false - use_referer: true - csrf_token_generator: security.csrf.token_manager - csrf_parameter: _csrf_shop_security_token - csrf_token_id: shop_authenticate - remember_me: - secret: "%env(APP_SECRET)%" - name: APP_SHOP_REMEMBER_ME - lifetime: 31536000 - remember_me_parameter: _remember_me - logout: - path: sylius_shop_logout - target: sylius_shop_login - invalidate_session: false - success_handler: sylius.handler.shop_user_logout - anonymous: true - - dev: - pattern: ^/(_(profiler|wdt)|css|images|js)/ - security: false - - access_control: - - { path: "%sylius.security.admin_regex%/_partial", role: IS_AUTHENTICATED_ANONYMOUSLY, ips: [127.0.0.1, ::1] } - - { path: "%sylius.security.admin_regex%/_partial", role: ROLE_NO_ACCESS } - - { path: "%sylius.security.shop_regex%/_partial", role: IS_AUTHENTICATED_ANONYMOUSLY, ips: [127.0.0.1, ::1] } - - { path: "%sylius.security.shop_regex%/_partial", role: ROLE_NO_ACCESS } - - - { path: "%sylius.security.admin_regex%/login", role: IS_AUTHENTICATED_ANONYMOUSLY } - - { path: "%sylius.security.api_regex%/login", role: IS_AUTHENTICATED_ANONYMOUSLY } - - { path: "%sylius.security.shop_regex%/login", role: IS_AUTHENTICATED_ANONYMOUSLY } - - - { path: "%sylius.security.shop_regex%/register", role: IS_AUTHENTICATED_ANONYMOUSLY } - - { path: "%sylius.security.shop_regex%/verify", role: IS_AUTHENTICATED_ANONYMOUSLY } - - - { path: "%sylius.security.admin_regex%", role: ROLE_ADMINISTRATION_ACCESS } - - { path: "%sylius.security.api_regex%/.*", role: ROLE_API_ACCESS } - - { path: "%sylius.security.shop_regex%/account", role: ROLE_USER } - - - { path: "%sylius.security.new_api_admin_regex%/.*", role: ROLE_API_ACCESS } - - { path: "%sylius.security.new_api_shop_regex%/.*", role: IS_AUTHENTICATED_ANONYMOUSLY } diff --git a/tests/Application/config/sylius/1.11/packages/staging/swiftmailer.yaml b/tests/Application/config/sylius/1.11/packages/staging/swiftmailer.yaml deleted file mode 100644 index f438078..0000000 --- a/tests/Application/config/sylius/1.11/packages/staging/swiftmailer.yaml +++ /dev/null @@ -1,2 +0,0 @@ -swiftmailer: - disable_delivery: true diff --git a/tests/Application/config/sylius/1.11/packages/swiftmailer.yaml b/tests/Application/config/sylius/1.11/packages/swiftmailer.yaml deleted file mode 100644 index 3bab0d3..0000000 --- a/tests/Application/config/sylius/1.11/packages/swiftmailer.yaml +++ /dev/null @@ -1,2 +0,0 @@ -swiftmailer: - url: '%env(MAILER_URL)%' diff --git a/tests/Application/config/sylius/1.11/packages/test/security.yaml b/tests/Application/config/sylius/1.11/packages/test/security.yaml deleted file mode 100644 index 21cc377..0000000 --- a/tests/Application/config/sylius/1.11/packages/test/security.yaml +++ /dev/null @@ -1,3 +0,0 @@ -security: - encoders: - sha512: sha512 diff --git a/tests/Application/config/sylius/1.11/packages/test/swiftmailer.yaml b/tests/Application/config/sylius/1.11/packages/test/swiftmailer.yaml deleted file mode 100644 index c438f4b..0000000 --- a/tests/Application/config/sylius/1.11/packages/test/swiftmailer.yaml +++ /dev/null @@ -1,6 +0,0 @@ -swiftmailer: - disable_delivery: true - logging: true - spool: - type: file - path: "%kernel.cache_dir%/spool" diff --git a/tests/Application/config/sylius/1.11/packages/test_cached/swiftmailer.yaml b/tests/Application/config/sylius/1.11/packages/test_cached/swiftmailer.yaml deleted file mode 100644 index c438f4b..0000000 --- a/tests/Application/config/sylius/1.11/packages/test_cached/swiftmailer.yaml +++ /dev/null @@ -1,6 +0,0 @@ -swiftmailer: - disable_delivery: true - logging: true - spool: - type: file - path: "%kernel.cache_dir%/spool" diff --git a/tests/Application/config/sylius/1.12/bundles.php b/tests/Application/config/sylius/1.12/bundles.php index 448fd5e..1ad7d83 100644 --- a/tests/Application/config/sylius/1.12/bundles.php +++ b/tests/Application/config/sylius/1.12/bundles.php @@ -6,8 +6,10 @@ * We are hiring developers from all over the world. Join us and start your new, exciting adventure and become part of us: https://bitbag.io/career */ +declare(strict_types=1); + return [ - League\FlysystemBundle\FlysystemBundle::class => ['all'=> true], + League\FlysystemBundle\FlysystemBundle::class => ['all' => true], Sylius\Calendar\SyliusCalendarBundle::class => ['all' => true], - BabDev\PagerfantaBundle\BabDevPagerfantaBundle::class => ['all' => true] + BabDev\PagerfantaBundle\BabDevPagerfantaBundle::class => ['all' => true], ]; diff --git a/tests/Application/config/sylius/1.11/bundles.php b/tests/Application/config/sylius/1.13/bundles.php similarity index 70% rename from tests/Application/config/sylius/1.11/bundles.php rename to tests/Application/config/sylius/1.13/bundles.php index f202ab5..5f82527 100644 --- a/tests/Application/config/sylius/1.11/bundles.php +++ b/tests/Application/config/sylius/1.13/bundles.php @@ -6,9 +6,11 @@ * We are hiring developers from all over the world. Join us and start your new, exciting adventure and become part of us: https://bitbag.io/career */ +declare(strict_types=1); + return [ - BabDev\PagerfantaBundle\BabDevPagerfantaBundle::class => ['all' => true], - SyliusLabs\Polyfill\Symfony\Security\Bundle\SyliusLabsPolyfillSymfonySecurityBundle::class => ['all' => true], + League\FlysystemBundle\FlysystemBundle::class => ['all' => true], Sylius\Calendar\SyliusCalendarBundle::class => ['all' => true], - Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle::class => ['all' => true], + BabDev\PagerfantaBundle\BabDevPagerfantaBundle::class => ['all' => true], + Sylius\Abstraction\StateMachine\SyliusStateMachineAbstractionBundle::class => ['all' => true], ]; diff --git a/tests/Application/config/sylius/1.13/packages/mailer.yaml b/tests/Application/config/sylius/1.13/packages/mailer.yaml new file mode 100644 index 0000000..0a0697c --- /dev/null +++ b/tests/Application/config/sylius/1.13/packages/mailer.yaml @@ -0,0 +1,3 @@ +framework: + mailer: + dsn: '%env(MAILER_DSN)%' diff --git a/tests/Application/config/sylius/1.13/packages/security.yaml b/tests/Application/config/sylius/1.13/packages/security.yaml new file mode 100644 index 0000000..842b093 --- /dev/null +++ b/tests/Application/config/sylius/1.13/packages/security.yaml @@ -0,0 +1,124 @@ +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 + + image_resolver: + pattern: ^/media/cache/resolve + security: false + + access_control: + - { path: "%sylius.security.admin_regex%/_partial", role: PUBLIC_ACCESS, ips: [127.0.0.1, ::1] } + - { path: "%sylius.security.admin_regex%/_partial", role: ROLE_NO_ACCESS } + - { path: "%sylius.security.shop_regex%/_partial", role: PUBLIC_ACCESS, ips: [127.0.0.1, ::1] } + - { path: "%sylius.security.shop_regex%/_partial", role: ROLE_NO_ACCESS } + + - { path: "%sylius.security.admin_regex%/login", role: PUBLIC_ACCESS } + - { path: "%sylius.security.shop_regex%/login", role: PUBLIC_ACCESS } + + - { path: "%sylius.security.shop_regex%/register", role: PUBLIC_ACCESS } + - { path: "%sylius.security.shop_regex%/verify", role: PUBLIC_ACCESS } + + - { path: "%sylius.security.admin_regex%", role: ROLE_ADMINISTRATION_ACCESS } + - { path: "%sylius.security.shop_regex%/account", role: ROLE_USER } + + - { path: "%sylius.security.new_api_admin_route%/reset-password-requests", role: PUBLIC_ACCESS } + - { path: "%sylius.security.new_api_admin_regex%/.*", role: ROLE_API_ACCESS } + - { path: "%sylius.security.new_api_admin_route%/authentication-token", role: PUBLIC_ACCESS } + - { path: "%sylius.security.new_api_user_account_regex%/.*", role: ROLE_USER } + - { path: "%sylius.security.new_api_shop_route%/authentication-token", role: PUBLIC_ACCESS } + - { path: "%sylius.security.new_api_shop_regex%/.*", role: PUBLIC_ACCESS } diff --git a/tests/Application/config/sylius/1.13/packages/test/mailer.yaml b/tests/Application/config/sylius/1.13/packages/test/mailer.yaml new file mode 100644 index 0000000..56cc28f --- /dev/null +++ b/tests/Application/config/sylius/1.13/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/Behat/Context/Transform/LexicalContext.php b/tests/Behat/Context/Transform/LexicalContext.php new file mode 100644 index 0000000..a5ae24a --- /dev/null +++ b/tests/Behat/Context/Transform/LexicalContext.php @@ -0,0 +1,59 @@ +validatePriceString($price); + + $price = str_replace(',', '', $price); + $price = (int) round((float) $price * 100, 2); + + if ('-' === $sign) { + $price *= -1; + } + + return $price; + } + + /** + * @Transform /^"((?:\d+\.)?\d+)%"$/ + */ + public function getPercentageFromString(string $percentage): float + { + return (float) $percentage / 100; + } + + /** + * @throws \InvalidArgumentException + */ + private function validatePriceString(string $price): void + { + if (!preg_match('/^.*\.\d{2}$/', $price)) { + throw new \InvalidArgumentException('The price string should have exactly 2 decimal digits.'); + } + + if (!preg_match('/^\d{1,3}(,\d{3})*\.\d{2}$/', $price)) { + throw new \InvalidArgumentException('Thousands and larger numbers should be separated by commas.'); + } + } +} diff --git a/tests/Behat/Mock/EventListener/FrankMartinShippingExportEventListener.php b/tests/Behat/Mock/EventListener/FrankMartinShippingExportEventListener.php index 6f9a835..c00f580 100644 --- a/tests/Behat/Mock/EventListener/FrankMartinShippingExportEventListener.php +++ b/tests/Behat/Mock/EventListener/FrankMartinShippingExportEventListener.php @@ -14,7 +14,6 @@ use Doctrine\Persistence\ObjectManager; use Sylius\Bundle\ResourceBundle\Event\ResourceControllerEvent; use Symfony\Component\Filesystem\Filesystem; - use Symfony\Component\HttpFoundation\RequestStack; use Webmozart\Assert\Assert; diff --git a/tests/Behat/Page/Admin/ShippingExport/IndexPageInterface.php b/tests/Behat/Page/Admin/ShippingExport/IndexPageInterface.php index 3f9026f..2052e87 100644 --- a/tests/Behat/Page/Admin/ShippingExport/IndexPageInterface.php +++ b/tests/Behat/Page/Admin/ShippingExport/IndexPageInterface.php @@ -16,8 +16,6 @@ interface IndexPageInterface extends BaseIndexPage { /** - * @param string $state - * * @return ElementInterface[] */ public function getShipmentsWithState(string $state): array; diff --git a/tests/Behat/Resources/services/contexts.yml b/tests/Behat/Resources/services/contexts.yml index 075e85c..4e92430 100644 --- a/tests/Behat/Resources/services/contexts.yml +++ b/tests/Behat/Resources/services/contexts.yml @@ -29,7 +29,10 @@ services: - '@bitbag.factory.shipping_export' - '@bitbag.repository.shipping_export' - "@event_dispatcher" - + + bitbag.behat.context.transform.lexical: + class: Tests\BitBag\SyliusShippingExportPlugin\Behat\Context\Transform\LexicalContext + bitbag.behat.context.ui.admin.shipping_gateway: class: Tests\BitBag\SyliusShippingExportPlugin\Behat\Context\Ui\Admin\ShippingGatewayContext arguments: diff --git a/tests/Behat/Resources/suites.yml b/tests/Behat/Resources/suites.yml index 2bfb50d..79150fb 100644 --- a/tests/Behat/Resources/suites.yml +++ b/tests/Behat/Resources/suites.yml @@ -40,6 +40,8 @@ default: - bitbag.behat.context.setup.shipping_gateway - bitbag.behat.context.setup.shipping_export + - bitbag.behat.context.transform.lexical + - bitbag.behat.context.ui.admin.shipping_gateway - bitbag.behat.context.ui.admin.shipping_export filters: