diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9d96b31..73a28d8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -21,21 +21,17 @@ jobs: strategy: fail-fast: false matrix: - php: ["8.0", "7.4"] - symfony: ["^4.4", "^5.2"] - sylius: ["~1.9.6", "~1.10.0", "~1.11.0"] + php: ["8.1", "8.2"] + symfony: ["^5.4", "^6.0"] + sylius: ["~1.12.0", "~1.13.0"] node: ["14.x"] mysql: ["8.0"] + state_machine_adapter: ["winzou_state_machine", "symfony_workflow"] exclude: - - sylius: ~1.9.6 - php: 8.0 - - - sylius: ~1.10.0 - symfony: 4.4 - - - sylius: ~1.11.0 - php: 7.4 + - + sylius: ~1.12.0 + state_machine_adapter: "symfony_workflow" env: APP_ENV: test @@ -129,6 +125,7 @@ jobs: key: ${{ runner.os }}-node-${{ matrix.node }}-yarn-${{ hashFiles('**/package.json **/yarn.lock') }} restore-keys: | ${{ runner.os }}-node-${{ matrix.node }}-yarn- + - name: Install JS dependencies run: (cd tests/Application && yarn install) @@ -178,7 +175,7 @@ jobs: - name: Run PHPUnit run: ./vendor/bin/phpunit --coverage-text - + - name: Failed build Slack notification uses: rtCamp/action-slack-notify@v2 if: ${{ failure() && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master') }} diff --git a/.github/workflows/coding_standard.yml b/.github/workflows/coding_standard.yml index ab60581..e725e3e 100644 --- a/.github/workflows/coding_standard.yml +++ b/.github/workflows/coding_standard.yml @@ -21,21 +21,17 @@ jobs: strategy: fail-fast: false matrix: - php: ["8.0", "7.4"] - symfony: ["^4.4", "^5.2"] - sylius: ["~1.9.6", "~1.10.0", "~1.11.0"] + php: ["8.1", "8.2"] + symfony: ["^5.4", "^6.0"] + sylius: ["~1.12.0", "~1.13.0"] node: ["14.x"] mysql: ["8.0"] + state_machine_adapter: ["winzou_state_machine", "symfony_workflow"] exclude: - - sylius: ~1.9.6 - php: 8.0 - - - sylius: ~1.10.0 - symfony: 4.4 - - - sylius: ~1.11.0 - php: 7.4 + - + sylius: ~1.12.0 + state_machine_adapter: "symfony_workflow" env: APP_ENV: test @@ -81,15 +77,15 @@ jobs: name: Install PHP dependencies run: composer install --no-interaction - - + - name: Run ECS run: vendor/bin/ecs - name: Run PHPStan - run: vendor/bin/phpstan analyse -c phpstan.neon -l 8 src/ - - - + run: vendor/bin/phpstan analyse -c phpstan.neon + + - name: Failed build Slack notification uses: rtCamp/action-slack-notify@v2 if: ${{ failure() && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master') }} diff --git a/composer.json b/composer.json index f9e010f..bba6f23 100644 --- a/composer.json +++ b/composer.json @@ -9,14 +9,15 @@ ], "license": "MIT", "require": { - "php": "^7.4 || ^8.0", - "sylius/sylius": "~1.9.0 || ~1.10.0 || ~1.11.0", - "twig/inky-extra": "^3.3" + "php": "^8.1", + "sylius/sylius": "~1.12.0 || ~1.13.0", + "twig/inky-extra": "^3.3", + "doctrine/annotations": "^1.14" }, "require-dev": { - "behat/behat": "^3.6.1", - "behat/mink-selenium2-driver": "^1.4", - "bitbag/coding-standard": "^1.0", + "behat/behat": "^3.7", + "behat/mink-selenium2-driver": "~1.6.0", + "bitbag/coding-standard": "^3.0.0", "dmore/behat-chrome-extension": "^1.3", "dmore/chrome-mink-driver": "^2.7", "friends-of-behat/mink": "^1.8", @@ -27,30 +28,18 @@ "friends-of-behat/suite-settings-extension": "^1.0", "friends-of-behat/symfony-extension": "^2.1", "friends-of-behat/variadic-extension": "^1.3", - "friendsofsymfony/oauth-server-bundle": "^1.6 || >2.0.0-alpha.0 ^2.0@dev", "lchrusciel/api-test-case": "^5.2", "phpspec/phpspec": "^7.0", - "phpstan/extension-installer": "^1.0", - "phpstan/phpstan": "0.12.85", - "phpstan/phpstan-doctrine": "0.12.33", - "phpstan/phpstan-strict-rules": "^0.12.0", - "phpstan/phpstan-webmozart-assert": "0.12.12", "phpunit/phpunit": "^9.5", - "sensiolabs/security-checker": "^6.0", "sylius-labs/coding-standard": "^4.0", - "symfony/browser-kit": "^4.4 || ^5.2", - "symfony/debug-bundle": "^4.4 || ^5.2", - "symfony/dotenv": "^4.4 || ^5.2", - "symfony/intl": "^4.4 || ^5.2", - "symfony/web-profiler-bundle": "^4.4 || ^5.2", + "symfony/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", "symfony/webpack-encore-bundle": "^1.13", - "vimeo/psalm": "4.7.1", "polishsymfonycommunity/symfony-mocker-container": "^1.0" }, - "conflict": { - "doctrine/dbal": "^3.0", - "doctrine/orm": ">=2.15.2" - }, "config": { "sort-packages": true, "allow-plugins": { diff --git a/doc/testing.md b/doc/testing.md index 55fadcc..aa29731 100644 --- a/doc/testing.md +++ b/doc/testing.md @@ -15,3 +15,14 @@ $ cd ../.. $ vendor/bin/behat $ vendor/bin/phpspec run ``` +## Testing emails with quick docker setup + +Steps to use mailhog docker image +- create `tests/Application/.env.local` +- copy content from `tests/Application/.env` +- `MAILER_DSN=null://null` -> comment this line +- `#MAILER_DSN=smtp://localhost:1025` -> uncomment this line +- remember to match port with docker image - by default they are set to 1025 +- start docker image with `docker-compose -f docker-compose.yml up` +- you can access mailhog UI on second mapped port - by default 8025 + diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..94e353f --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,13 @@ +version: '3.4' + +services: + mailhog: + # do not use in production! + image: mailhog/mailhog:latest + environment: + - MH_STORAGE=maildir + # volumes: + # - ./docker/mailhog/maildir:/maildir:rw,delegated + ports: + - "8025:8025" # UI + - "1025:1025" diff --git a/ecs.php b/ecs.php index efab80b..89ad086 100644 --- a/ecs.php +++ b/ecs.php @@ -1,20 +1,13 @@ import('vendor/bitbag/coding-standard/ecs.php'); +use Symplify\EasyCodingStandard\Config\ECSConfig; - $parameters = $containerConfigurator->parameters(); - $parameters->set(Option::PATHS, [ - __DIR__ . '/src', - __DIR__ . '/tests', - __DIR__ . '/spec', - ]); - $parameters->set(Option::SKIP, [ - __DIR__ . '/tests/Application', - VisibilityRequiredFixer::class => ['*Spec.php'], - ]); +return static function (ECSConfig $config): void { + + putenv('ALLOW_BITBAG_OS_HEADER=1'); + + $config->import('vendor/bitbag/coding-standard/ecs.php'); + $config->paths(['src', 'spec', 'tests/Repository', 'tests/Behat']); }; diff --git a/features/shop/receiving_confirmation_email_after_completing_checkout.feature b/features/shop/receiving_confirmation_email_after_completing_checkout.feature index 1fe16af..9cf4ec0 100644 --- a/features/shop/receiving_confirmation_email_after_completing_checkout.feature +++ b/features/shop/receiving_confirmation_email_after_completing_checkout.feature @@ -29,7 +29,7 @@ Feature: Receiving confirmation email after finalizing checkout @ui @email Scenario: Receiving a custom confirmation email after finalizing checkout - Given there is mail template with "order_confirmation" type and "Order confirmation" name and "Congratulations, you have bought new gun" subject and "Pif paf
{{order.number}}" content + Given there is mail template with "order_confirmation" type and "Order confirmation" name and "Congratulations, you have bought new gun" subject and "Pif paf {{order.number}}" content And I have product "Sig Sauer P226" in the cart And I have completed addressing step with email "john@example.com" and "United States" based billing address And I have proceeded order with "Free" shipping method and "Offline" payment diff --git a/features/shop/receiving_user_registration_emails.feature b/features/shop/receiving_user_registration_emails.feature index ae472b3..9fdf762 100644 --- a/features/shop/receiving_user_registration_emails.feature +++ b/features/shop/receiving_user_registration_emails.feature @@ -14,7 +14,7 @@ Feature: Receiving set of welcoming emails after registration @ui @email Scenario: Receiving a custom welcoming email after registration - Given there is mail template with "user_registration" type and "User registration" name and "Welcome to our shop!" subject and "Enjoy our stuff!" content + Given there is mail template with "verification_token" type and "User registration" name and "Welcome to our shop!" subject and "Enjoy our stuff!" content When I register with email "ghastly@bespoke.com" and password "suitsarelife" Then a welcoming email should have been sent to "ghastly@bespoke.com" @@ -24,7 +24,7 @@ Feature: Receiving set of welcoming emails after registration When I register with email "ghastly@bespoke.com" and password "suitsarelife" Then I should be notified that my account has been created and the verification email has been sent And a default account verification email should have been sent to "ghastly@bespoke.com" - And 2 emails should be sent to "ghastly@bespoke.com" + And emails should be sent to "ghastly@bespoke.com" depending on Sylius version But I should not be able to log in as "ghastly@bespoke.com" with "suitsarelife" password @ui @email @@ -33,5 +33,5 @@ Feature: Receiving set of welcoming emails after registration When I register with email "ghastly@bespoke.com" and password "suitsarelife" Then I should be notified that my account has been created and the verification email has been sent And a custom account verification email should have been sent to "ghastly@bespoke.com" - And 2 emails should be sent to "ghastly@bespoke.com" + And emails should be sent to "ghastly@bespoke.com" depending on Sylius version But I should not be able to log in as "ghastly@bespoke.com" with "suitsarelife" password diff --git a/features/shop/sending_confirmation_email_after_shipping_order.feature b/features/shop/sending_confirmation_email_after_shipping_order.feature index 5eb2e90..7c5aa22 100644 --- a/features/shop/sending_confirmation_email_after_shipping_order.feature +++ b/features/shop/sending_confirmation_email_after_shipping_order.feature @@ -32,7 +32,7 @@ Feature: Sending a confirmation email after shipping an order @ui @email Scenario: Sending a custom confirmation email after shipping an order - Given there is mail template with "shipment_confirmation" type and "Shipment confirmation" name and "Your products are waiting for you!" subject and "Enjoy your new stuff!
{{order.number}}
{{ shipment.method.name }}
{{shipment.tracking}}" content + Given there is mail template with "shipment_confirmation" type and "Shipment confirmation" name and "Your products are waiting for you!" subject and "Enjoy your new stuff! {{order.number}} {{ shipment.method.name }} {{shipment.tracking}}" content When I view the summary of the order "#00000666" And specify its tracking code as "#00044" And I ship this order diff --git a/phpstan.neon b/phpstan.neon index 84eac9f..0a0bb8e 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,17 +1,9 @@ +includes: + - vendor/bitbag/coding-standard/phpstan.neon parameters: level: 8 - reportUnmatchedIgnoredErrors: false - checkMissingIterableValueType: false - checkGenericClassInNonGenericObjectType: false - - excludes_analyse: - # Makes PHPStan crash - - 'src/DependencyInjection/Configuration.php' - - # Test dependencies - - 'tests/Application/*' - - # ECS Fixer dependency - - 'src/Fixer' - 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\./' + excludePaths: + - tests/Repository + paths: + - src + - tests diff --git a/spec/EmailSender/SenderSpec.php b/spec/EmailSender/SenderSpec.php index 142b342..dc67cc7 100644 --- a/spec/EmailSender/SenderSpec.php +++ b/spec/EmailSender/SenderSpec.php @@ -1,9 +1,10 @@ beConstructedWith( $rendererAdapter, $senderAdapter, $provider, $defaultSettingsProvider, - $templateTranslationRepository + $templateTranslationRepository, ); $this->shouldHaveType(Sender::class); } @@ -60,7 +61,7 @@ function it_should_send_email( DefaultSettingsProviderInterface $defaultSettingsProvider, EmailTemplateTranslationRepositoryInterface $templateTranslationRepository, EmailInterface $email, - RenderedEmail $renderedEmail + RenderedEmail $renderedEmail, ): void { $this->beConstructedWith( $rendererAdapter, @@ -102,7 +103,7 @@ function it_should_set_custom_email_template_if_found( DefaultSettingsProviderInterface $defaultSettingsProvider, EmailTemplateTranslationRepositoryInterface $templateTranslationRepository, EmailInterface $email, - RenderedEmail $renderedEmail + RenderedEmail $renderedEmail, ): void { $this->beConstructedWith( $rendererAdapter, @@ -122,7 +123,7 @@ function it_should_set_custom_email_template_if_found( $emailTemplateTranslation = new EmailTemplateTranslation(); $templateTranslationRepository->findOneByLocaleCodeAndType( self::LOCALE, - self::EMAIL_TYPE + self::EMAIL_TYPE, )->willReturn($emailTemplateTranslation); $rendererAdapter->render($email, Argument::type('array'))->willReturn($renderedEmail); diff --git a/spec/EventListener/NotFoundTypeCreateEmailTemplateEventListenerSpec.php b/spec/EventListener/NotFoundTypeCreateEmailTemplateEventListenerSpec.php index 3578df2..394ef55 100644 --- a/spec/EventListener/NotFoundTypeCreateEmailTemplateEventListenerSpec.php +++ b/spec/EventListener/NotFoundTypeCreateEmailTemplateEventListenerSpec.php @@ -1,9 +1,10 @@ attributes = $attributes; @@ -46,10 +46,12 @@ function it_is_initializable(): void function it_should_do_nothing_when_route_is_not_create_email_template( RequestEvent $requestEvent, Request $request, - ParameterBag $attributes, - EmailCodesProviderInterface $emailCodesProvider + ParameterBagInterface $attributes, + EmailCodesProviderInterface $emailCodesProvider, + Session $session, ): void { $requestEvent->getRequest()->willReturn($request); + $request->getSession()->willReturn($session); $attributes->get('_route')->shouldBeCalled()->willReturn('wrong_route'); @@ -61,10 +63,10 @@ function it_should_do_nothing_when_route_is_not_create_email_template( function it_should_not_redirect_when_type_are_available_to_create_email_template( RequestEvent $requestEvent, Request $request, - ParameterBag $attributes, + ParameterBagInterface $attributes, EmailCodesProviderInterface $emailCodesProvider, Session $session, - FlashBagInterface $flashBag + FlashBagInterface $flashBag, ): void { $requestEvent->getRequest()->willReturn($request); @@ -85,12 +87,12 @@ function it_should_not_redirect_when_type_are_available_to_create_email_template function it_should_redirect_when_route_is_create_email_template( RequestEvent $requestEvent, Request $request, - ParameterBag $attributes, + ParameterBagInterface $attributes, EmailCodesProviderInterface $emailCodesProvider, Session $session, FlashBagInterface $flashBag, RouterInterface $router, - DataCollectorTranslator $dataCollectorTranslator + DataCollectorTranslator $dataCollectorTranslator, ): void { $requestEvent->getRequest()->willReturn($request); diff --git a/spec/EventListener/TwigErrorEventListenerSpec.php b/spec/EventListener/TwigErrorEventListenerSpec.php index 970bd9c..9a850c0 100644 --- a/spec/EventListener/TwigErrorEventListenerSpec.php +++ b/spec/EventListener/TwigErrorEventListenerSpec.php @@ -1,9 +1,10 @@ getWrappedObject(), $request->getWrappedObject(), HttpKernelInterface::MASTER_REQUEST, - new \Exception() + new \Exception(), ); $customTwigErrorResponseProvider->provide(Argument::type(Error::class))->shouldNotBeCalled(); @@ -53,14 +54,14 @@ function it_should_do_nothing_if_exception_is_not_a_twig_security_error( function it_should_do_nothing_if_provided_custom_response_is_null( HttpKernelInterface $httpKernel, Request $request, - CustomTwigErrorResponseProviderInterface $customTwigErrorResponseProvider + CustomTwigErrorResponseProviderInterface $customTwigErrorResponseProvider, ): void { $genericResponse = new Response(); $exceptionEvent = new ExceptionEvent( $httpKernel->getWrappedObject(), $request->getWrappedObject(), HttpKernelInterface::MASTER_REQUEST, - new \Exception() + new \Exception(), ); $exceptionEvent->setResponse($genericResponse); $customTwigErrorResponseProvider->provide(Argument::type(Error::class))->willReturn(null); @@ -73,7 +74,7 @@ function it_should_do_nothing_if_provided_custom_response_is_null( function it_should_set_response_to_the_provided_custom_twig_error_response( HttpKernelInterface $httpKernel, Request $request, - CustomTwigErrorResponseProviderInterface $customTwigErrorResponseProvider + CustomTwigErrorResponseProviderInterface $customTwigErrorResponseProvider, ): void { $jsonResponse = new JsonResponse(); $error = new Error('foo'); @@ -81,7 +82,7 @@ function it_should_set_response_to_the_provided_custom_twig_error_response( $httpKernel->getWrappedObject(), $request->getWrappedObject(), HttpKernelInterface::MASTER_REQUEST, - $error + $error, ); $exceptionEvent->setResponse(new Response()); $customTwigErrorResponseProvider->provide($error)->willReturn($jsonResponse); diff --git a/spec/MailPreviewData/Factory/CustomerPreviewDataFactorySpec.php b/spec/MailPreviewData/Factory/CustomerPreviewDataFactorySpec.php index 97d2a91..a4bfed6 100644 --- a/spec/MailPreviewData/Factory/CustomerPreviewDataFactorySpec.php +++ b/spec/MailPreviewData/Factory/CustomerPreviewDataFactorySpec.php @@ -1,9 +1,10 @@ beConstructedWith( self::EXAMPLE_EMAILS_CONFIGURATION, $emailTemplateRepository, - $dataCollectorTranslator + $dataCollectorTranslator, ); } @@ -93,12 +100,12 @@ function it_should_return_not_email_template_types(EmailTemplateRepositoryInterf function it_should_return_not_used_types_for_edit_email_template( EmailTemplateRepositoryInterface $emailTemplateRepository, EmailTemplateInterface $emailTemplate, - DataCollectorTranslator $dataCollectorTranslator + DataCollectorTranslator $dataCollectorTranslator, ): void { $dataCollectorTranslator->trans( 'Contact Request', [], - EmailTemplateType::MAIL_TEMPLATE_TYPE_DOMAIN + EmailTemplateType::MAIL_TEMPLATE_TYPE_DOMAIN, )->shouldBeCalled()->willReturn('Contact Request'); $emailTemplateRepository->getAllTypes()->willReturn([ diff --git a/spec/Provider/MailPreviewDataProviderSpec.php b/spec/Provider/MailPreviewDataProviderSpec.php index 884e39e..64019ff 100644 --- a/spec/Provider/MailPreviewDataProviderSpec.php +++ b/spec/Provider/MailPreviewDataProviderSpec.php @@ -1,5 +1,12 @@ $genericMailPreviewData, @@ -60,7 +67,7 @@ function it_should_throw_exception_if_matched_mail_preview_data_is_not_implement function it_should_return_mail_preview_data_for_requested_type( MailPreviewDataInterface $genericMailPreviewData, - MailPreviewDataInterface $fooMailPreviewData + MailPreviewDataInterface $fooMailPreviewData, ): void { $availableMailPreviewData = [ MailPreviewDataProvider::GENERIC_PREVIEW_DATA_KEY => $genericMailPreviewData, diff --git a/spec/Repository/EmailTemplateTranslationRepositorySpec.php b/spec/Repository/EmailTemplateTranslationRepositorySpec.php index 0e9e3e1..3835783 100644 --- a/spec/Repository/EmailTemplateTranslationRepositorySpec.php +++ b/spec/Repository/EmailTemplateTranslationRepositorySpec.php @@ -1,9 +1,10 @@ createQueryBuilder('tt', null)->willReturn($queryBuilder); diff --git a/spec/Response/TwigError/SecurityNotAllowedFilterErrorResponseSpec.php b/spec/Response/TwigError/SecurityNotAllowedFilterErrorResponseSpec.php index d892b8e..e09cbd0 100644 --- a/spec/Response/TwigError/SecurityNotAllowedFilterErrorResponseSpec.php +++ b/spec/Response/TwigError/SecurityNotAllowedFilterErrorResponseSpec.php @@ -1,5 +1,12 @@ '*', @@ -51,7 +52,7 @@ function it_should_not_call_decorated_object_on_check_method_if_allowed_methods_ } function it_should_not_call_decorated_object_on_check_method_if_allowed_methods_contains__class_wildcard_with_matching_method( - SecurityPolicyInterface $securityPolicy + SecurityPolicyInterface $securityPolicy, ): void { $allowedMethods = [ '*' => [ @@ -65,7 +66,7 @@ function it_should_not_call_decorated_object_on_check_method_if_allowed_methods_ } function it_should_not_call_decorated_object_on_check_method_if_allowed_methods_contains_wildcard_class_with_wildcard_method( - SecurityPolicyInterface $securityPolicy + SecurityPolicyInterface $securityPolicy, ): void { $allowedMethods = [ '*' => '*', @@ -77,7 +78,7 @@ function it_should_not_call_decorated_object_on_check_method_if_allowed_methods_ } function it_should_call_decorated_object_method_on_check_method_if_passed_object_or_method_doesnt_meet_requirements( - SecurityPolicyInterface $securityPolicy + SecurityPolicyInterface $securityPolicy, ): void { $securityPolicy->checkMethodAllowed(Argument::type('object'), self::EXAMPLE_METHOD)->shouldBeCalled(); diff --git a/spec/Validator/IsRenderableMailContentValidatorSpec.php b/spec/Validator/IsRenderableMailContentValidatorSpec.php index 833fcc5..e9281d6 100644 --- a/spec/Validator/IsRenderableMailContentValidatorSpec.php +++ b/spec/Validator/IsRenderableMailContentValidatorSpec.php @@ -1,5 +1,12 @@ createEmailTemplateTranslationWithSampleEmailTemplate(); @@ -69,7 +76,7 @@ function it_should_add_violation_if_exception_is_thrown_while_rendering( $constraint = new IsRenderableMailContent(); $validator = new IsRenderableMailContentValidator( $twig->getWrappedObject(), - $mailPreviewDataProvider->getWrappedObject() + $mailPreviewDataProvider->getWrappedObject(), ); $validator->initialize($context->getWrappedObject()); @@ -85,7 +92,7 @@ function it_should_do_nothing_if_no_exception_has_been_thrown_while_rendering( ExecutionContextInterface $context, environment $twig, MailPreviewDataProviderInterface $mailPreviewDataProvider, - MailPreviewDataInterface $mailPreviewData + MailPreviewDataInterface $mailPreviewData, ): void { $emailTemplateTranslation = $this->createEmailTemplateTranslationWithSampleEmailTemplate(); @@ -94,9 +101,10 @@ function it_should_do_nothing_if_no_exception_has_been_thrown_while_rendering( $mailPreviewDataProvider->get(Argument::any())->willReturn($mailPreviewData); $constraint = new IsRenderableMailContent(); + $twig->render(RenderEmailPreviewAction::EMAIL_PREVIEW_TEMPLATE, Argument::type('array')); $validator = new IsRenderableMailContentValidator( $twig->getWrappedObject(), - $mailPreviewDataProvider->getWrappedObject() + $mailPreviewDataProvider->getWrappedObject(), ); $validator->initialize($context->getWrappedObject()); diff --git a/src/BitBagSyliusMailTemplatePlugin.php b/src/BitBagSyliusMailTemplatePlugin.php index 0a270bf..7d40d1f 100644 --- a/src/BitBagSyliusMailTemplatePlugin.php +++ b/src/BitBagSyliusMailTemplatePlugin.php @@ -1,10 +1,11 @@ setParameter( self::ALLOWED_FILTERS_PARAMETER, - array_unique(array_merge($config[Configuration::TWIG][Configuration::ALLOWED_FILTERS], self::REQUIRED_FILTERS)) + array_unique(array_merge($config[Configuration::TWIG][Configuration::ALLOWED_FILTERS], self::REQUIRED_FILTERS)), ); $container->setParameter( self::ALLOWED_FUNCTIONS_PARAMETER, - array_unique(array_merge($config[Configuration::TWIG][Configuration::ALLOWED_FUNCTIONS], self::REQUIRED_FUNCTIONS)) + array_unique(array_merge($config[Configuration::TWIG][Configuration::ALLOWED_FUNCTIONS], self::REQUIRED_FUNCTIONS)), ); $container->setParameter( self::ALLOWED_METHODS_PARAMETER, - $config[Configuration::TWIG][Configuration::ALLOWED_METHODS] + $config[Configuration::TWIG][Configuration::ALLOWED_METHODS], ); $container->setParameter( self::ALLOWED_PROPERTIES_PARAMETER, - $config[Configuration::TWIG][Configuration::ALLOWED_PROPERTIES] + $config[Configuration::TWIG][Configuration::ALLOWED_PROPERTIES], ); $container->setParameter( self::ALLOWED_TAGS_PARAMETER, - array_unique(array_merge($config[Configuration::TWIG][Configuration::ALLOWED_TAGS], self::REQUIRED_TAGS)) + array_unique(array_merge($config[Configuration::TWIG][Configuration::ALLOWED_TAGS], self::REQUIRED_TAGS)), ); } diff --git a/src/DependencyInjection/CompilerPass/SyliusBehatPolyfillCompilerPass.php b/src/DependencyInjection/CompilerPass/SyliusBehatPolyfillCompilerPass.php index d1d55d9..a656a08 100644 --- a/src/DependencyInjection/CompilerPass/SyliusBehatPolyfillCompilerPass.php +++ b/src/DependencyInjection/CompilerPass/SyliusBehatPolyfillCompilerPass.php @@ -1,9 +1,10 @@ senderAdapter = $senderAdapter; $this->rendererAdapter = $rendererAdapter; @@ -55,7 +55,7 @@ public function send( array $recipients, array $data = [], array $attachments = [], - array $replyTo = [] + array $replyTo = [], ): void { $email = $this->provider->getEmail($code); @@ -65,7 +65,7 @@ public function send( $customTemplate = $this->templateTranslationRepository->findOneByLocaleCodeAndType( $data[self::LOCALE_CODE_KEY] ?? '', - $code + $code, ); if (null !== $customTemplate) { @@ -86,7 +86,7 @@ public function send( $email, $data, $attachments, - $replyTo + $replyTo, ); } } diff --git a/src/EmailSender/SenderInterface.php b/src/EmailSender/SenderInterface.php index 4b43639..0da14ac 100644 --- a/src/EmailSender/SenderInterface.php +++ b/src/EmailSender/SenderInterface.php @@ -18,6 +18,6 @@ public function send( array $recipients, array $data = [], array $attachments = [], - array $replyTo = [] + array $replyTo = [], ): void; } diff --git a/src/Entity/EmailTemplate.php b/src/Entity/EmailTemplate.php index 66db9b6..f31c669 100644 --- a/src/Entity/EmailTemplate.php +++ b/src/Entity/EmailTemplate.php @@ -1,10 +1,11 @@ emailCodesProvider = $emailCodesProvider; $this->translator = $translator; diff --git a/src/EventListener/TwigErrorEventListener.php b/src/EventListener/TwigErrorEventListener.php index ae04230..8baeb40 100644 --- a/src/EventListener/TwigErrorEventListener.php +++ b/src/EventListener/TwigErrorEventListener.php @@ -1,9 +1,10 @@ emailTemplateFactory = $emailTemplateFactory; $this->emailTemplateTranslationFactory = $emailTemplateTranslationFactory; @@ -57,7 +57,7 @@ public function load(array $options): void private function createEmailTemplate( string $type, string $styleCss, - array $emailTemplateData + array $emailTemplateData, ): void { /** @var EmailTemplateInterface $emailTemplate */ $emailTemplate = $this->emailTemplateFactory->createNew(); diff --git a/src/Form/Type/EmailTemplateType.php b/src/Form/Type/EmailTemplateType.php index 7f8d940..3a922a4 100644 --- a/src/Form/Type/EmailTemplateType.php +++ b/src/Form/Type/EmailTemplateType.php @@ -1,10 +1,11 @@ emails = $emails; $this->emailTemplateRepository = $emailTemplateRepository; @@ -74,7 +75,7 @@ public function getAvailableEmailTemplateTypes(EmailTemplateInterface $emailTemp $translatedLabelName = $this->dataCollectorTranslator->trans( $labelName, [], - EmailTemplateType::MAIL_TEMPLATE_TYPE_DOMAIN + EmailTemplateType::MAIL_TEMPLATE_TYPE_DOMAIN, ); $types[$translatedLabelName] = $dataType; diff --git a/src/Provider/EmailCodesProviderInterface.php b/src/Provider/EmailCodesProviderInterface.php index c83dc7d..4a7f11d 100644 --- a/src/Provider/EmailCodesProviderInterface.php +++ b/src/Provider/EmailCodesProviderInterface.php @@ -1,9 +1,10 @@ select('et.type') ->getQuery() ->getResult() - ; + ; } } diff --git a/src/Repository/EmailTemplateRepositoryInterface.php b/src/Repository/EmailTemplateRepositoryInterface.php index 7afee5a..b1a7e8e 100644 --- a/src/Repository/EmailTemplateRepositoryInterface.php +++ b/src/Repository/EmailTemplateRepositoryInterface.php @@ -1,10 +1,11 @@ */ + /** @phpstan-ignore-next-line */ public function findBy( array $criteria, ?array $orderBy = null, $limit = null, - $offset = null + $offset = null, ): array { return $this->decoratedRepository->findBy($criteria, $orderBy, $limit, $offset); } diff --git a/src/Request/MailPreviewRequest.php b/src/Request/MailPreviewRequest.php index db479a3..ebde15c 100644 --- a/src/Request/MailPreviewRequest.php +++ b/src/Request/MailPreviewRequest.php @@ -1,9 +1,10 @@ name = $name; $this->subject = $subject; diff --git a/src/Request/RequestDtoInterface.php b/src/Request/RequestDtoInterface.php index 59536c8..58fa7f0 100644 --- a/src/Request/RequestDtoInterface.php +++ b/src/Request/RequestDtoInterface.php @@ -1,9 +1,10 @@ $this->getErrorMessage($error), ], - Response::HTTP_BAD_REQUEST + Response::HTTP_BAD_REQUEST, ); } diff --git a/src/Response/TwigError/SecurityNotAllowedFilterErrorResponse.php b/src/Response/TwigError/SecurityNotAllowedFilterErrorResponse.php index ffd9850..094c9c7 100644 --- a/src/Response/TwigError/SecurityNotAllowedFilterErrorResponse.php +++ b/src/Response/TwigError/SecurityNotAllowedFilterErrorResponse.php @@ -1,9 +1,10 @@ decoratedSecurityPolicy->checkSecurity($tags, $filters, $functions); } diff --git a/src/Validator/IsRenderableMailContent.php b/src/Validator/IsRenderableMailContent.php index 8a9e06d..3188731 100644 --- a/src/Validator/IsRenderableMailContent.php +++ b/src/Validator/IsRenderableMailContent.php @@ -1,9 +1,10 @@ symfony/swiftmailer-bundle ### -# For Gmail as a transport, use: "gmail://username:password@localhost" -# For a generic SMTP server, use: "smtp://localhost:25?encryption=&auth_mode=" -# Delivery is disabled by default via "null://localhost" -MAILER_URL=smtp://localhost -###< symfony/swiftmailer-bundle ### +###> symfony/mailer ### +MAILER_DSN=null://null + +# Use with docker-compose.yml mailhog configuration +#MAILER_DSN=smtp://localhost:1025 +###< symfony/mailer ### ###> symfony/messenger ### # Choose one of the transports below diff --git a/tests/Application/Kernel.php b/tests/Application/Kernel.php index c20ac6c..2e00669 100644 --- a/tests/Application/Kernel.php +++ b/tests/Application/Kernel.php @@ -12,6 +12,7 @@ use Symfony\Component\DependencyInjection\ContainerBuilder; 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 @@ -58,7 +59,7 @@ protected function configureContainer(ContainerBuilder $container, LoaderInterfa } } - protected function configureRoutes(RouteCollectionBuilder $routes): void + protected function configureRoutes(RoutingConfigurator $routes): void { foreach ($this->getConfigurationDirectories() as $confDir) { $this->loadRoutesConfiguration($routes, $confDir); @@ -87,11 +88,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, 'glob'); + $routes->import($confDir . '/{routes}/' . $this->environment . '/**/*' . self::CONFIG_EXTS, 'glob'); + $routes->import($confDir . '/{routes}' . self::CONFIG_EXTS, 'glob'); } /** diff --git a/tests/Application/config/bootstrap.php b/tests/Application/config/bootstrap.php index d7ac51d..2291ab4 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 d8015bb..0f554cf 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], @@ -59,4 +58,6 @@ Symfony\WebpackEncoreBundle\WebpackEncoreBundle::class => ['all' => true], Fidry\AliceDataFixtures\Bridge\Symfony\FidryAliceDataFixturesBundle::class => ['dev' => true, 'test' => true], Nelmio\Alice\Bridge\Symfony\NelmioAliceBundle::class => ['dev' => true, 'test' => true], + League\FlysystemBundle\FlysystemBundle::class => ['all' => true], + Sylius\Calendar\SyliusCalendarBundle::class => ['all' => true], ]; diff --git a/tests/Application/config/packages/dev/swiftmailer.yaml b/tests/Application/config/packages/dev/swiftmailer.yaml deleted file mode 100644 index 8ca953b..0000000 --- a/tests/Application/config/packages/dev/swiftmailer.yaml +++ /dev/null @@ -1,2 +0,0 @@ -swiftmailer: - disable_delivery: false diff --git a/tests/Application/config/packages/mailer.yaml b/tests/Application/config/packages/mailer.yaml new file mode 100644 index 0000000..56a650d --- /dev/null +++ b/tests/Application/config/packages/mailer.yaml @@ -0,0 +1,3 @@ +framework: + mailer: + dsn: '%env(MAILER_DSN)%' diff --git a/tests/Application/config/packages/prod/doctrine.yaml b/tests/Application/config/packages/prod/doctrine.yaml deleted file mode 100644 index 2f16f0f..0000000 --- a/tests/Application/config/packages/prod/doctrine.yaml +++ /dev/null @@ -1,31 +0,0 @@ -doctrine: - orm: - metadata_cache_driver: - type: service - id: doctrine.system_cache_provider - query_cache_driver: - type: service - id: doctrine.system_cache_provider - result_cache_driver: - type: service - id: doctrine.result_cache_provider - -services: - doctrine.result_cache_provider: - class: Symfony\Component\Cache\DoctrineProvider - public: false - arguments: - - '@doctrine.result_cache_pool' - doctrine.system_cache_provider: - class: Symfony\Component\Cache\DoctrineProvider - public: false - arguments: - - '@doctrine.system_cache_pool' - -framework: - cache: - pools: - doctrine.result_cache_pool: - adapter: cache.app - doctrine.system_cache_pool: - adapter: cache.system diff --git a/tests/Application/config/packages/security_checker.yaml b/tests/Application/config/packages/security_checker.yaml deleted file mode 100644 index 0f9cf00..0000000 --- a/tests/Application/config/packages/security_checker.yaml +++ /dev/null @@ -1,9 +0,0 @@ -services: - SensioLabs\Security\SecurityChecker: - public: false - - SensioLabs\Security\Command\SecurityCheckerCommand: - arguments: ['@SensioLabs\Security\SecurityChecker'] - public: false - tags: - - { name: console.command, command: 'security:check' } diff --git a/tests/Application/config/packages/staging/swiftmailer.yaml b/tests/Application/config/packages/staging/swiftmailer.yaml deleted file mode 100644 index f438078..0000000 --- a/tests/Application/config/packages/staging/swiftmailer.yaml +++ /dev/null @@ -1,2 +0,0 @@ -swiftmailer: - disable_delivery: true diff --git a/tests/Application/config/packages/swiftmailer.yaml b/tests/Application/config/packages/swiftmailer.yaml deleted file mode 100644 index 3bab0d3..0000000 --- a/tests/Application/config/packages/swiftmailer.yaml +++ /dev/null @@ -1,2 +0,0 @@ -swiftmailer: - url: '%env(MAILER_URL)%' diff --git a/tests/Application/config/packages/test/framework.yaml b/tests/Application/config/packages/test/framework.yaml index 76d7e5e..daf04d4 100644 --- a/tests/Application/config/packages/test/framework.yaml +++ b/tests/Application/config/packages/test/framework.yaml @@ -1,4 +1,4 @@ framework: test: ~ session: - storage_id: session.storage.mock_file + handler_id: ~ diff --git a/tests/Application/config/packages/test/mailer.yaml b/tests/Application/config/packages/test/mailer.yaml new file mode 100644 index 0000000..092eb28 --- /dev/null +++ b/tests/Application/config/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/config/packages/test/security.yaml b/tests/Application/config/packages/test/security.yaml index 21cc377..8ccd542 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/test/swiftmailer.yaml b/tests/Application/config/packages/test/swiftmailer.yaml deleted file mode 100644 index c438f4b..0000000 --- a/tests/Application/config/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/packages/test_cached/framework.yaml b/tests/Application/config/packages/test_cached/framework.yaml index 76d7e5e..daf04d4 100644 --- a/tests/Application/config/packages/test_cached/framework.yaml +++ b/tests/Application/config/packages/test_cached/framework.yaml @@ -1,4 +1,4 @@ framework: test: ~ session: - storage_id: session.storage.mock_file + handler_id: ~ diff --git a/tests/Application/config/packages/test_cached/security.yaml b/tests/Application/config/packages/test_cached/security.yaml index 21cc377..8ccd542 100644 --- a/tests/Application/config/packages/test_cached/security.yaml +++ b/tests/Application/config/packages/test_cached/security.yaml @@ -1,3 +1,3 @@ security: - encoders: + password_hashers: sha512: sha512 diff --git a/tests/Application/config/packages/test_cached/swiftmailer.yaml b/tests/Application/config/packages/test_cached/swiftmailer.yaml deleted file mode 100644 index c438f4b..0000000 --- a/tests/Application/config/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/routes/sylius_shop.yaml b/tests/Application/config/routes/sylius_shop.yaml index 92eeae0..fae46cb 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 diff --git a/tests/Application/config/sylius/1.10/packages/dev/jms_serializer.yaml b/tests/Application/config/sylius/1.10/packages/dev/jms_serializer.yaml deleted file mode 100644 index 2f32a9b..0000000 --- a/tests/Application/config/sylius/1.10/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.10/packages/jms_serializer.yaml b/tests/Application/config/sylius/1.10/packages/jms_serializer.yaml deleted file mode 100644 index ed7bc61..0000000 --- a/tests/Application/config/sylius/1.10/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.10/packages/prod/jms_serializer.yaml b/tests/Application/config/sylius/1.10/packages/prod/jms_serializer.yaml deleted file mode 100644 index c288182..0000000 --- a/tests/Application/config/sylius/1.10/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/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/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.10/bundles.php b/tests/Application/config/sylius/1.12/bundles.php similarity index 89% rename from tests/Application/config/sylius/1.10/bundles.php rename to tests/Application/config/sylius/1.12/bundles.php index d50639f..bd33f4a 100644 --- a/tests/Application/config/sylius/1.10/bundles.php +++ b/tests/Application/config/sylius/1.12/bundles.php @@ -1,7 +1,5 @@ ['all' => true], SyliusLabs\Polyfill\Symfony\Security\Bundle\SyliusLabsPolyfillSymfonySecurityBundle::class => ['all' => true], diff --git a/tests/Application/config/sylius/1.10/packages/security.yaml b/tests/Application/config/sylius/1.12/packages/security.yaml similarity index 58% rename from tests/Application/config/sylius/1.10/packages/security.yaml rename to tests/Application/config/sylius/1.12/packages/security.yaml index 1062810..4ed342f 100644 --- a/tests/Application/config/sylius/1.10/packages/security.yaml +++ b/tests/Application/config/sylius/1.12/packages/security.yaml @@ -1,16 +1,5 @@ -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 + enable_authenticator_manager: true providers: sylius_admin_user_provider: id: sylius.admin_user_provider.email_or_name_based @@ -20,11 +9,8 @@ security: 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: + password_hashers: Sylius\Component\User\Model\UserInterface: argon2i firewalls: admin: @@ -40,7 +26,7 @@ security: default_target_path: sylius_admin_dashboard use_forward: false use_referer: true - csrf_token_generator: security.csrf.token_manager + enable_csrf: true csrf_parameter: _csrf_admin_security_token csrf_token_id: admin_authenticate remember_me: @@ -52,46 +38,32 @@ security: 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 + pattern: "%sylius.security.new_api_admin_regex%/.*" + provider: sylius_api_admin_user_provider stateless: true - anonymous: true + entry_point: jwt json_login: - check_path: "%sylius.security.new_api_route%/admin-user-authentication-token" + check_path: "%sylius.security.new_api_admin_route%/authentication-token" username_path: email password_path: password success_handler: lexik_jwt_authentication.handler.authentication_success failure_handler: lexik_jwt_authentication.handler.authentication_failure - guard: - authenticators: - - lexik_jwt_authentication.jwt_token_authenticator + jwt: true new_api_shop_user: - pattern: "%sylius.security.new_api_route%/shop-user-authentication-token" - provider: sylius_shop_user_provider + pattern: "%sylius.security.new_api_shop_regex%/.*" + provider: sylius_api_shop_user_provider stateless: true - anonymous: true + entry_point: jwt json_login: - check_path: "%sylius.security.new_api_route%/shop-user-authentication-token" + check_path: "%sylius.security.new_api_shop_route%/authentication-token" username_path: email password_path: password success_handler: lexik_jwt_authentication.handler.authentication_success failure_handler: lexik_jwt_authentication.handler.authentication_failure - guard: - authenticators: - - lexik_jwt_authentication.jwt_token_authenticator - - 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 + jwt: true shop: switch_user: { role: ROLE_ALLOWED_TO_SWITCH } @@ -108,7 +80,7 @@ security: default_target_path: sylius_shop_homepage use_forward: false use_referer: true - csrf_token_generator: security.csrf.token_manager + enable_csrf: true csrf_parameter: _csrf_shop_security_token csrf_token_id: shop_authenticate remember_me: @@ -118,31 +90,35 @@ security: remember_me_parameter: _remember_me logout: path: sylius_shop_logout - target: sylius_shop_login + target: sylius_shop_homepage invalidate_session: false - success_handler: sylius.handler.shop_user_logout - anonymous: true dev: - pattern: ^/(_(profiler|wdt)|css|images|js)/ + 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: IS_AUTHENTICATED_ANONYMOUSLY, ips: [127.0.0.1, ::1] } + - { path: "%sylius.security.admin_regex%/_partial", role: PUBLIC_ACCESS, ips: [127.0.0.1, ::1] } - { path: "%sylius.security.admin_regex%/_partial", role: ROLE_NO_ACCESS } - - { path: "%sylius.security.shop_regex%/_partial", role: IS_AUTHENTICATED_ANONYMOUSLY, ips: [127.0.0.1, ::1] } + - { path: "%sylius.security.shop_regex%/_partial", role: PUBLIC_ACCESS, ips: [127.0.0.1, ::1] } - { path: "%sylius.security.shop_regex%/_partial", role: ROLE_NO_ACCESS } - - { path: "%sylius.security.admin_regex%/login", role: IS_AUTHENTICATED_ANONYMOUSLY } - - { path: "%sylius.security.api_regex%/login", role: IS_AUTHENTICATED_ANONYMOUSLY } - - { path: "%sylius.security.shop_regex%/login", role: IS_AUTHENTICATED_ANONYMOUSLY } + - { path: "%sylius.security.admin_regex%/login", role: PUBLIC_ACCESS } + - { path: "%sylius.security.shop_regex%/login", role: PUBLIC_ACCESS } - - { path: "%sylius.security.shop_regex%/register", role: IS_AUTHENTICATED_ANONYMOUSLY } - - { path: "%sylius.security.shop_regex%/verify", role: IS_AUTHENTICATED_ANONYMOUSLY } + - { path: "%sylius.security.shop_regex%/register", role: PUBLIC_ACCESS } + - { path: "%sylius.security.shop_regex%/verify", role: PUBLIC_ACCESS } - { path: "%sylius.security.admin_regex%", role: ROLE_ADMINISTRATION_ACCESS } - - { path: "%sylius.security.api_regex%/.*", role: ROLE_API_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_shop_regex%/.*", role: IS_AUTHENTICATED_ANONYMOUSLY } + - { path: "%sylius.security.new_api_admin_route%/authentication-token", role: PUBLIC_ACCESS } + - { path: "%sylius.security.new_api_user_account_regex%/.*", role: ROLE_USER } + - { path: "%sylius.security.new_api_shop_route%/authentication-token", role: PUBLIC_ACCESS } + - { path: "%sylius.security.new_api_shop_regex%/.*", role: PUBLIC_ACCESS } diff --git a/tests/Application/config/sylius/1.11/bundles.php b/tests/Application/config/sylius/1.13/bundles.php similarity index 68% rename from tests/Application/config/sylius/1.11/bundles.php rename to tests/Application/config/sylius/1.13/bundles.php index 400b877..b0560bc 100644 --- a/tests/Application/config/sylius/1.11/bundles.php +++ b/tests/Application/config/sylius/1.13/bundles.php @@ -1,9 +1,7 @@ ['all' => true], SyliusLabs\Polyfill\Symfony\Security\Bundle\SyliusLabsPolyfillSymfonySecurityBundle::class => ['all' => true], - Sylius\Calendar\SyliusCalendarBundle::class => ['all' => true], + Sylius\Abstraction\StateMachine\SyliusStateMachineAbstractionBundle::class => ['all' => true], ]; diff --git a/tests/Application/config/sylius/1.13/packages/_sylius.yaml b/tests/Application/config/sylius/1.13/packages/_sylius.yaml new file mode 100644 index 0000000..76aa43a --- /dev/null +++ b/tests/Application/config/sylius/1.13/packages/_sylius.yaml @@ -0,0 +1,7 @@ +parameters: + test_default_state_machine_adapter: 'symfony_workflow' + test_sylius_state_machine_adapter: '%env(string:default:test_default_state_machine_adapter:TEST_SYLIUS_STATE_MACHINE_ADAPTER)%' + +sylius_state_machine_abstraction: + graphs_to_adapters_mapping: + sylius_refund_refund_payment: '%test_sylius_state_machine_adapter%' diff --git a/tests/Application/config/sylius/1.11/packages/security.yaml b/tests/Application/config/sylius/1.13/packages/security.yaml similarity index 58% rename from tests/Application/config/sylius/1.11/packages/security.yaml rename to tests/Application/config/sylius/1.13/packages/security.yaml index 1062810..c81f04b 100644 --- a/tests/Application/config/sylius/1.11/packages/security.yaml +++ b/tests/Application/config/sylius/1.13/packages/security.yaml @@ -1,16 +1,5 @@ -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 + enable_authenticator_manager: true providers: sylius_admin_user_provider: id: sylius.admin_user_provider.email_or_name_based @@ -20,11 +9,8 @@ security: 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: + password_hashers: Sylius\Component\User\Model\UserInterface: argon2i firewalls: admin: @@ -40,7 +26,7 @@ security: default_target_path: sylius_admin_dashboard use_forward: false use_referer: true - csrf_token_generator: security.csrf.token_manager + enable_csrf: true csrf_parameter: _csrf_admin_security_token csrf_token_id: admin_authenticate remember_me: @@ -52,46 +38,32 @@ security: 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 + pattern: "%sylius.security.new_api_admin_regex%/.*" + provider: sylius_api_admin_user_provider stateless: true - anonymous: true + entry_point: jwt json_login: - check_path: "%sylius.security.new_api_route%/admin-user-authentication-token" + check_path: "%sylius.security.new_api_admin_route%/administrators/token" username_path: email password_path: password success_handler: lexik_jwt_authentication.handler.authentication_success failure_handler: lexik_jwt_authentication.handler.authentication_failure - guard: - authenticators: - - lexik_jwt_authentication.jwt_token_authenticator + jwt: true new_api_shop_user: - pattern: "%sylius.security.new_api_route%/shop-user-authentication-token" - provider: sylius_shop_user_provider + pattern: "%sylius.security.new_api_shop_regex%/.*" + provider: sylius_api_shop_user_provider stateless: true - anonymous: true + entry_point: jwt json_login: - check_path: "%sylius.security.new_api_route%/shop-user-authentication-token" + check_path: "%sylius.security.new_api_shop_route%/customers/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 + jwt: true shop: switch_user: { role: ROLE_ALLOWED_TO_SWITCH } @@ -108,7 +80,7 @@ security: default_target_path: sylius_shop_homepage use_forward: false use_referer: true - csrf_token_generator: security.csrf.token_manager + enable_csrf: true csrf_parameter: _csrf_shop_security_token csrf_token_id: shop_authenticate remember_me: @@ -118,31 +90,35 @@ security: remember_me_parameter: _remember_me logout: path: sylius_shop_logout - target: sylius_shop_login + target: sylius_shop_homepage invalidate_session: false - success_handler: sylius.handler.shop_user_logout - anonymous: true dev: - pattern: ^/(_(profiler|wdt)|css|images|js)/ + 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: IS_AUTHENTICATED_ANONYMOUSLY, ips: [127.0.0.1, ::1] } + - { path: "%sylius.security.admin_regex%/_partial", role: PUBLIC_ACCESS, ips: [127.0.0.1, ::1] } - { path: "%sylius.security.admin_regex%/_partial", role: ROLE_NO_ACCESS } - - { path: "%sylius.security.shop_regex%/_partial", role: IS_AUTHENTICATED_ANONYMOUSLY, ips: [127.0.0.1, ::1] } + - { path: "%sylius.security.shop_regex%/_partial", role: PUBLIC_ACCESS, ips: [127.0.0.1, ::1] } - { path: "%sylius.security.shop_regex%/_partial", role: ROLE_NO_ACCESS } - - { path: "%sylius.security.admin_regex%/login", role: IS_AUTHENTICATED_ANONYMOUSLY } - - { path: "%sylius.security.api_regex%/login", role: IS_AUTHENTICATED_ANONYMOUSLY } - - { path: "%sylius.security.shop_regex%/login", role: IS_AUTHENTICATED_ANONYMOUSLY } + - { path: "%sylius.security.admin_regex%/login", role: PUBLIC_ACCESS } + - { path: "%sylius.security.shop_regex%/login", role: PUBLIC_ACCESS } - - { path: "%sylius.security.shop_regex%/register", role: IS_AUTHENTICATED_ANONYMOUSLY } - - { path: "%sylius.security.shop_regex%/verify", role: IS_AUTHENTICATED_ANONYMOUSLY } + - { path: "%sylius.security.shop_regex%/register", role: PUBLIC_ACCESS } + - { path: "%sylius.security.shop_regex%/verify", role: PUBLIC_ACCESS } - { path: "%sylius.security.admin_regex%", role: ROLE_ADMINISTRATION_ACCESS } - - { path: "%sylius.security.api_regex%/.*", role: ROLE_API_ACCESS } - { path: "%sylius.security.shop_regex%/account", role: ROLE_USER } + - { path: "%sylius.security.new_api_admin_route%/administrators/reset-password", role: PUBLIC_ACCESS } - { path: "%sylius.security.new_api_admin_regex%/.*", role: ROLE_API_ACCESS } - - { path: "%sylius.security.new_api_shop_regex%/.*", role: IS_AUTHENTICATED_ANONYMOUSLY } + - { path: "%sylius.security.new_api_admin_route%/administrators/token", role: PUBLIC_ACCESS } + - { path: "%sylius.security.new_api_user_account_regex%/.*", role: ROLE_USER } + - { path: "%sylius.security.new_api_shop_route%/customers/token", role: PUBLIC_ACCESS } + - { path: "%sylius.security.new_api_shop_regex%/.*", role: PUBLIC_ACCESS } diff --git a/tests/Application/config/sylius/1.8/bundles.php b/tests/Application/config/sylius/1.8/bundles.php deleted file mode 100644 index 161339d..0000000 --- a/tests/Application/config/sylius/1.8/bundles.php +++ /dev/null @@ -1,10 +0,0 @@ - ['all' => true], - WhiteOctober\PagerfantaBundle\WhiteOctoberPagerfantaBundle::class => ['all' => true], - FOS\OAuthServerBundle\FOSOAuthServerBundle::class => ['all' => true], - Sylius\Bundle\AdminApiBundle\SyliusAdminApiBundle::class => ['all' => true], -]; diff --git a/tests/Application/config/sylius/1.8/packages/_sylius.yaml b/tests/Application/config/sylius/1.8/packages/_sylius.yaml deleted file mode 100644 index 1674a97..0000000 --- a/tests/Application/config/sylius/1.8/packages/_sylius.yaml +++ /dev/null @@ -1,2 +0,0 @@ -imports: - - { resource: "@SyliusAdminApiBundle/Resources/config/app/config.yml" } diff --git a/tests/Application/config/sylius/1.8/packages/dev/jms_serializer.yaml b/tests/Application/config/sylius/1.8/packages/dev/jms_serializer.yaml deleted file mode 100644 index 353e460..0000000 --- a/tests/Application/config/sylius/1.8/packages/dev/jms_serializer.yaml +++ /dev/null @@ -1,7 +0,0 @@ -jms_serializer: - visitors: - json: - options: - - JSON_PRETTY_PRINT - - JSON_UNESCAPED_SLASHES - - JSON_PRESERVE_ZERO_FRACTION diff --git a/tests/Application/config/sylius/1.8/packages/jms_serializer.yaml b/tests/Application/config/sylius/1.8/packages/jms_serializer.yaml deleted file mode 100644 index 64dd8d1..0000000 --- a/tests/Application/config/sylius/1.8/packages/jms_serializer.yaml +++ /dev/null @@ -1,4 +0,0 @@ -jms_serializer: - visitors: - xml: - format_output: '%kernel.debug%' diff --git a/tests/Application/config/sylius/1.8/packages/prod/jms_serializer.yaml b/tests/Application/config/sylius/1.8/packages/prod/jms_serializer.yaml deleted file mode 100644 index bc97faf..0000000 --- a/tests/Application/config/sylius/1.8/packages/prod/jms_serializer.yaml +++ /dev/null @@ -1,6 +0,0 @@ -jms_serializer: - visitors: - json: - options: - - JSON_UNESCAPED_SLASHES - - JSON_PRESERVE_ZERO_FRACTION diff --git a/tests/Application/config/sylius/1.8/packages/security.yaml b/tests/Application/config/sylius/1.8/packages/security.yaml deleted file mode 100644 index 8161bda..0000000 --- a/tests/Application/config/sylius/1.8/packages/security.yaml +++ /dev/null @@ -1,159 +0,0 @@ -parameters: - sylius.security.admin_regex: "^/%sylius_admin.path_name%" - sylius.security.api_regex: "^/api" - sylius.security.shop_regex: "^/(?!%sylius_admin.path_name%|new-api|api/.*|api$|media/.*)[^/]++" - sylius.security.new_api_route: "/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 - - oauth_token: - pattern: "%sylius.security.api_regex%/oauth/v2/token" - security: false - - new_api_admin_user: - pattern: "%sylius.security.new_api_route%/admin-user-authentication-token" - provider: sylius_admin_user_provider - stateless: true - anonymous: true - json_login: - check_path: "%sylius.security.new_api_route%/admin-user-authentication-token" - username_path: email - password_path: password - success_handler: lexik_jwt_authentication.handler.authentication_success - failure_handler: lexik_jwt_authentication.handler.authentication_failure - guard: - authenticators: - - lexik_jwt_authentication.jwt_token_authenticator - - new_api_shop_user: - pattern: "%sylius.security.new_api_route%/shop-user-authentication-token" - provider: sylius_shop_user_provider - stateless: true - anonymous: true - json_login: - check_path: "%sylius.security.new_api_route%/shop-user-authentication-token" - username_path: email - password_path: password - success_handler: lexik_jwt_authentication.handler.authentication_success - failure_handler: lexik_jwt_authentication.handler.authentication_failure - guard: - authenticators: - - lexik_jwt_authentication.jwt_token_authenticator - - new_api: - pattern: "%sylius.security.new_api_regex%/*" - provider: sylius_api_chain_provider - stateless: true - anonymous: lazy - guard: - authenticators: - - lexik_jwt_authentication.jwt_token_authenticator - - api: - pattern: "%sylius.security.api_regex%/.*" - provider: sylius_admin_user_provider - fos_oauth: true - stateless: true - anonymous: true - - shop: - switch_user: { role: ROLE_ALLOWED_TO_SWITCH } - context: shop - pattern: "%sylius.security.shop_regex%" - provider: sylius_shop_user_provider - form_login: - success_handler: sylius.authentication.success_handler - failure_handler: sylius.authentication.failure_handler - provider: sylius_shop_user_provider - login_path: sylius_shop_login - check_path: sylius_shop_login_check - failure_path: sylius_shop_login - default_target_path: sylius_shop_homepage - use_forward: false - use_referer: true - csrf_token_generator: security.csrf.token_manager - csrf_parameter: _csrf_shop_security_token - csrf_token_id: shop_authenticate - remember_me: - secret: "%env(APP_SECRET)%" - name: APP_SHOP_REMEMBER_ME - lifetime: 31536000 - remember_me_parameter: _remember_me - logout: - path: sylius_shop_logout - target: sylius_shop_login - invalidate_session: false - success_handler: sylius.handler.shop_user_logout - anonymous: true - - dev: - pattern: ^/(_(profiler|wdt)|css|images|js)/ - security: false - - access_control: - - { path: "%sylius.security.admin_regex%/_partial", role: IS_AUTHENTICATED_ANONYMOUSLY, ips: [127.0.0.1, ::1] } - - { path: "%sylius.security.admin_regex%/_partial", role: ROLE_NO_ACCESS } - - { path: "%sylius.security.shop_regex%/_partial", role: IS_AUTHENTICATED_ANONYMOUSLY, ips: [127.0.0.1, ::1] } - - { path: "%sylius.security.shop_regex%/_partial", role: ROLE_NO_ACCESS } - - - { path: "%sylius.security.admin_regex%/login", role: IS_AUTHENTICATED_ANONYMOUSLY } - - { path: "%sylius.security.api_regex%/login", role: IS_AUTHENTICATED_ANONYMOUSLY } - - { path: "%sylius.security.shop_regex%/login", role: IS_AUTHENTICATED_ANONYMOUSLY } - - - { path: "%sylius.security.shop_regex%/register", role: IS_AUTHENTICATED_ANONYMOUSLY } - - { path: "%sylius.security.shop_regex%/verify", role: IS_AUTHENTICATED_ANONYMOUSLY } - - - { path: "%sylius.security.admin_regex%", role: ROLE_ADMINISTRATION_ACCESS } - - { path: "%sylius.security.api_regex%/.*", role: ROLE_API_ACCESS } - - { path: "%sylius.security.shop_regex%/account", role: ROLE_USER } - - - { path: "%sylius.security.new_api_admin_regex%/.*", role: ROLE_API_ACCESS } - - { path: "%sylius.security.new_api_shop_regex%/.*", role: IS_AUTHENTICATED_ANONYMOUSLY } diff --git a/tests/Application/config/sylius/1.8/routes/dev/twig.yaml b/tests/Application/config/sylius/1.8/routes/dev/twig.yaml deleted file mode 100644 index f4ee839..0000000 --- a/tests/Application/config/sylius/1.8/routes/dev/twig.yaml +++ /dev/null @@ -1,3 +0,0 @@ -_errors: - resource: '@TwigBundle/Resources/config/routing/errors.xml' - prefix: /_error diff --git a/tests/Application/config/sylius/1.8/routes/sylius_admin_api.yaml b/tests/Application/config/sylius/1.8/routes/sylius_admin_api.yaml deleted file mode 100644 index 80aed45..0000000 --- a/tests/Application/config/sylius/1.8/routes/sylius_admin_api.yaml +++ /dev/null @@ -1,3 +0,0 @@ -sylius_admin_api: - resource: "@SyliusAdminApiBundle/Resources/config/routing.yml" - prefix: /api diff --git a/tests/Application/config/sylius/1.9/bundles.php b/tests/Application/config/sylius/1.9/bundles.php deleted file mode 100644 index 36137b9..0000000 --- a/tests/Application/config/sylius/1.9/bundles.php +++ /dev/null @@ -1,10 +0,0 @@ - ['all' => true], - SyliusLabs\Polyfill\Symfony\Security\Bundle\SyliusLabsPolyfillSymfonySecurityBundle::class => ['all' => true], - FOS\OAuthServerBundle\FOSOAuthServerBundle::class => ['all' => true], - Sylius\Bundle\AdminApiBundle\SyliusAdminApiBundle::class => ['all' => true], -]; diff --git a/tests/Application/config/sylius/1.9/packages/_sylius.yaml b/tests/Application/config/sylius/1.9/packages/_sylius.yaml deleted file mode 100644 index 1674a97..0000000 --- a/tests/Application/config/sylius/1.9/packages/_sylius.yaml +++ /dev/null @@ -1,2 +0,0 @@ -imports: - - { resource: "@SyliusAdminApiBundle/Resources/config/app/config.yml" } diff --git a/tests/Application/config/sylius/1.9/packages/dev/jms_serializer.yaml b/tests/Application/config/sylius/1.9/packages/dev/jms_serializer.yaml deleted file mode 100644 index 2f32a9b..0000000 --- a/tests/Application/config/sylius/1.9/packages/dev/jms_serializer.yaml +++ /dev/null @@ -1,12 +0,0 @@ -jms_serializer: - visitors: - json_serialization: - options: - - JSON_PRETTY_PRINT - - JSON_UNESCAPED_SLASHES - - JSON_PRESERVE_ZERO_FRACTION - json_deserialization: - options: - - JSON_PRETTY_PRINT - - JSON_UNESCAPED_SLASHES - - JSON_PRESERVE_ZERO_FRACTION diff --git a/tests/Application/config/sylius/1.9/packages/jms_serializer.yaml b/tests/Application/config/sylius/1.9/packages/jms_serializer.yaml deleted file mode 100644 index ed7bc61..0000000 --- a/tests/Application/config/sylius/1.9/packages/jms_serializer.yaml +++ /dev/null @@ -1,4 +0,0 @@ -jms_serializer: - visitors: - xml_serialization: - format_output: '%kernel.debug%' diff --git a/tests/Application/config/sylius/1.9/packages/prod/jms_serializer.yaml b/tests/Application/config/sylius/1.9/packages/prod/jms_serializer.yaml deleted file mode 100644 index c288182..0000000 --- a/tests/Application/config/sylius/1.9/packages/prod/jms_serializer.yaml +++ /dev/null @@ -1,10 +0,0 @@ -jms_serializer: - visitors: - json_serialization: - options: - - JSON_UNESCAPED_SLASHES - - JSON_PRESERVE_ZERO_FRACTION - json_deserialization: - options: - - JSON_UNESCAPED_SLASHES - - JSON_PRESERVE_ZERO_FRACTION diff --git a/tests/Application/config/sylius/1.9/packages/security.yaml b/tests/Application/config/sylius/1.9/packages/security.yaml deleted file mode 100644 index 8161bda..0000000 --- a/tests/Application/config/sylius/1.9/packages/security.yaml +++ /dev/null @@ -1,159 +0,0 @@ -parameters: - sylius.security.admin_regex: "^/%sylius_admin.path_name%" - sylius.security.api_regex: "^/api" - sylius.security.shop_regex: "^/(?!%sylius_admin.path_name%|new-api|api/.*|api$|media/.*)[^/]++" - sylius.security.new_api_route: "/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 - - oauth_token: - pattern: "%sylius.security.api_regex%/oauth/v2/token" - security: false - - new_api_admin_user: - pattern: "%sylius.security.new_api_route%/admin-user-authentication-token" - provider: sylius_admin_user_provider - stateless: true - anonymous: true - json_login: - check_path: "%sylius.security.new_api_route%/admin-user-authentication-token" - username_path: email - password_path: password - success_handler: lexik_jwt_authentication.handler.authentication_success - failure_handler: lexik_jwt_authentication.handler.authentication_failure - guard: - authenticators: - - lexik_jwt_authentication.jwt_token_authenticator - - new_api_shop_user: - pattern: "%sylius.security.new_api_route%/shop-user-authentication-token" - provider: sylius_shop_user_provider - stateless: true - anonymous: true - json_login: - check_path: "%sylius.security.new_api_route%/shop-user-authentication-token" - username_path: email - password_path: password - success_handler: lexik_jwt_authentication.handler.authentication_success - failure_handler: lexik_jwt_authentication.handler.authentication_failure - guard: - authenticators: - - lexik_jwt_authentication.jwt_token_authenticator - - new_api: - pattern: "%sylius.security.new_api_regex%/*" - provider: sylius_api_chain_provider - stateless: true - anonymous: lazy - guard: - authenticators: - - lexik_jwt_authentication.jwt_token_authenticator - - api: - pattern: "%sylius.security.api_regex%/.*" - provider: sylius_admin_user_provider - fos_oauth: true - stateless: true - anonymous: true - - shop: - switch_user: { role: ROLE_ALLOWED_TO_SWITCH } - context: shop - pattern: "%sylius.security.shop_regex%" - provider: sylius_shop_user_provider - form_login: - success_handler: sylius.authentication.success_handler - failure_handler: sylius.authentication.failure_handler - provider: sylius_shop_user_provider - login_path: sylius_shop_login - check_path: sylius_shop_login_check - failure_path: sylius_shop_login - default_target_path: sylius_shop_homepage - use_forward: false - use_referer: true - csrf_token_generator: security.csrf.token_manager - csrf_parameter: _csrf_shop_security_token - csrf_token_id: shop_authenticate - remember_me: - secret: "%env(APP_SECRET)%" - name: APP_SHOP_REMEMBER_ME - lifetime: 31536000 - remember_me_parameter: _remember_me - logout: - path: sylius_shop_logout - target: sylius_shop_login - invalidate_session: false - success_handler: sylius.handler.shop_user_logout - anonymous: true - - dev: - pattern: ^/(_(profiler|wdt)|css|images|js)/ - security: false - - access_control: - - { path: "%sylius.security.admin_regex%/_partial", role: IS_AUTHENTICATED_ANONYMOUSLY, ips: [127.0.0.1, ::1] } - - { path: "%sylius.security.admin_regex%/_partial", role: ROLE_NO_ACCESS } - - { path: "%sylius.security.shop_regex%/_partial", role: IS_AUTHENTICATED_ANONYMOUSLY, ips: [127.0.0.1, ::1] } - - { path: "%sylius.security.shop_regex%/_partial", role: ROLE_NO_ACCESS } - - - { path: "%sylius.security.admin_regex%/login", role: IS_AUTHENTICATED_ANONYMOUSLY } - - { path: "%sylius.security.api_regex%/login", role: IS_AUTHENTICATED_ANONYMOUSLY } - - { path: "%sylius.security.shop_regex%/login", role: IS_AUTHENTICATED_ANONYMOUSLY } - - - { path: "%sylius.security.shop_regex%/register", role: IS_AUTHENTICATED_ANONYMOUSLY } - - { path: "%sylius.security.shop_regex%/verify", role: IS_AUTHENTICATED_ANONYMOUSLY } - - - { path: "%sylius.security.admin_regex%", role: ROLE_ADMINISTRATION_ACCESS } - - { path: "%sylius.security.api_regex%/.*", role: ROLE_API_ACCESS } - - { path: "%sylius.security.shop_regex%/account", role: ROLE_USER } - - - { path: "%sylius.security.new_api_admin_regex%/.*", role: ROLE_API_ACCESS } - - { path: "%sylius.security.new_api_shop_regex%/.*", role: IS_AUTHENTICATED_ANONYMOUSLY } diff --git a/tests/Application/config/sylius/1.9/routes/sylius_admin_api.yaml b/tests/Application/config/sylius/1.9/routes/sylius_admin_api.yaml deleted file mode 100644 index 80aed45..0000000 --- a/tests/Application/config/sylius/1.9/routes/sylius_admin_api.yaml +++ /dev/null @@ -1,3 +0,0 @@ -sylius_admin_api: - resource: "@SyliusAdminApiBundle/Resources/config/routing.yml" - prefix: /api diff --git a/tests/Application/config/symfony/4.4/packages/framework.yaml b/tests/Application/config/symfony/4.4/packages/framework.yaml deleted file mode 100644 index 62f82d3..0000000 --- a/tests/Application/config/symfony/4.4/packages/framework.yaml +++ /dev/null @@ -1,2 +0,0 @@ -framework: - templating: { engines: ["twig"] } diff --git a/tests/Application/package.json b/tests/Application/package.json index 1347083..d0f787a 100644 --- a/tests/Application/package.json +++ b/tests/Application/package.json @@ -2,7 +2,7 @@ "dependencies": { "axios": "^0.25.0", "babel-polyfill": "^6.26.0", - "chart.js": "^2.9.3", + "chart.js": "^3.7.1", "codemirror": "^5.65.1", "jquery": "^3.4.0", "jquery.dirtyforms": "^2.0.0", diff --git a/tests/Application/public/media/image/.gitignore b/tests/Application/public/media/image/.gitignore deleted file mode 100644 index e69de29..0000000 diff --git a/tests/Behat/Context/Setup/EmailTemplateContext.php b/tests/Behat/Context/Setup/EmailTemplateContext.php index 894c7c4..c40f6f1 100644 --- a/tests/Behat/Context/Setup/EmailTemplateContext.php +++ b/tests/Behat/Context/Setup/EmailTemplateContext.php @@ -32,7 +32,7 @@ public function __construct( SharedStorageInterface $sharedStorage, FactoryInterface $templateFactory, FactoryInterface $templateTranslationFactory, - EmailTemplateTranslationRepositoryInterface $emailTemplateTranslationRepository + EmailTemplateTranslationRepositoryInterface $emailTemplateTranslationRepository, ) { $this->sharedStorage = $sharedStorage; $this->templateFactory = $templateFactory; @@ -47,7 +47,7 @@ public function thereIsMailTemplateWithTypeAndNameAndSubjectAndContent( string $type, string $name, string $subject, - string $content + string $content, ): void { $emailTemplate = $this->createEmailTemplate($type, $name, $subject, $content); @@ -62,7 +62,7 @@ public function thereIsMailTemplateWithTypeAndNameAndSubjectAndContentAndLocale( string $name, string $subject, string $content, - string $locale + string $locale, ): void { $emailTemplate = $this->createEmailTemplate($type, $name, $subject, $content, $locale); @@ -74,7 +74,7 @@ private function createEmailTemplate( ?string $name = null, ?string $subject = null, ?string $content = null, - ?string $locale = null + ?string $locale = null, ): EmailTemplateInterface { /** @var EmailTemplateTranslationInterface $emailTemplateTranslation */ $emailTemplateTranslation = $this->templateTranslationFactory->createNew(); diff --git a/tests/Behat/Context/Ui/Admin/EmailTemplateContext.php b/tests/Behat/Context/Ui/Admin/EmailTemplateContext.php index 3682410..cc8ebf9 100644 --- a/tests/Behat/Context/Ui/Admin/EmailTemplateContext.php +++ b/tests/Behat/Context/Ui/Admin/EmailTemplateContext.php @@ -1,9 +1,10 @@ createPage = $createPage; $this->notificationChecker = $notificationChecker; @@ -88,7 +89,7 @@ public function iShouldBeNotifiedThatTheEmailTemplateHasBeenSuccessfullyCreated( { $this->notificationChecker->checkNotification( 'Email template has been successfully created.', - NotificationType::success() + NotificationType::success(), ); } @@ -119,7 +120,7 @@ public function iAmOnTheEmailTemplatesList(): void /** * @Given /^I have added all of custom email types$/ */ - public function iHaveAddedAllOfCustomEmailTypes() + public function iHaveAddedAllOfCustomEmailTypes(): void { $this->addAllCustomEmailTypesInDatabase(); } @@ -173,9 +174,9 @@ private function addAllCustomEmailTypesInDatabase(): void 'remove_existing' => false, 'translations' => [ 'en_US' => [ - 'name' => "Name for ${type} type", - 'subject' => "Subject for ${type} type", - 'content' => "Content for ${type} type", + 'name' => "Name for {$type} type", + 'subject' => "Subject for {$type} type", + 'content' => "Content for {$type} type", ], ], ]; diff --git a/tests/Behat/Context/Ui/EmailTemplateContext.php b/tests/Behat/Context/Ui/EmailTemplateContext.php index a1be79d..8e0edc8 100644 --- a/tests/Behat/Context/Ui/EmailTemplateContext.php +++ b/tests/Behat/Context/Ui/EmailTemplateContext.php @@ -12,10 +12,13 @@ namespace Tests\BitBag\SyliusMailTemplatePlugin\Behat\Context\Ui; use Behat\Behat\Context\Context; +use Sylius\Behat\Service\Checker\EmailCheckerInterface; use Sylius\Behat\Service\SharedStorageInterface; +use Sylius\Bundle\CoreBundle\SyliusCoreBundle; +use Sylius\Component\Core\Model\CustomerInterface; use Sylius\Component\Core\Model\OrderInterface; use Sylius\Component\Core\Model\ShipmentInterface; -use Sylius\Component\Core\Test\Services\EmailCheckerInterface; +use Sylius\Component\Core\Model\ShippingMethodInterface; use Webmozart\Assert\Assert; final class EmailTemplateContext implements Context @@ -26,7 +29,7 @@ final class EmailTemplateContext implements Context public function __construct( SharedStorageInterface $sharedStorage, - EmailCheckerInterface $emailChecker + EmailCheckerInterface $emailChecker, ) { $this->sharedStorage = $sharedStorage; $this->emailChecker = $emailChecker; @@ -49,9 +52,9 @@ public function aCustomEmailShouldBeSentTo(string $recipient, string $sender): v sprintf( '%s wrote %s', $sender, - 'Hi! I did not receive an item!' + 'Hi! I did not receive an item!', ), - $recipient + $recipient, ); } @@ -66,9 +69,9 @@ public function aDefaultEmailShouldBeSentTo(string $recipient, string $sender): 'Message from', $sender, 'Content', - 'Hi! I did not receive an item!' + 'Hi! I did not receive an item!', ), - $recipient + $recipient, ); } @@ -80,7 +83,7 @@ public function aDefaultEmailWithResetTokenShouldBeSentTo(string $recipient, str { $this->assertEmailContainsMessageTo( 'To reset your password - click the link below', - $recipient + $recipient, ); } @@ -92,7 +95,7 @@ public function aCustomEmailWithResetTokenShouldBeSentTo(string $recipient, stri { $this->assertEmailContainsMessageTo( 'Wanna reset password? Here is your code:', - $recipient + $recipient, ); } @@ -102,15 +105,15 @@ public function aCustomEmailWithResetTokenShouldBeSentTo(string $recipient, stri public function anEmailWithShipmentsConfirmationForTheOrderShouldBeSentTo( string $method, string $orderNumber, - string $recipient + string $recipient, ): void { Assert::true($this->emailChecker->hasMessageTo( sprintf( 'Your order with number %s has been sent using %s.', $orderNumber, - $method + $method, ), - $recipient + $recipient, )); } @@ -121,7 +124,7 @@ public function aDefaultAccountVerificationEmailShouldHaveBeenSentTo(string $rec { $this->assertEmailContainsMessageTo( 'To verify your email address - click the link below', - $recipient + $recipient, ); } @@ -132,7 +135,7 @@ public function aCustomAccountVerificationEmailShouldHaveBeenSentTo(string $reci { $this->assertEmailContainsMessageTo( 'Verify yourself. We need you!', - $recipient + $recipient, ); } @@ -144,6 +147,21 @@ public function numberOfEmailsShouldBeSentTo(int $count, string $recipient): voi Assert::same($this->emailChecker->countMessagesTo($recipient), $count); } + /** + * @Then email(s) should be sent to :recipient depending on Sylius version + */ + public function numberOfEmailsShouldBeSentToDependingOnSyliusVersion(string $recipient): void + { + $count = 1; + + /** @phpstan-ignore-next-line */ + if (13 !== (int) SyliusCoreBundle::MINOR_VERSION) { + $count = 2; + } + + Assert::same($this->emailChecker->countMessagesTo($recipient), $count); + } + /** * @Then a welcoming email should have been sent to :recipient * @Then a welcoming email should have been sent to :recipient in :localeCode locale @@ -152,7 +170,7 @@ public function aWelcomingEmailShouldHaveBeenSentTo(string $recipient, string $l { $this->assertEmailContainsMessageTo( 'Enjoy our stuff!', - $recipient + $recipient, ); } @@ -163,8 +181,8 @@ public function aWelcomingEmailShouldHaveBeenSentTo(string $recipient, string $l public function aDefaultWelcomingEmailShouldHaveBeenSentTo(string $recipient, string $localeCode = 'en_US'): void { $this->assertEmailContainsMessageTo( - 'You have just been registered. Thank you', - $recipient + 'To verify your email address - click the link below', + $recipient, ); } @@ -175,15 +193,15 @@ public function aDefaultWelcomingEmailShouldHaveBeenSentTo(string $recipient, st public function anEmailWithTheConfirmationOfTheOrderShouldBeSentTo( OrderInterface $order, string $recipient, - string $localeCode = 'en_US' + string $localeCode = 'en_US', ): void { $this->assertEmailContainsMessageTo( sprintf( '%s %s', 'Pif paf', - $order->getNumber() + $order->getNumber(), ), - $recipient + $recipient, ); } @@ -194,16 +212,16 @@ public function anEmailWithTheConfirmationOfTheOrderShouldBeSentTo( public function aDefaultEmailWithTheConfirmationOfTheOrderShouldBeSentTo( OrderInterface $order, string $recipient, - string $localeCode = 'en_US' + string $localeCode = 'en_US', ): void { $this->assertEmailContainsMessageTo( sprintf( '%s %s %s', 'Your order no.', $order->getNumber(), - 'has been successfully placed.' + 'has been successfully placed.', ), - $recipient + $recipient, ); } @@ -213,7 +231,15 @@ public function aDefaultEmailWithTheConfirmationOfTheOrderShouldBeSentTo( */ public function anEmailWithSummaryOfOrderPlacedByShouldBeSentTo(OrderInterface $order, string $localeCode = 'en_US'): void { - $this->anEmailWithTheConfirmationOfTheOrderShouldBeSentTo($order, $order->getCustomer()->getEmailCanonical(), $localeCode); + /** @var ?CustomerInterface $customer */ + $customer = $order->getCustomer(); + Assert::notNull($customer); + + /** @var ?string $email */ + $email = $customer->getEmailCanonical(); + Assert::notNull($email); + + $this->anEmailWithTheConfirmationOfTheOrderShouldBeSentTo($order, $email, $localeCode); } /** @@ -222,7 +248,15 @@ public function anEmailWithSummaryOfOrderPlacedByShouldBeSentTo(OrderInterface $ */ public function aDefaultEmailWithSummaryOfOrderPlacedByShouldBeSentTo(OrderInterface $order, string $localeCode = 'en_US'): void { - $this->aDefaultEmailWithTheConfirmationOfTheOrderShouldBeSentTo($order, $order->getCustomer()->getEmailCanonical(), $localeCode); + /** @var ?CustomerInterface $customer */ + $customer = $order->getCustomer(); + Assert::notNull($customer); + + /** @var ?string $email */ + $email = $customer->getEmailCanonical(); + Assert::notNull($email); + + $this->aDefaultEmailWithTheConfirmationOfTheOrderShouldBeSentTo($order, $email, $localeCode); } /** @@ -232,11 +266,11 @@ public function aDefaultEmailWithSummaryOfOrderPlacedByShouldBeSentTo(OrderInter public function aDefaultEmailWithShipmentDetailsOfOrderShouldBeSentTo( OrderInterface $order, string $recipient, - string $localeCode = 'en_US' + string $localeCode = 'en_US', ): void { $this->assertEmailContainsMessageTo( 'Thank you for a successful transaction.', - $recipient + $recipient, ); } @@ -249,22 +283,22 @@ public function aDefaultEmailWithShipmentDetailsOfOrderShouldBeSentTo( public function anEmailWithShipmentDetailsOfOrderShouldBeSentTo( OrderInterface $order, string $recipient, - string $localeCode = 'en_US' + string $localeCode = 'en_US', ): void { $this->assertEmailContainsMessageTo( sprintf( '%s %s %s', 'Enjoy your new stuff!', $order->getNumber(), - $this->getShippingMethodName($order) + $this->getShippingMethodName($order), ), - $recipient + $recipient, ); if ($this->sharedStorage->has('tracking_code')) { $this->assertEmailContainsMessageTo( $this->sharedStorage->get('tracking_code'), - $recipient + $recipient, ); } } @@ -282,6 +316,12 @@ private function getShippingMethodName(OrderInterface $order): string throw new \LogicException('Order should have at least one shipment.'); } - return $shipment->getMethod()->getName(); + /** @var ?ShippingMethodInterface $shippingMethod */ + $shippingMethod = $shipment->getMethod(); + Assert::notNull($shippingMethod); + + Assert::notNull($shippingMethod->getName()); + + return $shippingMethod->getName(); } } diff --git a/tests/Behat/Context/Ui/LoginContext.php b/tests/Behat/Context/Ui/LoginContext.php index 13a5668..92544cb 100644 --- a/tests/Behat/Context/Ui/LoginContext.php +++ b/tests/Behat/Context/Ui/LoginContext.php @@ -54,7 +54,7 @@ public function __construct( WellKnownPasswordChangePageInterface $wellKnownPasswordChangePage, RegisterElementInterface $registerElement, NotificationCheckerInterface $notificationChecker, - CurrentPageResolverInterface $currentPageResolver + CurrentPageResolverInterface $currentPageResolver, ) { $this->homePage = $homePage; $this->loginPage = $loginPage; @@ -104,6 +104,10 @@ public function iFollowLinkOnMyEmailToResetPassword(UserInterface $user): void */ public function iSpecifyTheUsername(?string $username = null): void { + if (null === $username) { + throw new \InvalidArgumentException('Username cannot be null.'); + } + $this->loginPage->specifyUsername($username); } @@ -122,6 +126,10 @@ public function iSpecifyTheEmail(?string $email = null): void */ public function iSpecifyThePasswordAs(?string $password = null): void { + if (null === $password) { + throw new \InvalidArgumentException('Password cannot be null.'); + } + $this->loginPage->specifyPassword($password); } @@ -131,6 +139,10 @@ public function iSpecifyThePasswordAs(?string $password = null): void */ public function iSpecifyMyNewPassword(?string $password = null): void { + if (null === $password) { + throw new \InvalidArgumentException('Password cannot be null.'); + } + $this->resetPasswordPage->specifyNewPassword($password); } @@ -140,6 +152,10 @@ public function iSpecifyMyNewPassword(?string $password = null): void */ public function iConfirmMyNewPassword(?string $password = null): void { + if (null === $password) { + throw new \InvalidArgumentException('Password cannot be null.'); + } + $this->resetPasswordPage->specifyConfirmPassword($password); } @@ -239,14 +255,14 @@ public function iShouldBeNotifiedThatEmailWithResetInstructionWasSent(): void { $this->notificationChecker->checkNotification( 'If the email you have specified exists in our system, we have sent there an instruction on how to reset your password.', - NotificationType::success() + NotificationType::success(), ); } /** * @Then I should be notified that the :elementName is required */ - public function iShouldBeNotifiedThatElementIsRequired($elementName) + public function iShouldBeNotifiedThatElementIsRequired(string $elementName): void { Assert::true($this->requestPasswordResetPage->checkValidationMessageFor($elementName, sprintf('Please enter your %s.', $elementName))); } @@ -280,7 +296,7 @@ public function iShouldBeNotifiedThatTheEnteredPasswordsDoNotMatch(): void { Assert::true($this->resetPasswordPage->checkValidationMessageFor( 'password', - 'The entered passwords don\'t match' + 'The entered passwords don\'t match', )); } @@ -291,7 +307,7 @@ public function iShouldBeNotifiedThatThePasswordShouldBeAtLeastCharactersLong(): { Assert::true($this->resetPasswordPage->checkValidationMessageFor( 'password', - 'Password must be at least 4 characters long.' + 'Password must be at least 4 characters long.', )); } diff --git a/tests/Behat/Element/Admin/PreviewModalElement.php b/tests/Behat/Element/Admin/PreviewModalElement.php index 108f58e..458b366 100644 --- a/tests/Behat/Element/Admin/PreviewModalElement.php +++ b/tests/Behat/Element/Admin/PreviewModalElement.php @@ -1,9 +1,10 @@ getDriver()->executeScript( - sprintf('document.querySelector("[name=\'%s\']").value = "%s";', $field, $value) + sprintf('document.querySelector("[name=\'%s\']").value = "%s";', $field, $value), ); } public function preview(string $locale): void { - $this->getDocument()->find('css', sprintf('[data-locale="%s"] .bitbag_preview_mail_template', $locale))->click(); + /** @var ?NodeElement $node */ + $node = $this->getDocument()->find('css', sprintf('[data-locale="%s"] .bitbag_preview_mail_template', $locale)); + + if (null === $node) { + throw new NodeException(); + } + + $node->click(); } /** @@ -66,9 +76,11 @@ public function preview(string $locale): void */ public function checkHasPreviewModal(string $subject, string $content): void { - $this->getDriver()->wait(300, 'document.querySelector(".mail-preview").offsetParent !== null'); + $this->getDriver()->wait(3000, 'document.querySelector(".mail-preview").offsetParent !== null'); Assert::true($this->previewModal->isModalVisible()); + /** @phpstan-ignore-next-line */ Assert::contains($this->previewModal->getSubject(), $subject); + /** @phpstan-ignore-next-line */ Assert::contains($this->previewModal->getContent(), $content); } } diff --git a/tests/Behat/Page/Admin/EmailTemplate/CreatePageInterface.php b/tests/Behat/Page/Admin/EmailTemplate/CreatePageInterface.php index df70acd..3113877 100644 --- a/tests/Behat/Page/Admin/EmailTemplate/CreatePageInterface.php +++ b/tests/Behat/Page/Admin/EmailTemplate/CreatePageInterface.php @@ -1,9 +1,10 @@ getContainer(); $this->emailTemplateRepository = $container->get('bitbag_sylius_mail_template_plugin.custom_repository.email_template'); $this->emailCodesProvider = $container->get('bitbag_sylius_mail_template_plugin.provider.email_codes'); @@ -64,7 +65,7 @@ public function test_available_choices_by_email_template(): void Assert::assertEquals( count($choices) - 1, - count($this->emailCodesProvider->provideWithLabelsNotUsedTypes()) + count($this->emailCodesProvider->provideWithLabelsNotUsedTypes()), ); } }