From 4a072273c6707979fa74c893ce77f52739762779 Mon Sep 17 00:00:00 2001 From: janpalen Date: Mon, 8 Jul 2024 10:55:53 +0200 Subject: [PATCH 01/15] OP-376 - Update dependencies --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 8b22ed0..ae9c680 100644 --- a/composer.json +++ b/composer.json @@ -8,8 +8,8 @@ "description": "Bonus points plugin for Sylius.", "license": "MIT", "require": { - "php": "^8.0", - "sylius/sylius": "~1.11.0 || ~1.12.0" + "php": "^8.1", + "sylius/sylius": "~1.12.0 || ~1.13.0" }, "require-dev": { "symfony/webpack-encore-bundle": "^1.14", From 796baf8381ca3e570fd3ed6eb5760d6d4ff77394 Mon Sep 17 00:00:00 2001 From: janpalen Date: Mon, 8 Jul 2024 11:06:35 +0200 Subject: [PATCH 02/15] OP-376 - Change build matrix --- .github/workflows/build.yml | 27 ++++++++------------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f69c7d7..e70417b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -14,29 +14,18 @@ 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] - symfony: [^5.4, ^6.0] - sylius: [~1.11.0, ~1.12.0] - node: [14.19] - mysql: [5.7, 8.0] - - exclude: - - - sylius: ~1.11.0 - symfony: ^6.0 - - - sylius: ~1.11.0 - php: 7.3 - - - sylius: ~1.11.0 - php: 7.4 + php: ["8.1", "8.2", "8.3"] + symfony: ["^5.4", "^6.0"] + sylius: ["~1.12.0", "~1.13.0"] + node: ["18.x", "20.x"] + mysql: ["5.7", "8.0"] env: APP_ENV: test @@ -182,8 +171,8 @@ jobs: name: Behat logs path: etc/build/ if-no-files-found: ignore - - - + + - name: Failed build Slack notification uses: rtCamp/action-slack-notify@v2 if: ${{ failure() && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master') }} From 382b31e34446aa0d41cf96543822cc9b17e341a5 Mon Sep 17 00:00:00 2001 From: janpalen Date: Mon, 8 Jul 2024 11:13:50 +0200 Subject: [PATCH 03/15] OP-376 - Change .env.test file --- tests/Application/.env.test | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/Application/.env.test b/tests/Application/.env.test index 003690d..36a1c38 100644 --- a/tests/Application/.env.test +++ b/tests/Application/.env.test @@ -1,5 +1,7 @@ +APP_ENV=test + APP_SECRET='ch4mb3r0f5ecr3ts' KERNEL_CLASS='Tests\BitBag\SyliusBonusPointsPlugin\Application\Kernel' -DATABASE_URL=mysql://root@127.0.0.1/sylius_bonus_points_%kernel.environment%?serverVersion=5.5 +DATABASE_URL=sqlite:///%kernel.project_dir%/var/data_%kernel.environment%.db From 77da6dda4a2b2bcc142f90c6b2105308b18f4c99 Mon Sep 17 00:00:00 2001 From: janpalen Date: Mon, 8 Jul 2024 13:13:51 +0200 Subject: [PATCH 04/15] OP-376 - Fix files for ECS --- composer.json | 13 ++++++------ ecs.php | 13 +++++++++--- src/Assigner/BonusPointsAssigner.php | 21 ++++++++++--------- src/Assigner/BonusPointsAssignerInterface.php | 9 ++++---- src/BitBagSyliusBonusPointsPlugin.php | 9 ++++---- ...BonusPointsStrategyCalculatorInterface.php | 9 ++++---- ...elegatingBonusPointsStrategyCalculator.php | 11 +++++----- ...BonusPointsStrategyCalculatorInterface.php | 9 ++++---- .../PerOrderItemPercentageCalculator.php | 11 +++++----- src/Calculator/PerOrderPriceCalculator.php | 11 +++++----- ...ntsStrategyEligibilityCheckerInterface.php | 9 ++++---- ...sPointsStrategyRulesEligibilityChecker.php | 9 ++++---- ...onusPointsStrategyRuleCheckerInterface.php | 9 ++++---- src/Checker/Rule/HasTaxonRuleChecker.php | 9 ++++---- src/Context/CustomerBonusPointsContext.php | 11 +++++----- .../CustomerBonusPointsContextInterface.php | 9 ++++---- .../ResetOrderBonusPointsAction.php | 11 +++++----- src/Creator/BonusPointsCreator.php | 13 ++++++------ src/Creator/BonusPointsCreatorInterface.php | 9 +++++++- ...sterBonusPointsStrategyCalculatorsPass.php | 9 ++++---- ...sterBonusPointsStrategyRuleCheckerPass.php | 9 ++++---- src/Entity/AdjustmentInterface.php | 9 ++++---- src/Entity/BonusPoints.php | 9 ++++---- src/Entity/BonusPointsAwareInterface.php | 9 ++++---- src/Entity/BonusPointsAwareTrait.php | 9 ++++---- src/Entity/BonusPointsInterface.php | 9 ++++---- src/Entity/BonusPointsStrategy.php | 10 ++++----- src/Entity/BonusPointsStrategyInterface.php | 9 ++++---- src/Entity/BonusPointsStrategyRule.php | 9 ++++---- .../BonusPointsStrategyRuleInterface.php | 9 ++++---- src/Entity/CustomerBonusPoints.php | 9 ++++---- src/Entity/CustomerBonusPointsInterface.php | 9 ++++---- .../OrderBonusPointsListener.php | 11 +++++----- src/Form/Extension/CartTypeExtension.php | 16 +++++++------- ...onfigurableBonusPointsStrategyRuleType.php | 12 ++++++----- .../AbstractConfigurationCollectionType.php | 13 ++++++------ ...onusPointsStrategyCalculatorChoiceType.php | 9 ++++---- .../BonusPointsStrategyRuleChoiceType.php | 9 ++++---- .../BonusPointsStrategyRuleCollectionType.php | 9 ++++---- src/Form/Type/BonusPointsStrategyRuleType.php | 9 ++++---- src/Form/Type/BonusPointsStrategyType.php | 11 +++++----- ...erOrderItemPercentageConfigurationType.php | 9 ++++---- ...erOrderItemPercentageConfigurationType.php | 9 ++++---- .../PerOrderPriceConfigurationType.php | 12 ++++++----- .../Type/Rule/HasTaxonConfigurationType.php | 9 ++++---- src/Menu/AdminMenuBuilder.php | 9 ++++---- .../OrderBonusPointsProcessor.php | 13 ++++++------ .../ResetOrderBonusPointsProcessor.php | 11 +++++----- ...esetOrderBonusPointsProcessorInterface.php | 9 ++++---- src/Purifier/OrderBonusPointsPurifier.php | 13 ++++++------ .../OrderBonusPointsPurifierInterface.php | 11 +++++----- src/Repository/BonusPointsRepository.php | 9 ++++---- .../BonusPointsRepositoryInterface.php | 9 ++++---- .../BonusPointsStrategyRepository.php | 9 ++++---- ...BonusPointsStrategyRepositoryInterface.php | 9 ++++---- src/Resolver/BonusPointsResolver.php | 13 ++++++------ src/Resolver/BonusPointsResolverInterface.php | 9 ++++---- src/Twig/Extension/BonusPointsExtension.php | 9 ++++---- .../Constraints/BonusPointsApply.php | 9 ++++---- .../Constraints/BonusPointsApplyValidator.php | 15 ++++++------- .../Constraints/BonusPointsAvailability.php | 9 ++++---- .../BonusPointsAvailabilityValidator.php | 12 ++++++----- 62 files changed, 358 insertions(+), 281 deletions(-) diff --git a/composer.json b/composer.json index ae9c680..40771b9 100644 --- a/composer.json +++ b/composer.json @@ -12,9 +12,9 @@ "sylius/sylius": "~1.12.0 || ~1.13.0" }, "require-dev": { - "symfony/webpack-encore-bundle": "^1.14", "behat/behat": "^3.6.1", "behat/mink-selenium2-driver": "^1.4", + "bitbag/coding-standard": "^3.0", "dmore/behat-chrome-extension": "^1.3", "dmore/chrome-mink-driver": "^2.7", "friends-of-behat/mink": "^1.8", @@ -27,18 +27,19 @@ "lakion/mink-debug-extension": "^2.0.0", "phpspec/phpspec": "^7.0", "phpstan/extension-installer": "^1.0", - "phpstan/phpstan": "0.12.88", - "phpstan/phpstan-doctrine": "0.12.37", - "phpstan/phpstan-strict-rules": "^0.12.0", - "phpstan/phpstan-webmozart-assert": "0.12.12", + "phpstan/phpstan": "1.4", + "phpstan/phpstan-doctrine": "^1.0", + "phpstan/phpstan-strict-rules": "^1.0", + "phpstan/phpstan-webmozart-assert": "^1.0", "phpunit/phpunit": "^9.5", + "polishsymfonycommunity/symfony-mocker-container": "^1.0", "sylius-labs/coding-standard": "^4.0", "symfony/browser-kit": "^5.4 || ^6.0", "symfony/debug-bundle": "^5.4 || ^6.0", "symfony/dotenv": "^5.4 || ^6.0", "symfony/intl": "^5.4 || ^6.0", "symfony/web-profiler-bundle": "^5.4 || ^6.0", - "polishsymfonycommunity/symfony-mocker-container": "^1.0" + "symfony/webpack-encore-bundle": "^1.14" }, "prefer-stable": true, "autoload": { diff --git a/ecs.php b/ecs.php index 337930e..4a3eb77 100644 --- a/ecs.php +++ b/ecs.php @@ -1,7 +1,14 @@ import('vendor/sylius-labs/coding-standard/ecs.php'); +use Symplify\EasyCodingStandard\Config\ECSConfig; + +return static function (ECSConfig $config): void { + + // Change this if you want to automatically add BitBag OpenSource Header + putenv('ALLOW_BITBAG_OS_HEADER=1'); + + $config->import('vendor/bitbag/coding-standard/ecs.php'); + $config->paths(['src', 'tests']); }; diff --git a/src/Assigner/BonusPointsAssigner.php b/src/Assigner/BonusPointsAssigner.php index 1676ced..f88e520 100644 --- a/src/Assigner/BonusPointsAssigner.php +++ b/src/Assigner/BonusPointsAssigner.php @@ -1,10 +1,11 @@ delegatingBonusPointsStrategyCalculator = $delegatingBonusPointsStrategyCalculator; $this->bonusPointsStrategyEligibilityChecker = $bonusPointsStrategyEligibilityChecker; @@ -143,7 +144,7 @@ private function getProportionalIntegerToDeduct(BonusPointsStrategyInterface $bo $totals[] = $item->getTotal(); } - if (count($totals) === 0) { + if (0 === count($totals)) { return []; } @@ -167,7 +168,7 @@ public function calculateBonusPointsPerOrder(BonusPointsStrategyInterface $bonus $splitAmountOrderItems = $this->getProportionalIntegerToDeduct( $bonusPointsStrategy, $order->getItems()->toArray(), - $order->getAdjustmentsTotal(AdjustmentInterface::ORDER_BONUS_POINTS_ADJUSTMENT) + $order->getAdjustmentsTotal(AdjustmentInterface::ORDER_BONUS_POINTS_ADJUSTMENT), ); } @@ -183,8 +184,8 @@ public function calculateBonusPointsPerOrder(BonusPointsStrategyInterface $bonus $bonusPointsTotal += $this->delegatingBonusPointsStrategyCalculator->calculate( $orderItem, $bonusPointsStrategy, - $bonusPointsStrategy->isDeductBonusPoints() && count($splitAmountOrderItems) > 0 ? - $splitAmountOrderItems[$orderItem->getId()] : 0 + $bonusPointsStrategy->isDeductBonusPoints() && 0 < count($splitAmountOrderItems) ? + $splitAmountOrderItems[$orderItem->getId()] : 0, ); } } @@ -212,7 +213,7 @@ public function calculateBonusPoints(OrderInterface $order, BonusPointsStrategyI $bonusPointsTotal += $this->delegatingBonusPointsStrategyCalculator->calculate( $eligibleProduct, $bonusPointsStrategy, - $order->getAdjustmentsTotal(AdjustmentInterface::ORDER_BONUS_POINTS_ADJUSTMENT) + $order->getAdjustmentsTotal(AdjustmentInterface::ORDER_BONUS_POINTS_ADJUSTMENT), ); } diff --git a/src/Assigner/BonusPointsAssignerInterface.php b/src/Assigner/BonusPointsAssignerInterface.php index 9c8ae1e..1d5befb 100644 --- a/src/Assigner/BonusPointsAssignerInterface.php +++ b/src/Assigner/BonusPointsAssignerInterface.php @@ -1,10 +1,11 @@ registry = $registry; $this->bonusPointsStrategyEligibilityChecker = $bonusPointsStrategyEligibilityChecker; diff --git a/src/Calculator/DelegatingBonusPointsStrategyCalculatorInterface.php b/src/Calculator/DelegatingBonusPointsStrategyCalculatorInterface.php index 28fba14..683de82 100644 --- a/src/Calculator/DelegatingBonusPointsStrategyCalculatorInterface.php +++ b/src/Calculator/DelegatingBonusPointsStrategyCalculatorInterface.php @@ -1,10 +1,11 @@ getTotal(); - if ($amountToDeduct < 0) { + if (0 > $amountToDeduct) { $total += $amountToDeduct; } diff --git a/src/Calculator/PerOrderPriceCalculator.php b/src/Calculator/PerOrderPriceCalculator.php index 46e9927..413ac47 100644 --- a/src/Calculator/PerOrderPriceCalculator.php +++ b/src/Calculator/PerOrderPriceCalculator.php @@ -1,10 +1,11 @@ decimalPart += ($totalFloat - $total); - if ($this->decimalPart >= 1) { + if (1 <= $this->decimalPart) { ++$total; --$this->decimalPart; diff --git a/src/Checker/Eligibility/BonusPointsStrategyEligibilityCheckerInterface.php b/src/Checker/Eligibility/BonusPointsStrategyEligibilityCheckerInterface.php index 5cd1fd2..fa5a986 100644 --- a/src/Checker/Eligibility/BonusPointsStrategyEligibilityCheckerInterface.php +++ b/src/Checker/Eligibility/BonusPointsStrategyEligibilityCheckerInterface.php @@ -1,10 +1,11 @@ customerContext = $customerContext; $this->customerBonusPointsRepository = $customerBonusPointsRepository; diff --git a/src/Context/CustomerBonusPointsContextInterface.php b/src/Context/CustomerBonusPointsContextInterface.php index 25f6a4b..fd9314e 100644 --- a/src/Context/CustomerBonusPointsContextInterface.php +++ b/src/Context/CustomerBonusPointsContextInterface.php @@ -1,10 +1,11 @@ router = $router; $this->cartContext = $cartContext; diff --git a/src/Creator/BonusPointsCreator.php b/src/Creator/BonusPointsCreator.php index 410a4c9..5edd852 100644 --- a/src/Creator/BonusPointsCreator.php +++ b/src/Creator/BonusPointsCreator.php @@ -1,10 +1,11 @@ bonusPointsFactory = $bonusPointsFactory; $this->bonusPointsRepository = $bonusPointsRepository; @@ -36,7 +37,7 @@ public function createWithData( CustomerBonusPointsInterface $customerBonusPoints, OrderInterface $order, int $points, - BonusPointsInterface $parentBonusPoints = null + BonusPointsInterface $parentBonusPoints = null, ): BonusPointsInterface { /** @var BonusPointsInterface $bonusPoints */ $bonusPoints = $this->bonusPointsFactory->createNew(); diff --git a/src/Creator/BonusPointsCreatorInterface.php b/src/Creator/BonusPointsCreatorInterface.php index e9a45eb..de6c15b 100644 --- a/src/Creator/BonusPointsCreatorInterface.php +++ b/src/Creator/BonusPointsCreatorInterface.php @@ -1,5 +1,12 @@ bonusPointsCreator = $bonusPointsCreator; $this->customerBonusPointsContext = $customerBonusPointsContext; diff --git a/src/Form/Extension/CartTypeExtension.php b/src/Form/Extension/CartTypeExtension.php index d7bafbe..9f543de 100644 --- a/src/Form/Extension/CartTypeExtension.php +++ b/src/Form/Extension/CartTypeExtension.php @@ -1,10 +1,11 @@ customerBonusPointsContext = $customerBonusPointsContext; $this->bonusPointsResolver = $bonusPointsResolver; @@ -51,7 +52,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void /** @var OrderInterface $cart */ $cart = $this->cartContext->getCart(); - if ($this->bonusPointsResolver->resolveBonusPoints($cart) === 0) { + if (0 === $this->bonusPointsResolver->resolveBonusPoints($cart)) { return; } @@ -69,7 +70,8 @@ public function buildForm(FormBuilderInterface $builder, array $options): void ]), ], 'data' => null, - ]); + ]) + ; } public static function getExtendedTypes(): iterable diff --git a/src/Form/Type/AbstractConfigurableBonusPointsStrategyRuleType.php b/src/Form/Type/AbstractConfigurableBonusPointsStrategyRuleType.php index 388551c..54a8df1 100644 --- a/src/Form/Type/AbstractConfigurableBonusPointsStrategyRuleType.php +++ b/src/Form/Type/AbstractConfigurableBonusPointsStrategyRuleType.php @@ -1,10 +1,11 @@ setDefault('configuration_type', null) - ->setAllowedTypes('configuration_type', ['string', 'null']); + ->setAllowedTypes('configuration_type', ['string', 'null']) + ; } protected function addConfigurationFields(FormInterface $form, string $configurationType): void diff --git a/src/Form/Type/AbstractConfigurationCollectionType.php b/src/Form/Type/AbstractConfigurationCollectionType.php index 8d849c7..21437b1 100644 --- a/src/Form/Type/AbstractConfigurationCollectionType.php +++ b/src/Form/Type/AbstractConfigurationCollectionType.php @@ -1,10 +1,11 @@ $type] - ) + ['configuration_type' => $type], + ), ); $prototypes[$type] = $formBuilder->getForm(); diff --git a/src/Form/Type/BonusPointsStrategyCalculatorChoiceType.php b/src/Form/Type/BonusPointsStrategyCalculatorChoiceType.php index 14633b1..3ebafe3 100755 --- a/src/Form/Type/BonusPointsStrategyCalculatorChoiceType.php +++ b/src/Form/Type/BonusPointsStrategyCalculatorChoiceType.php @@ -1,10 +1,11 @@ null !== $currency ? $currency->getCode() : null, ]) ->setRequired('currency') - ->setAllowedTypes('currency', 'string'); + ->setAllowedTypes('currency', 'string') + ; } } diff --git a/src/Form/Type/Rule/HasTaxonConfigurationType.php b/src/Form/Type/Rule/HasTaxonConfigurationType.php index ef0c038..00aee7b 100644 --- a/src/Form/Type/Rule/HasTaxonConfigurationType.php +++ b/src/Form/Type/Rule/HasTaxonConfigurationType.php @@ -1,10 +1,11 @@ bonusPointsRepository = $bonusPointsRepository; $this->bonusPointsManager = $bonusPointsManager; @@ -96,7 +97,7 @@ public function process(OrderInterface $order): void $adjustment = $this->adjustmentFactory->createWithData( AdjustmentInterface::ORDER_BONUS_POINTS_ADJUSTMENT, AdjustmentInterface::ORDER_BONUS_POINTS_ADJUSTMENT, - (-1 * $totalUsedPoints) + (-1 * $totalUsedPoints), ); $adjustment->setOriginCode(AdjustmentInterface::ORDER_BONUS_POINTS_ADJUSTMENT); diff --git a/src/Processor/ResetOrderBonusPointsProcessor.php b/src/Processor/ResetOrderBonusPointsProcessor.php index 61aa9bb..61676ba 100644 --- a/src/Processor/ResetOrderBonusPointsProcessor.php +++ b/src/Processor/ResetOrderBonusPointsProcessor.php @@ -1,10 +1,11 @@ orderBonusPointsPurifier = $orderBonusPointsPurifier; $this->bonusPointsRepository = $bonusPointsRepository; diff --git a/src/Processor/ResetOrderBonusPointsProcessorInterface.php b/src/Processor/ResetOrderBonusPointsProcessorInterface.php index a388af3..c218a67 100644 --- a/src/Processor/ResetOrderBonusPointsProcessorInterface.php +++ b/src/Processor/ResetOrderBonusPointsProcessorInterface.php @@ -1,10 +1,11 @@ customerBonusPointsContext = $customerBonusPointsContext; $this->persistenceManager = $persistenceManager; @@ -41,7 +42,7 @@ public function __construct( public function purify( BonusPointsInterface $bonusPoints, - CustomerBonusPointsInterface $customerBonusPoints = null + CustomerBonusPointsInterface $customerBonusPoints = null, ): void { /** @var OrderInterface $order */ $order = $bonusPoints->getOrder(); diff --git a/src/Purifier/OrderBonusPointsPurifierInterface.php b/src/Purifier/OrderBonusPointsPurifierInterface.php index 36d6c8b..0c07767 100644 --- a/src/Purifier/OrderBonusPointsPurifierInterface.php +++ b/src/Purifier/OrderBonusPointsPurifierInterface.php @@ -1,10 +1,11 @@ customerBonusPointsContext = $customerBonusPointsContext; } public function resolveBonusPoints( OrderInterface $withoutOrder = null, - Customer $customer = null + Customer $customer = null, ): int { $customerPoints = $this->customerBonusPointsContext->getCustomerBonusPoints(); diff --git a/src/Resolver/BonusPointsResolverInterface.php b/src/Resolver/BonusPointsResolverInterface.php index 6886eab..f39e8e1 100644 --- a/src/Resolver/BonusPointsResolverInterface.php +++ b/src/Resolver/BonusPointsResolverInterface.php @@ -1,10 +1,11 @@ bonusPointsStrategyRepository = $bonusPointsStrategyRepository; $this->cartContext = $cartContext; @@ -49,11 +50,11 @@ public function validate($bonusPoints, Constraint $constraint): void $bonusPointsStrategies = $this->bonusPointsStrategyRepository->findActiveByCalculatorType(PerOrderPriceCalculator::TYPE); - if (\count($bonusPointsStrategies) === 0) { + if (0 === \count($bonusPointsStrategies)) { return; } - if ($bonusPoints % 100 !== 0) { + if (0 !== $bonusPoints % 100) { $this->context->getViolations()->remove(0); $this->context->buildViolation($constraint->invalidBonusPointsValueMessage)->addViolation(); } diff --git a/src/Validator/Constraints/BonusPointsAvailability.php b/src/Validator/Constraints/BonusPointsAvailability.php index 5e7f272..2c617e7 100644 --- a/src/Validator/Constraints/BonusPointsAvailability.php +++ b/src/Validator/Constraints/BonusPointsAvailability.php @@ -1,10 +1,11 @@ $this->bonusPointsResolver->resolveBonusPoints($order)) { $this->context ->buildViolation($constraint->message) - ->addViolation(); + ->addViolation() + ; } } } From f7078cdfee4012457bab6130c2d01dd59b56b6e5 Mon Sep 17 00:00:00 2001 From: janpalen Date: Mon, 8 Jul 2024 13:45:16 +0200 Subject: [PATCH 05/15] OP-376 - Change constructor syntax --- src/Assigner/BonusPointsAssigner.php | 48 ++++--------------- ...elegatingBonusPointsStrategyCalculator.php | 12 +---- ...sPointsStrategyRulesEligibilityChecker.php | 9 ++-- src/Checker/Rule/HasTaxonRuleChecker.php | 9 ++-- src/Context/CustomerBonusPointsContext.php | 18 ++----- .../ResetOrderBonusPointsAction.php | 18 ++----- src/Creator/BonusPointsCreator.php | 12 +---- .../OrderBonusPointsListener.php | 18 ++----- src/Form/Extension/CartTypeExtension.php | 18 ++----- ...onfigurableBonusPointsStrategyRuleType.php | 12 ++--- .../AbstractConfigurationCollectionType.php | 9 ++-- ...onusPointsStrategyCalculatorChoiceType.php | 9 ++-- .../BonusPointsStrategyRuleChoiceType.php | 9 ++-- src/Form/Type/BonusPointsStrategyType.php | 13 +---- .../PerOrderPriceConfigurationType.php | 9 ++-- .../Type/Rule/HasTaxonConfigurationType.php | 9 ++-- .../OrderBonusPointsProcessor.php | 24 ++-------- .../ResetOrderBonusPointsProcessor.php | 12 +---- src/Purifier/OrderBonusPointsPurifier.php | 18 ++----- src/Resolver/BonusPointsResolver.php | 6 +-- src/Twig/Extension/BonusPointsExtension.php | 9 ++-- .../Constraints/BonusPointsApplyValidator.php | 12 +---- .../BonusPointsAvailabilityValidator.php | 14 ++---- 23 files changed, 71 insertions(+), 256 deletions(-) diff --git a/src/Assigner/BonusPointsAssigner.php b/src/Assigner/BonusPointsAssigner.php index f88e520..a954abc 100644 --- a/src/Assigner/BonusPointsAssigner.php +++ b/src/Assigner/BonusPointsAssigner.php @@ -32,48 +32,16 @@ final class BonusPointsAssigner implements BonusPointsAssignerInterface { - /** @var DelegatingBonusPointsStrategyCalculatorInterface */ - private $delegatingBonusPointsStrategyCalculator; - - /** @var BonusPointsStrategyEligibilityCheckerInterface */ - private $bonusPointsStrategyEligibilityChecker; - - /** @var BonusPointsStrategyRepositoryInterface */ - private $bonusPointsStrategyRepository; - - /** @var FactoryInterface */ - private $bonusPointsFactory; - - /** @var EntityManagerInterface */ - private $bonusPointsEntityManager; - - /** @var RepositoryInterface */ - private $customerBonusPointsRepository; - - /** @var FactoryInterface */ - private $customerBonusPointsFactory; - - /** @var ProportionalIntegerDistributorInterface */ - private $proportionalIntegerDistributor; - public function __construct( - DelegatingBonusPointsStrategyCalculatorInterface $delegatingBonusPointsStrategyCalculator, - BonusPointsStrategyEligibilityCheckerInterface $bonusPointsStrategyEligibilityChecker, - BonusPointsStrategyRepositoryInterface $bonusPointsStrategyRepository, - FactoryInterface $bonusPointsFactory, - EntityManagerInterface $bonusPointsEntityManager, - RepositoryInterface $customerBonusPointsRepository, - FactoryInterface $customerBonusPointsFactory, - ProportionalIntegerDistributorInterface $proportionalIntegerDistributor, + private readonly DelegatingBonusPointsStrategyCalculatorInterface $delegatingBonusPointsStrategyCalculator, + private readonly BonusPointsStrategyEligibilityCheckerInterface $bonusPointsStrategyEligibilityChecker, + private readonly BonusPointsStrategyRepositoryInterface $bonusPointsStrategyRepository, + private readonly FactoryInterface $bonusPointsFactory, + private readonly EntityManagerInterface $bonusPointsEntityManager, + private readonly RepositoryInterface $customerBonusPointsRepository, + private readonly FactoryInterface $customerBonusPointsFactory, + private readonly ProportionalIntegerDistributorInterface $proportionalIntegerDistributor, ) { - $this->delegatingBonusPointsStrategyCalculator = $delegatingBonusPointsStrategyCalculator; - $this->bonusPointsStrategyEligibilityChecker = $bonusPointsStrategyEligibilityChecker; - $this->bonusPointsStrategyRepository = $bonusPointsStrategyRepository; - $this->bonusPointsFactory = $bonusPointsFactory; - $this->bonusPointsEntityManager = $bonusPointsEntityManager; - $this->customerBonusPointsRepository = $customerBonusPointsRepository; - $this->customerBonusPointsFactory = $customerBonusPointsFactory; - $this->proportionalIntegerDistributor = $proportionalIntegerDistributor; } public function assign(OrderInterface $order): void diff --git a/src/Calculator/DelegatingBonusPointsStrategyCalculator.php b/src/Calculator/DelegatingBonusPointsStrategyCalculator.php index 7760eda..f262240 100644 --- a/src/Calculator/DelegatingBonusPointsStrategyCalculator.php +++ b/src/Calculator/DelegatingBonusPointsStrategyCalculator.php @@ -18,18 +18,10 @@ final class DelegatingBonusPointsStrategyCalculator implements DelegatingBonusPointsStrategyCalculatorInterface { - /** @var ServiceRegistryInterface */ - private $registry; - - /** @var BonusPointsStrategyEligibilityCheckerInterface */ - private $bonusPointsStrategyEligibilityChecker; - public function __construct( - ServiceRegistryInterface $registry, - BonusPointsStrategyEligibilityCheckerInterface $bonusPointsStrategyEligibilityChecker, + private readonly ServiceRegistryInterface $registry, + private readonly BonusPointsStrategyEligibilityCheckerInterface $bonusPointsStrategyEligibilityChecker, ) { - $this->registry = $registry; - $this->bonusPointsStrategyEligibilityChecker = $bonusPointsStrategyEligibilityChecker; } public function calculate(OrderItemInterface $subject, BonusPointsStrategyInterface $bonusPointsStrategy, int $amountToDeduct = 0): int diff --git a/src/Checker/Eligibility/BonusPointsStrategyRulesEligibilityChecker.php b/src/Checker/Eligibility/BonusPointsStrategyRulesEligibilityChecker.php index 6bdbd34..8e88841 100644 --- a/src/Checker/Eligibility/BonusPointsStrategyRulesEligibilityChecker.php +++ b/src/Checker/Eligibility/BonusPointsStrategyRulesEligibilityChecker.php @@ -19,12 +19,9 @@ final class BonusPointsStrategyRulesEligibilityChecker implements BonusPointsStrategyEligibilityCheckerInterface { - /** @var ServiceRegistryInterface */ - private $ruleRegistry; - - public function __construct(ServiceRegistryInterface $ruleRegistry) - { - $this->ruleRegistry = $ruleRegistry; + public function __construct( + private readonly ServiceRegistryInterface $ruleRegistry, + ) { } public function isEligible(ProductInterface $product, BonusPointsStrategyInterface $bonusPointsStrategy): bool diff --git a/src/Checker/Rule/HasTaxonRuleChecker.php b/src/Checker/Rule/HasTaxonRuleChecker.php index 1b15661..5b84f1b 100644 --- a/src/Checker/Rule/HasTaxonRuleChecker.php +++ b/src/Checker/Rule/HasTaxonRuleChecker.php @@ -20,12 +20,9 @@ final class HasTaxonRuleChecker implements BonusPointsStrategyRuleCheckerInterfa { public const TYPE = 'has_taxon'; - /** @var TaxonRepositoryInterface */ - private $taxonRepository; - - public function __construct(TaxonRepositoryInterface $taxonRepository) - { - $this->taxonRepository = $taxonRepository; + public function __construct( + private readonly TaxonRepositoryInterface $taxonRepository, + ) { } public function isEligible(ProductInterface $product, array $configuration): bool diff --git a/src/Context/CustomerBonusPointsContext.php b/src/Context/CustomerBonusPointsContext.php index 2e65b70..cc7c5cf 100644 --- a/src/Context/CustomerBonusPointsContext.php +++ b/src/Context/CustomerBonusPointsContext.php @@ -19,23 +19,11 @@ final class CustomerBonusPointsContext implements CustomerBonusPointsContextInterface { - /** @var CustomerContextInterface */ - private $customerContext; - - /** @var RepositoryInterface */ - private $customerBonusPointsRepository; - - /** @var FactoryInterface */ - private $customerBonusPointsFactory; - public function __construct( - CustomerContextInterface $customerContext, - RepositoryInterface $customerBonusPointsRepository, - FactoryInterface $customerBonusPointsFactory, + private readonly CustomerContextInterface $customerContext, + private readonly RepositoryInterface $customerBonusPointsRepository, + private readonly FactoryInterface $customerBonusPointsFactory, ) { - $this->customerContext = $customerContext; - $this->customerBonusPointsRepository = $customerBonusPointsRepository; - $this->customerBonusPointsFactory = $customerBonusPointsFactory; } public function getCustomerBonusPoints(): ?CustomerBonusPointsInterface diff --git a/src/Controller/ResetOrderBonusPointsAction.php b/src/Controller/ResetOrderBonusPointsAction.php index 9f3e35f..8871b18 100644 --- a/src/Controller/ResetOrderBonusPointsAction.php +++ b/src/Controller/ResetOrderBonusPointsAction.php @@ -20,23 +20,11 @@ final class ResetOrderBonusPointsAction { - /** @var RouterInterface */ - private $router; - - /** @var CartContextInterface */ - private $cartContext; - - /** @var ResetOrderBonusPointsProcessorInterface */ - private $resetOrderBonusPointsProcessor; - public function __construct( - RouterInterface $router, - CartContextInterface $cartContext, - ResetOrderBonusPointsProcessorInterface $resetOrderBonusPointsProcessor, + private readonly RouterInterface $router, + private readonly CartContextInterface $cartContext, + private readonly ResetOrderBonusPointsProcessorInterface $resetOrderBonusPointsProcessor, ) { - $this->router = $router; - $this->cartContext = $cartContext; - $this->resetOrderBonusPointsProcessor = $resetOrderBonusPointsProcessor; } public function __invoke(Request $request): Response diff --git a/src/Creator/BonusPointsCreator.php b/src/Creator/BonusPointsCreator.php index 5edd852..2a2e815 100644 --- a/src/Creator/BonusPointsCreator.php +++ b/src/Creator/BonusPointsCreator.php @@ -19,18 +19,10 @@ final class BonusPointsCreator implements BonusPointsCreatorInterface { - /** @var FactoryInterface */ - private $bonusPointsFactory; - - /** @var BonusPointsRepositoryInterface */ - private $bonusPointsRepository; - public function __construct( - FactoryInterface $bonusPointsFactory, - BonusPointsRepositoryInterface $bonusPointsRepository, + private readonly FactoryInterface $bonusPointsFactory, + private readonly BonusPointsRepositoryInterface $bonusPointsRepository, ) { - $this->bonusPointsFactory = $bonusPointsFactory; - $this->bonusPointsRepository = $bonusPointsRepository; } public function createWithData( diff --git a/src/EventListener/OrderBonusPointsListener.php b/src/EventListener/OrderBonusPointsListener.php index 592334f..b6cfa5e 100644 --- a/src/EventListener/OrderBonusPointsListener.php +++ b/src/EventListener/OrderBonusPointsListener.php @@ -22,23 +22,11 @@ final class OrderBonusPointsListener { - /** @var BonusPointsCreatorInterface */ - private $bonusPointsCreator; - - /** @var CustomerBonusPointsContextInterface */ - private $customerBonusPointsContext; - - /** @var ResetOrderBonusPointsProcessorInterface */ - private $resetBonusPointsProcessor; - public function __construct( - BonusPointsCreatorInterface $bonusPointsCreator, - CustomerBonusPointsContextInterface $customerBonusPointsContext, - ResetOrderBonusPointsProcessorInterface $resetBonusPointsProcessor, + private readonly BonusPointsCreatorInterface $bonusPointsCreator, + private readonly CustomerBonusPointsContextInterface $customerBonusPointsContext, + private readonly ResetOrderBonusPointsProcessorInterface $resetBonusPointsProcessor, ) { - $this->bonusPointsCreator = $bonusPointsCreator; - $this->customerBonusPointsContext = $customerBonusPointsContext; - $this->resetBonusPointsProcessor = $resetBonusPointsProcessor; } public function assignBonusPoints(ResourceControllerEvent $event): void diff --git a/src/Form/Extension/CartTypeExtension.php b/src/Form/Extension/CartTypeExtension.php index 9f543de..e5fb636 100644 --- a/src/Form/Extension/CartTypeExtension.php +++ b/src/Form/Extension/CartTypeExtension.php @@ -24,23 +24,11 @@ final class CartTypeExtension extends AbstractTypeExtension { - /** @var CustomerBonusPointsContextInterface */ - private $customerBonusPointsContext; - - /** @var BonusPointsResolverInterface */ - private $bonusPointsResolver; - - /** @var CartContextInterface */ - private $cartContext; - public function __construct( - CustomerBonusPointsContextInterface $customerBonusPointsContext, - BonusPointsResolverInterface $bonusPointsResolver, - CartContextInterface $cartContext, + private readonly CustomerBonusPointsContextInterface $customerBonusPointsContext, + private readonly BonusPointsResolverInterface $bonusPointsResolver, + private readonly CartContextInterface $cartContext, ) { - $this->customerBonusPointsContext = $customerBonusPointsContext; - $this->bonusPointsResolver = $bonusPointsResolver; - $this->cartContext = $cartContext; } public function buildForm(FormBuilderInterface $builder, array $options): void diff --git a/src/Form/Type/AbstractConfigurableBonusPointsStrategyRuleType.php b/src/Form/Type/AbstractConfigurableBonusPointsStrategyRuleType.php index 54a8df1..293082b 100644 --- a/src/Form/Type/AbstractConfigurableBonusPointsStrategyRuleType.php +++ b/src/Form/Type/AbstractConfigurableBonusPointsStrategyRuleType.php @@ -22,14 +22,12 @@ abstract class AbstractConfigurableBonusPointsStrategyRuleType extends AbstractResourceType { - /** @var FormTypeRegistryInterface */ - private $formTypeRegistry; - - public function __construct(string $dataClass, array $validationGroups = [], FormTypeRegistryInterface $formTypeRegistry) - { + public function __construct( + string $dataClass, + array $validationGroups = [], + private readonly FormTypeRegistryInterface $formTypeRegistry, + ) { parent::__construct($dataClass, $validationGroups); - - $this->formTypeRegistry = $formTypeRegistry; } public function buildForm(FormBuilderInterface $builder, array $options): void diff --git a/src/Form/Type/AbstractConfigurationCollectionType.php b/src/Form/Type/AbstractConfigurationCollectionType.php index 21437b1..3eaefbb 100644 --- a/src/Form/Type/AbstractConfigurationCollectionType.php +++ b/src/Form/Type/AbstractConfigurationCollectionType.php @@ -21,12 +21,9 @@ abstract class AbstractConfigurationCollectionType extends AbstractType { - /** @var ServiceRegistryInterface */ - protected $registry; - - public function __construct(ServiceRegistryInterface $registry) - { - $this->registry = $registry; + public function __construct( + private readonly ServiceRegistryInterface $registry, + ) { } public function buildForm(FormBuilderInterface $builder, array $options): void diff --git a/src/Form/Type/BonusPointsStrategyCalculatorChoiceType.php b/src/Form/Type/BonusPointsStrategyCalculatorChoiceType.php index 3ebafe3..0d356ae 100755 --- a/src/Form/Type/BonusPointsStrategyCalculatorChoiceType.php +++ b/src/Form/Type/BonusPointsStrategyCalculatorChoiceType.php @@ -17,12 +17,9 @@ final class BonusPointsStrategyCalculatorChoiceType extends AbstractType { - /** @var array */ - private $calculators; - - public function __construct(array $calculators) - { - $this->calculators = $calculators; + public function __construct( + private readonly array $calculators, + ) { } public function configureOptions(OptionsResolver $resolver): void diff --git a/src/Form/Type/BonusPointsStrategyRuleChoiceType.php b/src/Form/Type/BonusPointsStrategyRuleChoiceType.php index 352024c..7cabb65 100755 --- a/src/Form/Type/BonusPointsStrategyRuleChoiceType.php +++ b/src/Form/Type/BonusPointsStrategyRuleChoiceType.php @@ -17,12 +17,9 @@ final class BonusPointsStrategyRuleChoiceType extends AbstractType { - /** @var array */ - private $rules; - - public function __construct(array $rules) - { - $this->rules = $rules; + public function __construct( + private readonly array $rules, + ) { } public function configureOptions(OptionsResolver $resolver): void diff --git a/src/Form/Type/BonusPointsStrategyType.php b/src/Form/Type/BonusPointsStrategyType.php index df6ae08..69530db 100644 --- a/src/Form/Type/BonusPointsStrategyType.php +++ b/src/Form/Type/BonusPointsStrategyType.php @@ -26,22 +26,13 @@ final class BonusPointsStrategyType extends AbstractResourceType { - /** @var ServiceRegistryInterface */ - private $calculatorRegistry; - - /** @var FormTypeRegistryInterface */ - private $formTypeRegistry; - public function __construct( string $dataClass, array $validationGroups, - ServiceRegistryInterface $calculatorRegistry, - FormTypeRegistryInterface $formTypeRegistry, + private readonly ServiceRegistryInterface $calculatorRegistry, + private readonly FormTypeRegistryInterface $formTypeRegistry, ) { parent::__construct($dataClass, $validationGroups); - - $this->calculatorRegistry = $calculatorRegistry; - $this->formTypeRegistry = $formTypeRegistry; } public function buildForm(FormBuilderInterface $builder, array $options): void diff --git a/src/Form/Type/Calculator/PerOrderPriceConfigurationType.php b/src/Form/Type/Calculator/PerOrderPriceConfigurationType.php index d9e39b2..0b51e38 100644 --- a/src/Form/Type/Calculator/PerOrderPriceConfigurationType.php +++ b/src/Form/Type/Calculator/PerOrderPriceConfigurationType.php @@ -23,12 +23,9 @@ final class PerOrderPriceConfigurationType extends AbstractType { - /** @var ChannelContextInterface */ - private $channelContext; - - public function __construct(ChannelContextInterface $channelContext) - { - $this->channelContext = $channelContext; + public function __construct( + private readonly ChannelContextInterface $channelContext, + ) { } public function buildForm(FormBuilderInterface $builder, array $options): void diff --git a/src/Form/Type/Rule/HasTaxonConfigurationType.php b/src/Form/Type/Rule/HasTaxonConfigurationType.php index 00aee7b..7e691db 100644 --- a/src/Form/Type/Rule/HasTaxonConfigurationType.php +++ b/src/Form/Type/Rule/HasTaxonConfigurationType.php @@ -19,12 +19,9 @@ final class HasTaxonConfigurationType extends AbstractType { - /** @var DataTransformerInterface */ - private $taxonsToCodesTransformer; - - public function __construct(DataTransformerInterface $taxonsToCodesTransformer) - { - $this->taxonsToCodesTransformer = $taxonsToCodesTransformer; + public function __construct( + private readonly DataTransformerInterface $taxonsToCodesTransformer, + ) { } public function buildForm(FormBuilderInterface $builder, array $options): void diff --git a/src/OrderProcessing/OrderBonusPointsProcessor.php b/src/OrderProcessing/OrderBonusPointsProcessor.php index 62ee86a..5d2f2e3 100644 --- a/src/OrderProcessing/OrderBonusPointsProcessor.php +++ b/src/OrderProcessing/OrderBonusPointsProcessor.php @@ -24,28 +24,12 @@ final class OrderBonusPointsProcessor implements OrderProcessorInterface { - /** @var RepositoryInterface */ - private $bonusPointsRepository; - - /** @var ObjectManager */ - private $bonusPointsManager; - - /** @var AdjustmentFactoryInterface */ - private $adjustmentFactory; - - /** @var OrderBonusPointsPurifierInterface */ - private $orderBonusPointsPurifier; - public function __construct( - RepositoryInterface $bonusPointsRepository, - ObjectManager $bonusPointsManager, - AdjustmentFactoryInterface $adjustmentFactory, - OrderBonusPointsPurifierInterface $orderBonusPointsPurifier, + private readonly RepositoryInterface $bonusPointsRepository, + private readonly ObjectManager $bonusPointsManager, + private readonly AdjustmentFactoryInterface $adjustmentFactory, + private readonly OrderBonusPointsPurifierInterface $orderBonusPointsPurifier, ) { - $this->bonusPointsRepository = $bonusPointsRepository; - $this->bonusPointsManager = $bonusPointsManager; - $this->adjustmentFactory = $adjustmentFactory; - $this->orderBonusPointsPurifier = $orderBonusPointsPurifier; } public function process(OrderInterface $order): void diff --git a/src/Processor/ResetOrderBonusPointsProcessor.php b/src/Processor/ResetOrderBonusPointsProcessor.php index 61676ba..27d5786 100644 --- a/src/Processor/ResetOrderBonusPointsProcessor.php +++ b/src/Processor/ResetOrderBonusPointsProcessor.php @@ -19,18 +19,10 @@ final class ResetOrderBonusPointsProcessor implements ResetOrderBonusPointsProcessorInterface { - /** @var OrderBonusPointsPurifierInterface */ - private $orderBonusPointsPurifier; - - /** @var RepositoryInterface */ - private $bonusPointsRepository; - public function __construct( - OrderBonusPointsPurifierInterface $orderBonusPointsPurifier, - RepositoryInterface $bonusPointsRepository, + private readonly OrderBonusPointsPurifierInterface $orderBonusPointsPurifier, + private readonly RepositoryInterface $bonusPointsRepository, ) { - $this->orderBonusPointsPurifier = $orderBonusPointsPurifier; - $this->bonusPointsRepository = $bonusPointsRepository; } public function process(OrderInterface $order): void diff --git a/src/Purifier/OrderBonusPointsPurifier.php b/src/Purifier/OrderBonusPointsPurifier.php index 38087ed..04e16a5 100644 --- a/src/Purifier/OrderBonusPointsPurifier.php +++ b/src/Purifier/OrderBonusPointsPurifier.php @@ -21,23 +21,11 @@ final class OrderBonusPointsPurifier implements OrderBonusPointsPurifierInterface { - /** @var CustomerBonusPointsContextInterface */ - private $customerBonusPointsContext; - - /** @var ObjectManager */ - private $persistenceManager; - - /** @var RepositoryInterface */ - private $bonusPointsRepository; - public function __construct( - CustomerBonusPointsContextInterface $customerBonusPointsContext, - ObjectManager $persistenceManager, - RepositoryInterface $bonusPointsRepository, + private readonly CustomerBonusPointsContextInterface $customerBonusPointsContext, + private readonly ObjectManager $persistenceManager, + private readonly RepositoryInterface $bonusPointsRepository, ) { - $this->customerBonusPointsContext = $customerBonusPointsContext; - $this->persistenceManager = $persistenceManager; - $this->bonusPointsRepository = $bonusPointsRepository; } public function purify( diff --git a/src/Resolver/BonusPointsResolver.php b/src/Resolver/BonusPointsResolver.php index 2ad209b..5fdb6d6 100644 --- a/src/Resolver/BonusPointsResolver.php +++ b/src/Resolver/BonusPointsResolver.php @@ -17,13 +17,9 @@ final class BonusPointsResolver implements BonusPointsResolverInterface { - /** @var CustomerBonusPointsContextInterface */ - private $customerBonusPointsContext; - public function __construct( - CustomerBonusPointsContextInterface $customerBonusPointsContext, + private readonly CustomerBonusPointsContextInterface $customerBonusPointsContext, ) { - $this->customerBonusPointsContext = $customerBonusPointsContext; } public function resolveBonusPoints( diff --git a/src/Twig/Extension/BonusPointsExtension.php b/src/Twig/Extension/BonusPointsExtension.php index bcc89e5..245b1df 100644 --- a/src/Twig/Extension/BonusPointsExtension.php +++ b/src/Twig/Extension/BonusPointsExtension.php @@ -17,12 +17,9 @@ class BonusPointsExtension extends AbstractExtension { - /** @var BonusPointsResolverInterface */ - private $bonusPointsResolver; - - public function __construct(BonusPointsResolverInterface $bonusPointsResolver) - { - $this->bonusPointsResolver = $bonusPointsResolver; + public function __construct( + private readonly BonusPointsResolverInterface $bonusPointsResolver, + ) { } public function getFunctions(): array diff --git a/src/Validator/Constraints/BonusPointsApplyValidator.php b/src/Validator/Constraints/BonusPointsApplyValidator.php index 661808a..2d7bc3b 100644 --- a/src/Validator/Constraints/BonusPointsApplyValidator.php +++ b/src/Validator/Constraints/BonusPointsApplyValidator.php @@ -19,18 +19,10 @@ final class BonusPointsApplyValidator extends ConstraintValidator { - /** @var BonusPointsStrategyRepositoryInterface */ - private $bonusPointsStrategyRepository; - - /** @var CartContextInterface */ - private $cartContext; - public function __construct( - BonusPointsStrategyRepositoryInterface $bonusPointsStrategyRepository, - CartContextInterface $cartContext, + private readonly BonusPointsStrategyRepositoryInterface $bonusPointsStrategyRepository, + private readonly CartContextInterface $cartContext, ) { - $this->bonusPointsStrategyRepository = $bonusPointsStrategyRepository; - $this->cartContext = $cartContext; } /** diff --git a/src/Validator/Constraints/BonusPointsAvailabilityValidator.php b/src/Validator/Constraints/BonusPointsAvailabilityValidator.php index 4a655e5..bc0451c 100644 --- a/src/Validator/Constraints/BonusPointsAvailabilityValidator.php +++ b/src/Validator/Constraints/BonusPointsAvailabilityValidator.php @@ -22,16 +22,10 @@ final class BonusPointsAvailabilityValidator extends ConstraintValidator { - /** @var BonusPointsResolverInterface */ - private $bonusPointsResolver; - - /** @var RepositoryInterface */ - private $bonusPointsRepository; - - public function __construct(BonusPointsResolverInterface $bonusPointsResolver, RepositoryInterface $bonusPointsRepository) - { - $this->bonusPointsResolver = $bonusPointsResolver; - $this->bonusPointsRepository = $bonusPointsRepository; + public function __construct( + private readonly BonusPointsResolverInterface $bonusPointsResolver, + private readonly RepositoryInterface $bonusPointsRepository, + ) { } /** From 73f59db43f6e71925336b9343f1c3431e2d5f691 Mon Sep 17 00:00:00 2001 From: janpalen Date: Mon, 8 Jul 2024 14:07:47 +0200 Subject: [PATCH 06/15] OP-376 - Fix tests files for ECS --- composer.json | 2 +- tests/Application/Kernel.php | 1 - tests/Application/config/bootstrap.php | 7 +++++++ tests/Application/config/bundles.php | 9 +++++---- .../Application/config/sylius/1.11/bundles.php | 9 +++++---- .../Application/config/sylius/1.12/bundles.php | 9 +++++---- tests/Application/public/index.php | 7 +++++++ tests/Application/src/Entity/Order.php | 7 +++++++ .../Behat/Behaviour/ContainsErrorInterface.php | 9 +++++---- tests/Behat/Behaviour/ContainsErrorTrait.php | 9 +++++---- .../Setup/BonusPointsStrategyContext.php | 13 +++++++------ .../Ui/Admin/BonusPointsStrategyContext.php | 17 +++++++++-------- tests/Behat/Context/Ui/Shop/CartContext.php | 9 +++++---- .../Context/Ui/Shop/CheckoutCompleteContext.php | 9 +++++---- .../Admin/BonusPointsStrategy/CreatePage.php | 9 +++++---- .../BonusPointsStrategy/CreatePageInterface.php | 9 +++++---- .../Admin/BonusPointsStrategy/IndexPage.php | 9 +++++---- .../BonusPointsStrategy/IndexPageInterface.php | 9 +++++---- .../Admin/BonusPointsStrategy/UpdatePage.php | 9 +++++---- .../BonusPointsStrategy/UpdatePageInterface.php | 9 +++++---- tests/Behat/Page/Shop/Cart/CartPage.php | 9 +++++---- .../Behat/Page/Shop/Cart/CartPageInterface.php | 9 +++++---- tests/Behat/Page/Shop/Checkout/CompletePage.php | 9 +++++---- .../Shop/Checkout/CompletePageInterface.php | 9 +++++---- 24 files changed, 123 insertions(+), 84 deletions(-) diff --git a/composer.json b/composer.json index 40771b9..60f8c73 100644 --- a/composer.json +++ b/composer.json @@ -8,7 +8,7 @@ "description": "Bonus points plugin for Sylius.", "license": "MIT", "require": { - "php": "^8.1", + "php": "^8.0", "sylius/sylius": "~1.12.0 || ~1.13.0" }, "require-dev": { diff --git a/tests/Application/Kernel.php b/tests/Application/Kernel.php index d1deec8..fb1afca 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 { diff --git a/tests/Application/config/bootstrap.php b/tests/Application/config/bootstrap.php index 2291ab4..450a654 100644 --- a/tests/Application/config/bootstrap.php +++ b/tests/Application/config/bootstrap.php @@ -1,5 +1,12 @@ sharedStorage = $sharedStorage; $this->objectManager = $objectManager; @@ -65,7 +66,7 @@ public function thereIsABonusPointsStrategyWithRuleWithTaxon( string $code, string $name, string $ruleType, - string $taxon + string $taxon, ): void { $bonusPointsStrategy = $this->createBonusPointsStrategy($code, $name); diff --git a/tests/Behat/Context/Ui/Admin/BonusPointsStrategyContext.php b/tests/Behat/Context/Ui/Admin/BonusPointsStrategyContext.php index 2c16931..2d679ce 100755 --- a/tests/Behat/Context/Ui/Admin/BonusPointsStrategyContext.php +++ b/tests/Behat/Context/Ui/Admin/BonusPointsStrategyContext.php @@ -1,10 +1,11 @@ sharedStorage = $sharedStorage; $this->currentPageResolver = $currentPageResolver; @@ -167,7 +168,7 @@ public function iShouldBeNotifiedThatTheBonusPointsStrategyHasBeenCreated(): voi { $this->notificationChecker->checkNotification( 'Bonus points strategy has been successfully created.', - NotificationType::success() + NotificationType::success(), ); } @@ -178,7 +179,7 @@ public function iShouldBeNotifiedThatTheBonusPointsStrategySuccessfullyHasBeenDe { $this->notificationChecker->checkNotification( 'Bonus points strategy has been successfully deleted.', - NotificationType::success() + NotificationType::success(), ); } @@ -189,7 +190,7 @@ public function iShouldBeNotifiedThatTheAutomaticBlacklistingConfigurationSucces { $this->notificationChecker->checkNotification( 'Bonus points strategy has been successfully updated.', - NotificationType::success() + NotificationType::success(), ); } diff --git a/tests/Behat/Context/Ui/Shop/CartContext.php b/tests/Behat/Context/Ui/Shop/CartContext.php index b328e9f..0dffc8b 100755 --- a/tests/Behat/Context/Ui/Shop/CartContext.php +++ b/tests/Behat/Context/Ui/Shop/CartContext.php @@ -1,10 +1,11 @@ Date: Mon, 8 Jul 2024 14:31:01 +0200 Subject: [PATCH 07/15] OP-376 - Change constructor syntax --- src/Assigner/BonusPointsAssigner.php | 16 +++---- ...elegatingBonusPointsStrategyCalculator.php | 4 +- ...sPointsStrategyRulesEligibilityChecker.php | 2 +- src/Checker/Rule/HasTaxonRuleChecker.php | 2 +- src/Context/CustomerBonusPointsContext.php | 6 +-- .../ResetOrderBonusPointsAction.php | 6 +-- src/Creator/BonusPointsCreator.php | 4 +- .../OrderBonusPointsListener.php | 6 +-- src/Form/Extension/CartTypeExtension.php | 6 +-- ...onfigurableBonusPointsStrategyRuleType.php | 2 +- .../AbstractConfigurationCollectionType.php | 2 +- ...onusPointsStrategyCalculatorChoiceType.php | 2 +- .../BonusPointsStrategyRuleChoiceType.php | 2 +- src/Form/Type/BonusPointsStrategyType.php | 4 +- .../PerOrderPriceConfigurationType.php | 2 +- .../Type/Rule/HasTaxonConfigurationType.php | 2 +- .../OrderBonusPointsProcessor.php | 8 ++-- .../ResetOrderBonusPointsProcessor.php | 4 +- src/Purifier/OrderBonusPointsPurifier.php | 6 +-- src/Resolver/BonusPointsResolver.php | 2 +- src/Twig/Extension/BonusPointsExtension.php | 2 +- .../Constraints/BonusPointsApplyValidator.php | 4 +- .../BonusPointsAvailabilityValidator.php | 4 +- .../Setup/BonusPointsStrategyContext.php | 36 +++------------- .../Ui/Admin/BonusPointsStrategyContext.php | 42 ++++--------------- tests/Behat/Context/Ui/Shop/CartContext.php | 9 ++-- .../Ui/Shop/CheckoutCompleteContext.php | 9 ++-- 27 files changed, 68 insertions(+), 126 deletions(-) diff --git a/src/Assigner/BonusPointsAssigner.php b/src/Assigner/BonusPointsAssigner.php index a954abc..ab9a7dd 100644 --- a/src/Assigner/BonusPointsAssigner.php +++ b/src/Assigner/BonusPointsAssigner.php @@ -33,14 +33,14 @@ final class BonusPointsAssigner implements BonusPointsAssignerInterface { public function __construct( - private readonly DelegatingBonusPointsStrategyCalculatorInterface $delegatingBonusPointsStrategyCalculator, - private readonly BonusPointsStrategyEligibilityCheckerInterface $bonusPointsStrategyEligibilityChecker, - private readonly BonusPointsStrategyRepositoryInterface $bonusPointsStrategyRepository, - private readonly FactoryInterface $bonusPointsFactory, - private readonly EntityManagerInterface $bonusPointsEntityManager, - private readonly RepositoryInterface $customerBonusPointsRepository, - private readonly FactoryInterface $customerBonusPointsFactory, - private readonly ProportionalIntegerDistributorInterface $proportionalIntegerDistributor, + private DelegatingBonusPointsStrategyCalculatorInterface $delegatingBonusPointsStrategyCalculator, + private BonusPointsStrategyEligibilityCheckerInterface $bonusPointsStrategyEligibilityChecker, + private BonusPointsStrategyRepositoryInterface $bonusPointsStrategyRepository, + private FactoryInterface $bonusPointsFactory, + private EntityManagerInterface $bonusPointsEntityManager, + private RepositoryInterface $customerBonusPointsRepository, + private FactoryInterface $customerBonusPointsFactory, + private ProportionalIntegerDistributorInterface $proportionalIntegerDistributor, ) { } diff --git a/src/Calculator/DelegatingBonusPointsStrategyCalculator.php b/src/Calculator/DelegatingBonusPointsStrategyCalculator.php index f262240..4c24789 100644 --- a/src/Calculator/DelegatingBonusPointsStrategyCalculator.php +++ b/src/Calculator/DelegatingBonusPointsStrategyCalculator.php @@ -19,8 +19,8 @@ final class DelegatingBonusPointsStrategyCalculator implements DelegatingBonusPointsStrategyCalculatorInterface { public function __construct( - private readonly ServiceRegistryInterface $registry, - private readonly BonusPointsStrategyEligibilityCheckerInterface $bonusPointsStrategyEligibilityChecker, + private ServiceRegistryInterface $registry, + private BonusPointsStrategyEligibilityCheckerInterface $bonusPointsStrategyEligibilityChecker, ) { } diff --git a/src/Checker/Eligibility/BonusPointsStrategyRulesEligibilityChecker.php b/src/Checker/Eligibility/BonusPointsStrategyRulesEligibilityChecker.php index 8e88841..251c94c 100644 --- a/src/Checker/Eligibility/BonusPointsStrategyRulesEligibilityChecker.php +++ b/src/Checker/Eligibility/BonusPointsStrategyRulesEligibilityChecker.php @@ -20,7 +20,7 @@ final class BonusPointsStrategyRulesEligibilityChecker implements BonusPointsStrategyEligibilityCheckerInterface { public function __construct( - private readonly ServiceRegistryInterface $ruleRegistry, + private ServiceRegistryInterface $ruleRegistry, ) { } diff --git a/src/Checker/Rule/HasTaxonRuleChecker.php b/src/Checker/Rule/HasTaxonRuleChecker.php index 5b84f1b..981e673 100644 --- a/src/Checker/Rule/HasTaxonRuleChecker.php +++ b/src/Checker/Rule/HasTaxonRuleChecker.php @@ -21,7 +21,7 @@ final class HasTaxonRuleChecker implements BonusPointsStrategyRuleCheckerInterfa public const TYPE = 'has_taxon'; public function __construct( - private readonly TaxonRepositoryInterface $taxonRepository, + private TaxonRepositoryInterface $taxonRepository, ) { } diff --git a/src/Context/CustomerBonusPointsContext.php b/src/Context/CustomerBonusPointsContext.php index cc7c5cf..0acce77 100644 --- a/src/Context/CustomerBonusPointsContext.php +++ b/src/Context/CustomerBonusPointsContext.php @@ -20,9 +20,9 @@ final class CustomerBonusPointsContext implements CustomerBonusPointsContextInterface { public function __construct( - private readonly CustomerContextInterface $customerContext, - private readonly RepositoryInterface $customerBonusPointsRepository, - private readonly FactoryInterface $customerBonusPointsFactory, + private CustomerContextInterface $customerContext, + private RepositoryInterface $customerBonusPointsRepository, + private FactoryInterface $customerBonusPointsFactory, ) { } diff --git a/src/Controller/ResetOrderBonusPointsAction.php b/src/Controller/ResetOrderBonusPointsAction.php index 8871b18..b5a1466 100644 --- a/src/Controller/ResetOrderBonusPointsAction.php +++ b/src/Controller/ResetOrderBonusPointsAction.php @@ -21,9 +21,9 @@ final class ResetOrderBonusPointsAction { public function __construct( - private readonly RouterInterface $router, - private readonly CartContextInterface $cartContext, - private readonly ResetOrderBonusPointsProcessorInterface $resetOrderBonusPointsProcessor, + private RouterInterface $router, + private CartContextInterface $cartContext, + private ResetOrderBonusPointsProcessorInterface $resetOrderBonusPointsProcessor, ) { } diff --git a/src/Creator/BonusPointsCreator.php b/src/Creator/BonusPointsCreator.php index 2a2e815..dd3ca77 100644 --- a/src/Creator/BonusPointsCreator.php +++ b/src/Creator/BonusPointsCreator.php @@ -20,8 +20,8 @@ final class BonusPointsCreator implements BonusPointsCreatorInterface { public function __construct( - private readonly FactoryInterface $bonusPointsFactory, - private readonly BonusPointsRepositoryInterface $bonusPointsRepository, + private FactoryInterface $bonusPointsFactory, + private BonusPointsRepositoryInterface $bonusPointsRepository, ) { } diff --git a/src/EventListener/OrderBonusPointsListener.php b/src/EventListener/OrderBonusPointsListener.php index b6cfa5e..99f7c6e 100644 --- a/src/EventListener/OrderBonusPointsListener.php +++ b/src/EventListener/OrderBonusPointsListener.php @@ -23,9 +23,9 @@ final class OrderBonusPointsListener { public function __construct( - private readonly BonusPointsCreatorInterface $bonusPointsCreator, - private readonly CustomerBonusPointsContextInterface $customerBonusPointsContext, - private readonly ResetOrderBonusPointsProcessorInterface $resetBonusPointsProcessor, + private BonusPointsCreatorInterface $bonusPointsCreator, + private CustomerBonusPointsContextInterface $customerBonusPointsContext, + private ResetOrderBonusPointsProcessorInterface $resetBonusPointsProcessor, ) { } diff --git a/src/Form/Extension/CartTypeExtension.php b/src/Form/Extension/CartTypeExtension.php index e5fb636..30b5fb3 100644 --- a/src/Form/Extension/CartTypeExtension.php +++ b/src/Form/Extension/CartTypeExtension.php @@ -25,9 +25,9 @@ final class CartTypeExtension extends AbstractTypeExtension { public function __construct( - private readonly CustomerBonusPointsContextInterface $customerBonusPointsContext, - private readonly BonusPointsResolverInterface $bonusPointsResolver, - private readonly CartContextInterface $cartContext, + private CustomerBonusPointsContextInterface $customerBonusPointsContext, + private BonusPointsResolverInterface $bonusPointsResolver, + private CartContextInterface $cartContext, ) { } diff --git a/src/Form/Type/AbstractConfigurableBonusPointsStrategyRuleType.php b/src/Form/Type/AbstractConfigurableBonusPointsStrategyRuleType.php index 293082b..f1aec66 100644 --- a/src/Form/Type/AbstractConfigurableBonusPointsStrategyRuleType.php +++ b/src/Form/Type/AbstractConfigurableBonusPointsStrategyRuleType.php @@ -25,7 +25,7 @@ abstract class AbstractConfigurableBonusPointsStrategyRuleType extends AbstractR public function __construct( string $dataClass, array $validationGroups = [], - private readonly FormTypeRegistryInterface $formTypeRegistry, + private FormTypeRegistryInterface $formTypeRegistry, ) { parent::__construct($dataClass, $validationGroups); } diff --git a/src/Form/Type/AbstractConfigurationCollectionType.php b/src/Form/Type/AbstractConfigurationCollectionType.php index 3eaefbb..932706f 100644 --- a/src/Form/Type/AbstractConfigurationCollectionType.php +++ b/src/Form/Type/AbstractConfigurationCollectionType.php @@ -22,7 +22,7 @@ abstract class AbstractConfigurationCollectionType extends AbstractType { public function __construct( - private readonly ServiceRegistryInterface $registry, + private ServiceRegistryInterface $registry, ) { } diff --git a/src/Form/Type/BonusPointsStrategyCalculatorChoiceType.php b/src/Form/Type/BonusPointsStrategyCalculatorChoiceType.php index 0d356ae..47bf0d6 100755 --- a/src/Form/Type/BonusPointsStrategyCalculatorChoiceType.php +++ b/src/Form/Type/BonusPointsStrategyCalculatorChoiceType.php @@ -18,7 +18,7 @@ final class BonusPointsStrategyCalculatorChoiceType extends AbstractType { public function __construct( - private readonly array $calculators, + private array $calculators, ) { } diff --git a/src/Form/Type/BonusPointsStrategyRuleChoiceType.php b/src/Form/Type/BonusPointsStrategyRuleChoiceType.php index 7cabb65..2af29bf 100755 --- a/src/Form/Type/BonusPointsStrategyRuleChoiceType.php +++ b/src/Form/Type/BonusPointsStrategyRuleChoiceType.php @@ -18,7 +18,7 @@ final class BonusPointsStrategyRuleChoiceType extends AbstractType { public function __construct( - private readonly array $rules, + private array $rules, ) { } diff --git a/src/Form/Type/BonusPointsStrategyType.php b/src/Form/Type/BonusPointsStrategyType.php index 69530db..d28e064 100644 --- a/src/Form/Type/BonusPointsStrategyType.php +++ b/src/Form/Type/BonusPointsStrategyType.php @@ -29,8 +29,8 @@ final class BonusPointsStrategyType extends AbstractResourceType public function __construct( string $dataClass, array $validationGroups, - private readonly ServiceRegistryInterface $calculatorRegistry, - private readonly FormTypeRegistryInterface $formTypeRegistry, + private ServiceRegistryInterface $calculatorRegistry, + private FormTypeRegistryInterface $formTypeRegistry, ) { parent::__construct($dataClass, $validationGroups); } diff --git a/src/Form/Type/Calculator/PerOrderPriceConfigurationType.php b/src/Form/Type/Calculator/PerOrderPriceConfigurationType.php index 0b51e38..d5edebf 100644 --- a/src/Form/Type/Calculator/PerOrderPriceConfigurationType.php +++ b/src/Form/Type/Calculator/PerOrderPriceConfigurationType.php @@ -24,7 +24,7 @@ final class PerOrderPriceConfigurationType extends AbstractType { public function __construct( - private readonly ChannelContextInterface $channelContext, + private ChannelContextInterface $channelContext, ) { } diff --git a/src/Form/Type/Rule/HasTaxonConfigurationType.php b/src/Form/Type/Rule/HasTaxonConfigurationType.php index 7e691db..69fab25 100644 --- a/src/Form/Type/Rule/HasTaxonConfigurationType.php +++ b/src/Form/Type/Rule/HasTaxonConfigurationType.php @@ -20,7 +20,7 @@ final class HasTaxonConfigurationType extends AbstractType { public function __construct( - private readonly DataTransformerInterface $taxonsToCodesTransformer, + private DataTransformerInterface $taxonsToCodesTransformer, ) { } diff --git a/src/OrderProcessing/OrderBonusPointsProcessor.php b/src/OrderProcessing/OrderBonusPointsProcessor.php index 5d2f2e3..6570515 100644 --- a/src/OrderProcessing/OrderBonusPointsProcessor.php +++ b/src/OrderProcessing/OrderBonusPointsProcessor.php @@ -25,10 +25,10 @@ final class OrderBonusPointsProcessor implements OrderProcessorInterface { public function __construct( - private readonly RepositoryInterface $bonusPointsRepository, - private readonly ObjectManager $bonusPointsManager, - private readonly AdjustmentFactoryInterface $adjustmentFactory, - private readonly OrderBonusPointsPurifierInterface $orderBonusPointsPurifier, + private RepositoryInterface $bonusPointsRepository, + private ObjectManager $bonusPointsManager, + private AdjustmentFactoryInterface $adjustmentFactory, + private OrderBonusPointsPurifierInterface $orderBonusPointsPurifier, ) { } diff --git a/src/Processor/ResetOrderBonusPointsProcessor.php b/src/Processor/ResetOrderBonusPointsProcessor.php index 27d5786..3c274c5 100644 --- a/src/Processor/ResetOrderBonusPointsProcessor.php +++ b/src/Processor/ResetOrderBonusPointsProcessor.php @@ -20,8 +20,8 @@ final class ResetOrderBonusPointsProcessor implements ResetOrderBonusPointsProcessorInterface { public function __construct( - private readonly OrderBonusPointsPurifierInterface $orderBonusPointsPurifier, - private readonly RepositoryInterface $bonusPointsRepository, + private OrderBonusPointsPurifierInterface $orderBonusPointsPurifier, + private RepositoryInterface $bonusPointsRepository, ) { } diff --git a/src/Purifier/OrderBonusPointsPurifier.php b/src/Purifier/OrderBonusPointsPurifier.php index 04e16a5..c3e07ca 100644 --- a/src/Purifier/OrderBonusPointsPurifier.php +++ b/src/Purifier/OrderBonusPointsPurifier.php @@ -22,9 +22,9 @@ final class OrderBonusPointsPurifier implements OrderBonusPointsPurifierInterface { public function __construct( - private readonly CustomerBonusPointsContextInterface $customerBonusPointsContext, - private readonly ObjectManager $persistenceManager, - private readonly RepositoryInterface $bonusPointsRepository, + private CustomerBonusPointsContextInterface $customerBonusPointsContext, + private ObjectManager $persistenceManager, + private RepositoryInterface $bonusPointsRepository, ) { } diff --git a/src/Resolver/BonusPointsResolver.php b/src/Resolver/BonusPointsResolver.php index 5fdb6d6..59a4db5 100644 --- a/src/Resolver/BonusPointsResolver.php +++ b/src/Resolver/BonusPointsResolver.php @@ -18,7 +18,7 @@ final class BonusPointsResolver implements BonusPointsResolverInterface { public function __construct( - private readonly CustomerBonusPointsContextInterface $customerBonusPointsContext, + private CustomerBonusPointsContextInterface $customerBonusPointsContext, ) { } diff --git a/src/Twig/Extension/BonusPointsExtension.php b/src/Twig/Extension/BonusPointsExtension.php index 245b1df..296a36e 100644 --- a/src/Twig/Extension/BonusPointsExtension.php +++ b/src/Twig/Extension/BonusPointsExtension.php @@ -18,7 +18,7 @@ class BonusPointsExtension extends AbstractExtension { public function __construct( - private readonly BonusPointsResolverInterface $bonusPointsResolver, + private BonusPointsResolverInterface $bonusPointsResolver, ) { } diff --git a/src/Validator/Constraints/BonusPointsApplyValidator.php b/src/Validator/Constraints/BonusPointsApplyValidator.php index 2d7bc3b..a2af296 100644 --- a/src/Validator/Constraints/BonusPointsApplyValidator.php +++ b/src/Validator/Constraints/BonusPointsApplyValidator.php @@ -20,8 +20,8 @@ final class BonusPointsApplyValidator extends ConstraintValidator { public function __construct( - private readonly BonusPointsStrategyRepositoryInterface $bonusPointsStrategyRepository, - private readonly CartContextInterface $cartContext, + private BonusPointsStrategyRepositoryInterface $bonusPointsStrategyRepository, + private CartContextInterface $cartContext, ) { } diff --git a/src/Validator/Constraints/BonusPointsAvailabilityValidator.php b/src/Validator/Constraints/BonusPointsAvailabilityValidator.php index bc0451c..2aa3c11 100644 --- a/src/Validator/Constraints/BonusPointsAvailabilityValidator.php +++ b/src/Validator/Constraints/BonusPointsAvailabilityValidator.php @@ -23,8 +23,8 @@ final class BonusPointsAvailabilityValidator extends ConstraintValidator { public function __construct( - private readonly BonusPointsResolverInterface $bonusPointsResolver, - private readonly RepositoryInterface $bonusPointsRepository, + private BonusPointsResolverInterface $bonusPointsResolver, + private RepositoryInterface $bonusPointsRepository, ) { } diff --git a/tests/Behat/Context/Setup/BonusPointsStrategyContext.php b/tests/Behat/Context/Setup/BonusPointsStrategyContext.php index 85afa7c..e3a5fea 100755 --- a/tests/Behat/Context/Setup/BonusPointsStrategyContext.php +++ b/tests/Behat/Context/Setup/BonusPointsStrategyContext.php @@ -25,38 +25,14 @@ final class BonusPointsStrategyContext implements Context { - /** @var SharedStorageInterface */ - private $sharedStorage; - - /** @var ObjectManager */ - private $objectManager; - - /** @var FactoryInterface */ - private $bonusPointsStrategyFactory; - - /** @var FactoryInterface */ - private $bonusPointsStrategyRuleFactory; - - /** @var BonusPointsStrategyRepositoryInterface */ - private $bonusPointsStrategyRepository; - - /** @var TaxonRepositoryInterface */ - private $taxonRepository; - public function __construct( - FactoryInterface $bonusPointsStrategyFactory, - FactoryInterface $bonusPointsStrategyRuleFactory, - SharedStorageInterface $sharedStorage, - ObjectManager $objectManager, - BonusPointsStrategyRepositoryInterface $bonusPointsStrategyRepository, - TaxonRepositoryInterface $taxonRepository, + private FactoryInterface $bonusPointsStrategyFactory, + private FactoryInterface $bonusPointsStrategyRuleFactory, + private SharedStorageInterface $sharedStorage, + private ObjectManager $objectManager, + private BonusPointsStrategyRepositoryInterface $bonusPointsStrategyRepository, + private TaxonRepositoryInterface $taxonRepository, ) { - $this->sharedStorage = $sharedStorage; - $this->objectManager = $objectManager; - $this->bonusPointsStrategyFactory = $bonusPointsStrategyFactory; - $this->bonusPointsStrategyRuleFactory = $bonusPointsStrategyRuleFactory; - $this->bonusPointsStrategyRepository = $bonusPointsStrategyRepository; - $this->taxonRepository = $taxonRepository; } /** diff --git a/tests/Behat/Context/Ui/Admin/BonusPointsStrategyContext.php b/tests/Behat/Context/Ui/Admin/BonusPointsStrategyContext.php index 2d679ce..ea6f8fc 100755 --- a/tests/Behat/Context/Ui/Admin/BonusPointsStrategyContext.php +++ b/tests/Behat/Context/Ui/Admin/BonusPointsStrategyContext.php @@ -25,43 +25,15 @@ final class BonusPointsStrategyContext implements Context { - /** @var SharedStorageInterface */ - private $sharedStorage; - - /** @var CurrentPageResolverInterface */ - private $currentPageResolver; - - /** @var NotificationCheckerInterface */ - private $notificationChecker; - - /** @var IndexPageInterface */ - private $indexPage; - - /** @var CreatePageInterface */ - private $createPage; - - /** @var UpdatePageInterface */ - private $updatePage; - - /** @var BonusPointsStrategyRepositoryInterface */ - private $bonusPointsStrategyRepository; - public function __construct( - SharedStorageInterface $sharedStorage, - CurrentPageResolverInterface $currentPageResolver, - NotificationCheckerInterface $notificationChecker, - IndexPageInterface $indexPage, - CreatePageInterface $createPage, - UpdatePageInterface $updatePage, - BonusPointsStrategyRepositoryInterface $bonusPointsStrategyRepository, + private SharedStorageInterface $sharedStorage, + private CurrentPageResolverInterface $currentPageResolver, + private NotificationCheckerInterface $notificationChecker, + private IndexPageInterface $indexPage, + private CreatePageInterface $createPage, + private UpdatePageInterface $updatePage, + private BonusPointsStrategyRepositoryInterface $bonusPointsStrategyRepository, ) { - $this->sharedStorage = $sharedStorage; - $this->currentPageResolver = $currentPageResolver; - $this->notificationChecker = $notificationChecker; - $this->indexPage = $indexPage; - $this->createPage = $createPage; - $this->updatePage = $updatePage; - $this->bonusPointsStrategyRepository = $bonusPointsStrategyRepository; } /** diff --git a/tests/Behat/Context/Ui/Shop/CartContext.php b/tests/Behat/Context/Ui/Shop/CartContext.php index 0dffc8b..460049f 100755 --- a/tests/Behat/Context/Ui/Shop/CartContext.php +++ b/tests/Behat/Context/Ui/Shop/CartContext.php @@ -17,12 +17,9 @@ final class CartContext implements Context { - /** @var CartPageInterface */ - private $cartPage; - - public function __construct(CartPageInterface $cartPage) - { - $this->cartPage = $cartPage; + public function __construct( + private CartPageInterface $cartPage, + ) { } /** diff --git a/tests/Behat/Context/Ui/Shop/CheckoutCompleteContext.php b/tests/Behat/Context/Ui/Shop/CheckoutCompleteContext.php index f3d66d6..f0cf28d 100755 --- a/tests/Behat/Context/Ui/Shop/CheckoutCompleteContext.php +++ b/tests/Behat/Context/Ui/Shop/CheckoutCompleteContext.php @@ -17,12 +17,9 @@ final class CheckoutCompleteContext implements Context { - /** @var CompletePageInterface */ - private $completePage; - - public function __construct(CompletePageInterface $completePage) - { - $this->completePage = $completePage; + public function __construct( + private CompletePageInterface $completePage, + ) { } /** From 765ebbe25b8b43d277ec2b6d137cbdd55a791dc7 Mon Sep 17 00:00:00 2001 From: janpalen Date: Wed, 10 Jul 2024 16:04:09 +0200 Subject: [PATCH 08/15] OP-376 - Refactor configuration --- .github/workflows/build.yml | 15 ++-- composer.json | 5 +- tests/Application/.env.test | 4 +- tests/Application/config/bundles.php | 5 ++ .../config/sylius/1.11/bundles.php | 18 ---- .../sylius/1.11/packages/dev/swiftmailer.yaml | 2 - .../sylius/1.11/packages/swiftmailer.yaml | 2 - .../1.11/packages/test/swiftmailer.yaml | 6 -- .../packages/test_cached/swiftmailer.yaml | 6 -- .../config/sylius/1.12/bundles.php | 18 ---- .../config/sylius/1.13/bundles.php | 14 +++ .../{1.11 => 1.13}/packages/security.yaml | 86 +++++++------------ .../sylius/1.13/packages/test/mailer.yaml | 7 ++ .../packages/test}/security.yaml | 2 +- .../packages/test_cached}/security.yaml | 0 tests/Application/package.json | 6 +- tests/Application/package.json.~1.12.0.dist | 58 +++++++++++++ 17 files changed, 133 insertions(+), 121 deletions(-) delete mode 100644 tests/Application/config/sylius/1.11/bundles.php delete mode 100644 tests/Application/config/sylius/1.11/packages/dev/swiftmailer.yaml delete mode 100644 tests/Application/config/sylius/1.11/packages/swiftmailer.yaml delete mode 100644 tests/Application/config/sylius/1.11/packages/test/swiftmailer.yaml delete mode 100644 tests/Application/config/sylius/1.11/packages/test_cached/swiftmailer.yaml delete mode 100644 tests/Application/config/sylius/1.12/bundles.php create mode 100644 tests/Application/config/sylius/1.13/bundles.php rename tests/Application/config/sylius/{1.11 => 1.13}/packages/security.yaml (58%) create mode 100644 tests/Application/config/sylius/1.13/packages/test/mailer.yaml rename tests/Application/config/sylius/{1.11/packages/test_cached => 1.13/packages/test}/security.yaml (60%) rename tests/Application/config/sylius/{1.11/packages/test => 1.13/packages/test_cached}/security.yaml (100%) create mode 100644 tests/Application/package.json.~1.12.0.dist diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e70417b..07b72b7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -33,7 +33,7 @@ jobs: steps: - - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Setup PHP @@ -46,7 +46,7 @@ jobs: - name: Setup Node - uses: actions/setup-node@v1 + uses: actions/setup-node@v4 with: node-version: "${{ matrix.node }}" @@ -84,7 +84,7 @@ jobs: - name: Cache Composer - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: ${{ steps.composer-cache.outputs.dir }} key: ${{ runner.os }}-php-${{ matrix.php }}-composer-${{ hashFiles('**/composer.json **/composer.lock') }} @@ -109,7 +109,7 @@ jobs: - name: Get Yarn cache directory id: yarn-cache - run: echo "::set-output name=dir::$(yarn cache dir)" + run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT - name: Cache Yarn @@ -149,6 +149,10 @@ jobs: name: Validate database schema run: (cd tests/Application && bin/console doctrine:schema:validate) + - + name: Run ECS + run: vendor/bin/ecs check src + - name: Run PHPStan if: matrix.php != 8.0 @@ -158,14 +162,13 @@ jobs: name: Run PHPSpec run: vendor/bin/phpspec run --ansi -f progress --no-interaction - - name: Run Behat run: vendor/bin/behat --colors --strict -vvv --no-interaction || vendor/bin/behat --colors --strict -vvv --no-interaction --rerun - name: Upload Behat logs - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 if: failure() with: name: Behat logs diff --git a/composer.json b/composer.json index 60f8c73..63e13eb 100644 --- a/composer.json +++ b/composer.json @@ -8,7 +8,7 @@ "description": "Bonus points plugin for Sylius.", "license": "MIT", "require": { - "php": "^8.0", + "php": "^8.1", "sylius/sylius": "~1.12.0 || ~1.13.0" }, "require-dev": { @@ -41,6 +41,9 @@ "symfony/web-profiler-bundle": "^5.4 || ^6.0", "symfony/webpack-encore-bundle": "^1.14" }, + "conflict": { + "behat/mink-selenium2-driver": ">=1.7.0" + }, "prefer-stable": true, "autoload": { "psr-4": { diff --git a/tests/Application/.env.test b/tests/Application/.env.test index 36a1c38..003690d 100644 --- a/tests/Application/.env.test +++ b/tests/Application/.env.test @@ -1,7 +1,5 @@ -APP_ENV=test - APP_SECRET='ch4mb3r0f5ecr3ts' KERNEL_CLASS='Tests\BitBag\SyliusBonusPointsPlugin\Application\Kernel' -DATABASE_URL=sqlite:///%kernel.project_dir%/var/data_%kernel.environment%.db +DATABASE_URL=mysql://root@127.0.0.1/sylius_bonus_points_%kernel.environment%?serverVersion=5.5 diff --git a/tests/Application/config/bundles.php b/tests/Application/config/bundles.php index 7e398e8..42fbe8b 100644 --- a/tests/Application/config/bundles.php +++ b/tests/Application/config/bundles.php @@ -62,4 +62,9 @@ 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], + Sylius\Calendar\SyliusCalendarBundle::class => ['all' => true], + League\FlysystemBundle\FlysystemBundle::class => ['all' => true], + BabDev\PagerfantaBundle\BabDevPagerfantaBundle::class => ['all' => true], + SyliusLabs\Polyfill\Symfony\Security\Bundle\SyliusLabsPolyfillSymfonySecurityBundle::class => ['all' => true], ]; diff --git a/tests/Application/config/sylius/1.11/bundles.php b/tests/Application/config/sylius/1.11/bundles.php deleted file mode 100644 index e181580..0000000 --- a/tests/Application/config/sylius/1.11/bundles.php +++ /dev/null @@ -1,18 +0,0 @@ - ['all' => true], - Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle::class => ['all' => true], - SyliusLabs\Polyfill\Symfony\Security\Bundle\SyliusLabsPolyfillSymfonySecurityBundle::class => ['all' => true], - Sylius\Calendar\SyliusCalendarBundle::class => ['all' => true], - Symfony\WebpackEncoreBundle\WebpackEncoreBundle::class => ['all' => true], -]; 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/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/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 deleted file mode 100644 index 016613a..0000000 --- a/tests/Application/config/sylius/1.12/bundles.php +++ /dev/null @@ -1,18 +0,0 @@ - ['all' => true], - Symfony\WebpackEncoreBundle\WebpackEncoreBundle::class => ['all' => true], - Sylius\Calendar\SyliusCalendarBundle::class => ['all' => true], - BabDev\PagerfantaBundle\BabDevPagerfantaBundle::class => ['all' => true], - SyliusLabs\Polyfill\Symfony\Security\Bundle\SyliusLabsPolyfillSymfonySecurityBundle::class => ['all' => true], -]; diff --git a/tests/Application/config/sylius/1.13/bundles.php b/tests/Application/config/sylius/1.13/bundles.php new file mode 100644 index 0000000..e615f85 --- /dev/null +++ b/tests/Application/config/sylius/1.13/bundles.php @@ -0,0 +1,14 @@ + ['all' => true], +]; 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.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/Application/config/sylius/1.11/packages/test_cached/security.yaml b/tests/Application/config/sylius/1.13/packages/test/security.yaml similarity index 60% rename from tests/Application/config/sylius/1.11/packages/test_cached/security.yaml rename to tests/Application/config/sylius/1.13/packages/test/security.yaml index 21cc377..8ccd542 100644 --- a/tests/Application/config/sylius/1.11/packages/test_cached/security.yaml +++ b/tests/Application/config/sylius/1.13/packages/test/security.yaml @@ -1,3 +1,3 @@ security: - encoders: + password_hashers: sha512: sha512 diff --git a/tests/Application/config/sylius/1.11/packages/test/security.yaml b/tests/Application/config/sylius/1.13/packages/test_cached/security.yaml similarity index 100% rename from tests/Application/config/sylius/1.11/packages/test/security.yaml rename to tests/Application/config/sylius/1.13/packages/test_cached/security.yaml diff --git a/tests/Application/package.json b/tests/Application/package.json index 68380d8..51f71a7 100644 --- a/tests/Application/package.json +++ b/tests/Application/package.json @@ -1,15 +1,15 @@ { "dependencies": { - "babel-polyfill": "^6.26.0", + "babel-polyfill": "^7.0.0", "chart.js": "3.7.1", - "jquery": "^3.4.0", + "jquery": "^3.5.0", "jquery.dirtyforms": "^2.0.0", "lightbox2": "^2.9.0", "semantic-ui-css": "^2.2.0", "slick-carousel": "^1.8.1" }, "devDependencies": { - "@symfony/webpack-encore": "^0.28.0", + "@symfony/webpack-encore": "^1.6.1", "babel-core": "^6.26.3", "babel-plugin-external-helpers": "^6.22.0", "babel-plugin-module-resolver": "^3.1.1", diff --git a/tests/Application/package.json.~1.12.0.dist b/tests/Application/package.json.~1.12.0.dist new file mode 100644 index 0000000..68380d8 --- /dev/null +++ b/tests/Application/package.json.~1.12.0.dist @@ -0,0 +1,58 @@ +{ + "dependencies": { + "babel-polyfill": "^6.26.0", + "chart.js": "3.7.1", + "jquery": "^3.4.0", + "jquery.dirtyforms": "^2.0.0", + "lightbox2": "^2.9.0", + "semantic-ui-css": "^2.2.0", + "slick-carousel": "^1.8.1" + }, + "devDependencies": { + "@symfony/webpack-encore": "^0.28.0", + "babel-core": "^6.26.3", + "babel-plugin-external-helpers": "^6.22.0", + "babel-plugin-module-resolver": "^3.1.1", + "babel-plugin-transform-object-rest-spread": "^6.26.0", + "babel-preset-env": "^1.7.0", + "babel-register": "^6.26.0", + "dedent": "^0.7.0", + "eslint": "^4.19.1", + "eslint-config-airbnb-base": "^12.1.0", + "eslint-import-resolver-babel-module": "^4.0.0", + "eslint-plugin-import": "^2.11.0", + "fast-async": "^6.3.7", + "gulp": "^4.0.0", + "gulp-chug": "^0.5", + "gulp-concat": "^2.6.0", + "gulp-debug": "^2.1.2", + "gulp-if": "^2.0.0", + "gulp-livereload": "^4.0.1", + "gulp-order": "^1.1.1", + "gulp-sass": "^4.0.1", + "gulp-sourcemaps": "^1.6.0", + "gulp-uglifycss": "^1.0.5", + "merge-stream": "^1.0.0", + "rollup": "^0.60.2", + "rollup-plugin-babel": "^3.0.4", + "rollup-plugin-commonjs": "^9.1.3", + "rollup-plugin-inject": "^2.0.0", + "rollup-plugin-node-resolve": "^3.3.0", + "rollup-plugin-uglify": "^4.0.0", + "sass-loader": "^7.0.1", + "upath": "^1.1.0", + "yargs": "^6.4.0" + }, + "scripts": { + "build": "gulp build", + "gulp": "gulp build", + "lint": "yarn lint:js", + "lint:js": "eslint gulpfile.babel.js" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/Sylius/Sylius.git" + }, + "author": "Paweł Jędrzejewski", + "license": "MIT" +} From cb2c27828c6500fdb0b851da26deb5ebb4a7244a Mon Sep 17 00:00:00 2001 From: janpalen Date: Wed, 10 Jul 2024 16:05:55 +0200 Subject: [PATCH 09/15] OP-376 - Behat tests fix --- ...cting_bonus_points_with_per_order_price_calculator.feature | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/features/shop/collecting_bonus_points_with_per_order_price_calculator.feature b/features/shop/collecting_bonus_points_with_per_order_price_calculator.feature index aef3eee..b6407a7 100644 --- a/features/shop/collecting_bonus_points_with_per_order_price_calculator.feature +++ b/features/shop/collecting_bonus_points_with_per_order_price_calculator.feature @@ -11,7 +11,7 @@ Feature: Collecting bonus points And the store allows paying "Offline" And there is bonus points strategy with code "bitbag-bonus-points-strategy" and name "BitBag Bonus Points Strategy" with rule "Has Taxon" with "Watches" taxon And the bonus points strategy "bitbag-bonus-points-strategy" admits "2" points per one currency - And the store has a product "BitBag Watch" priced at "$2000.32" + And the store has a product "BitBag Watch" priced at "$2,000.32" And this product belongs to "Watches" And there is a customer "Francis Underwood" identified by an email "francis@underwood.com" and a password "whitehouse" And there is a customer "francis@underwood.com" that placed an order "#00000022" @@ -42,4 +42,4 @@ Feature: Collecting bonus points @ui @javascript Scenario: Unsuccessfully using of awarded bonus points with "per order price" calculator When I want to use "0.32" bonus points - Then I should be notified that this value should be natural number, greater than or equal to 1 \ No newline at end of file + Then I should be notified that this value should be natural number, greater than or equal to 1 From fd31d673b3c31747c493575eb5aee901d50884bb Mon Sep 17 00:00:00 2001 From: janpalen Date: Thu, 11 Jul 2024 11:57:50 +0200 Subject: [PATCH 10/15] OP-376 - PhpStan fixes --- src/Assigner/BonusPointsAssigner.php | 1 + src/Context/CustomerBonusPointsContext.php | 1 + src/Entity/CustomerBonusPoints.php | 2 +- src/Entity/CustomerBonusPointsInterface.php | 2 +- .../Type/AbstractConfigurableBonusPointsStrategyRuleType.php | 2 +- src/Validator/Constraints/BonusPointsApplyValidator.php | 1 + 6 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Assigner/BonusPointsAssigner.php b/src/Assigner/BonusPointsAssigner.php index ab9a7dd..d411470 100644 --- a/src/Assigner/BonusPointsAssigner.php +++ b/src/Assigner/BonusPointsAssigner.php @@ -80,6 +80,7 @@ public function assign(OrderInterface $order): void private function getCustomerBonusPoints(?CustomerInterface $customer): CustomerBonusPointsInterface { + /** @var CustomerBonusPointsInterface $customerBonusPoints */ $customerBonusPoints = $this->customerBonusPointsRepository->findOneBy([ 'customer' => $customer, ]) ?? $this->customerBonusPointsFactory->createNew(); diff --git a/src/Context/CustomerBonusPointsContext.php b/src/Context/CustomerBonusPointsContext.php index 0acce77..5283869 100644 --- a/src/Context/CustomerBonusPointsContext.php +++ b/src/Context/CustomerBonusPointsContext.php @@ -35,6 +35,7 @@ public function getCustomerBonusPoints(): ?CustomerBonusPointsInterface return null; } + /** @var CustomerBonusPointsInterface|null $customerBonusPoints */ $customerBonusPoints = $this->customerBonusPointsRepository->findOneBy([ 'customer' => $customer, ]); diff --git a/src/Entity/CustomerBonusPoints.php b/src/Entity/CustomerBonusPoints.php index 7db38c0..db786e2 100644 --- a/src/Entity/CustomerBonusPoints.php +++ b/src/Entity/CustomerBonusPoints.php @@ -14,7 +14,7 @@ use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\Criteria; -use Sylius\Component\Core\Model\CustomerInterface; +use Sylius\Component\Customer\Model\CustomerInterface; class CustomerBonusPoints implements CustomerBonusPointsInterface { diff --git a/src/Entity/CustomerBonusPointsInterface.php b/src/Entity/CustomerBonusPointsInterface.php index 2058a64..a1eca0c 100644 --- a/src/Entity/CustomerBonusPointsInterface.php +++ b/src/Entity/CustomerBonusPointsInterface.php @@ -12,7 +12,7 @@ namespace BitBag\SyliusBonusPointsPlugin\Entity; use Doctrine\Common\Collections\Collection; -use Sylius\Component\Core\Model\CustomerInterface; +use Sylius\Component\Customer\Model\CustomerInterface; use Sylius\Component\Resource\Model\ResourceInterface; interface CustomerBonusPointsInterface extends ResourceInterface diff --git a/src/Form/Type/AbstractConfigurableBonusPointsStrategyRuleType.php b/src/Form/Type/AbstractConfigurableBonusPointsStrategyRuleType.php index f1aec66..6b2224c 100644 --- a/src/Form/Type/AbstractConfigurableBonusPointsStrategyRuleType.php +++ b/src/Form/Type/AbstractConfigurableBonusPointsStrategyRuleType.php @@ -24,8 +24,8 @@ abstract class AbstractConfigurableBonusPointsStrategyRuleType extends AbstractR { public function __construct( string $dataClass, - array $validationGroups = [], private FormTypeRegistryInterface $formTypeRegistry, + array $validationGroups = [], ) { parent::__construct($dataClass, $validationGroups); } diff --git a/src/Validator/Constraints/BonusPointsApplyValidator.php b/src/Validator/Constraints/BonusPointsApplyValidator.php index a2af296..f1069cd 100644 --- a/src/Validator/Constraints/BonusPointsApplyValidator.php +++ b/src/Validator/Constraints/BonusPointsApplyValidator.php @@ -26,6 +26,7 @@ public function __construct( } /** + * @param mixed $bonusPoints * @param Constraint|BonusPointsApply $constraint */ public function validate($bonusPoints, Constraint $constraint): void From 3146c73688fd51162ae620e080c8d161b2eebdbe Mon Sep 17 00:00:00 2001 From: janpalen Date: Thu, 11 Jul 2024 12:25:38 +0200 Subject: [PATCH 11/15] OP-376 - Behat tests fixes --- .github/workflows/build.yml | 4 +- composer.json | 6 +- .../adding_bonus_points_strategy.feature | 4 +- .../managing_bonus_points_strategy.feature | 2 +- src/Resources/config/services/form.xml | 2 +- tests/Application/package.json | 9 +-- .../Context/Transform/LexicalContext.php | 56 +++++++++++++++++++ tests/Behat/Resources/services/contexts.xml | 1 + .../Resources/services/contexts/transform.xml | 14 +++++ .../suites/ui/collecting_bonus_points.yaml | 3 +- 10 files changed, 88 insertions(+), 13 deletions(-) create mode 100644 tests/Behat/Context/Transform/LexicalContext.php create mode 100644 tests/Behat/Resources/services/contexts/transform.xml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 07b72b7..7c6b381 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -21,10 +21,10 @@ jobs: strategy: fail-fast: false matrix: - php: ["8.1", "8.2", "8.3"] + php: ["8.1"] symfony: ["^5.4", "^6.0"] sylius: ["~1.12.0", "~1.13.0"] - node: ["18.x", "20.x"] + node: ["14.x"] mysql: ["5.7", "8.0"] env: diff --git a/composer.json b/composer.json index 63e13eb..9c5ca3c 100644 --- a/composer.json +++ b/composer.json @@ -39,10 +39,12 @@ "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.14" + "symfony/webpack-encore-bundle": "^1.14", + "doctrine/persistence": "^3.0" }, "conflict": { - "behat/mink-selenium2-driver": ">=1.7.0" + "behat/mink-selenium2-driver": ">=1.7.0", + "doctrine/annotations": ">1.15" }, "prefer-stable": true, "autoload": { diff --git a/features/admin/adding_bonus_points_strategy.feature b/features/admin/adding_bonus_points_strategy.feature index 5b8284d..d073594 100644 --- a/features/admin/adding_bonus_points_strategy.feature +++ b/features/admin/adding_bonus_points_strategy.feature @@ -7,7 +7,7 @@ Feature: Adding a new bonus points strategy Background: Given the store operates on a single channel in "United States" And I am logged in as an administrator - And the store classifies its products as "T-Shirts", "Watches", "Belts" and "Wallets" + And the store classifies its products as "T-shirts", "Watches", "Belts" and "Wallets" And the "T-Shirts" taxon has children taxon "Men" and "Women" @ui @javascript @@ -36,4 +36,4 @@ Feature: Adding a new bonus points strategy And I fill with "10" field "Percent to calculate points" And I add it Then I should be notified that the bonus points strategy has been created - And the "second-bitbag-bonus-points-strategy" should appear in the registry \ No newline at end of file + And the "second-bitbag-bonus-points-strategy" should appear in the registry diff --git a/features/admin/managing_bonus_points_strategy.feature b/features/admin/managing_bonus_points_strategy.feature index 23edfca..61c7084 100644 --- a/features/admin/managing_bonus_points_strategy.feature +++ b/features/admin/managing_bonus_points_strategy.feature @@ -7,7 +7,7 @@ Feature: Managing a new bonus points strategy Background: Given the store operates on a single channel in "United States" And I am logged in as an administrator - And the store classifies its products as "T-Shirts", "Watches", "Belts" and "Wallets" + And the store classifies its products as "T-shirts", "Watches", "Belts" and "Wallets" And the "T-Shirts" taxon has children taxon "Men" and "Women" And there is bonus points strategy with code "bitbag-bonus-points-strategy" and name "BitBag Bonus Points Strategy" with rule "Has taxon" with "Watches" taxon And the bonus points strategy "bitbag-bonus-points-strategy" admits "2" points per one currency diff --git a/src/Resources/config/services/form.xml b/src/Resources/config/services/form.xml index 8aeccb4..32f96ca 100755 --- a/src/Resources/config/services/form.xml +++ b/src/Resources/config/services/form.xml @@ -17,8 +17,8 @@ %bitbag_sylius_bonus_points.model.bonus_points_strategy_rule.class% - %bitbag.form.type.validation_groups% + %bitbag.form.type.validation_groups% diff --git a/tests/Application/package.json b/tests/Application/package.json index 51f71a7..7855577 100644 --- a/tests/Application/package.json +++ b/tests/Application/package.json @@ -1,6 +1,6 @@ { "dependencies": { - "babel-polyfill": "^7.0.0", + "babel-polyfill": "^6.26.0", "chart.js": "3.7.1", "jquery": "^3.5.0", "jquery.dirtyforms": "^2.0.0", @@ -39,13 +39,14 @@ "rollup-plugin-inject": "^2.0.0", "rollup-plugin-node-resolve": "^3.3.0", "rollup-plugin-uglify": "^4.0.0", - "sass-loader": "^7.0.1", + "sass-loader": "^12.1.0", "upath": "^1.1.0", "yargs": "^6.4.0" }, "scripts": { - "build": "gulp build", - "gulp": "gulp build", + "dev": "yarn encore dev", + "watch": "yarn encore dev --watch", + "prod": "yarn encore prod", "lint": "yarn lint:js", "lint:js": "eslint gulpfile.babel.js" }, diff --git a/tests/Behat/Context/Transform/LexicalContext.php b/tests/Behat/Context/Transform/LexicalContext.php new file mode 100644 index 0000000..17e6a94 --- /dev/null +++ b/tests/Behat/Context/Transform/LexicalContext.php @@ -0,0 +1,56 @@ +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/Resources/services/contexts.xml b/tests/Behat/Resources/services/contexts.xml index 7cb6a4e..7f563f7 100644 --- a/tests/Behat/Resources/services/contexts.xml +++ b/tests/Behat/Resources/services/contexts.xml @@ -4,5 +4,6 @@ + diff --git a/tests/Behat/Resources/services/contexts/transform.xml b/tests/Behat/Resources/services/contexts/transform.xml new file mode 100644 index 0000000..c00ee6c --- /dev/null +++ b/tests/Behat/Resources/services/contexts/transform.xml @@ -0,0 +1,14 @@ + + + + + + + + + + diff --git a/tests/Behat/Resources/suites/ui/collecting_bonus_points.yaml b/tests/Behat/Resources/suites/ui/collecting_bonus_points.yaml index f9b654f..3111433 100755 --- a/tests/Behat/Resources/suites/ui/collecting_bonus_points.yaml +++ b/tests/Behat/Resources/suites/ui/collecting_bonus_points.yaml @@ -65,5 +65,6 @@ default: - bitbag_sylius_bonus_points_plugin.behat.context.setup.bonus_points_strategy - bitbag_sylius_bonus_points_plugin.behat.context.ui.shop.cart - bitbag_sylius_bonus_points_plugin.behat.context.ui.shop.checkout_complete + - bitbag_sylius_bonus_points_plugin.behat.context.transform.lexical filters: - tags: "@collecting_bonus_points && @ui" \ No newline at end of file + tags: "@collecting_bonus_points && @ui" From 3d4232051d8fe0e9a38e23034677ba8133b98cf8 Mon Sep 17 00:00:00 2001 From: janpalen Date: Mon, 15 Jul 2024 14:53:29 +0200 Subject: [PATCH 12/15] OP-376 - Fixes --- .github/workflows/build.yml | 5 +- composer.json | 2 +- ecs.php | 2 - tests/Application/package.json.~1.12.0.dist | 58 --------------------- 4 files changed, 5 insertions(+), 62 deletions(-) delete mode 100644 tests/Application/package.json.~1.12.0.dist diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7c6b381..d8632bb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -21,11 +21,14 @@ jobs: strategy: fail-fast: false matrix: - php: ["8.1"] + php: ["8.0", "8.1"] symfony: ["^5.4", "^6.0"] sylius: ["~1.12.0", "~1.13.0"] node: ["14.x"] mysql: ["5.7", "8.0"] + exclude: + - sylius: "~1.13.0" + php: "8.0" env: APP_ENV: test diff --git a/composer.json b/composer.json index 9c5ca3c..d61b28b 100644 --- a/composer.json +++ b/composer.json @@ -8,7 +8,7 @@ "description": "Bonus points plugin for Sylius.", "license": "MIT", "require": { - "php": "^8.1", + "php": "^8.0 || ^8.1", "sylius/sylius": "~1.12.0 || ~1.13.0" }, "require-dev": { diff --git a/ecs.php b/ecs.php index 4a3eb77..4982640 100644 --- a/ecs.php +++ b/ecs.php @@ -5,8 +5,6 @@ use Symplify\EasyCodingStandard\Config\ECSConfig; return static function (ECSConfig $config): void { - - // Change this if you want to automatically add BitBag OpenSource Header putenv('ALLOW_BITBAG_OS_HEADER=1'); $config->import('vendor/bitbag/coding-standard/ecs.php'); diff --git a/tests/Application/package.json.~1.12.0.dist b/tests/Application/package.json.~1.12.0.dist deleted file mode 100644 index 68380d8..0000000 --- a/tests/Application/package.json.~1.12.0.dist +++ /dev/null @@ -1,58 +0,0 @@ -{ - "dependencies": { - "babel-polyfill": "^6.26.0", - "chart.js": "3.7.1", - "jquery": "^3.4.0", - "jquery.dirtyforms": "^2.0.0", - "lightbox2": "^2.9.0", - "semantic-ui-css": "^2.2.0", - "slick-carousel": "^1.8.1" - }, - "devDependencies": { - "@symfony/webpack-encore": "^0.28.0", - "babel-core": "^6.26.3", - "babel-plugin-external-helpers": "^6.22.0", - "babel-plugin-module-resolver": "^3.1.1", - "babel-plugin-transform-object-rest-spread": "^6.26.0", - "babel-preset-env": "^1.7.0", - "babel-register": "^6.26.0", - "dedent": "^0.7.0", - "eslint": "^4.19.1", - "eslint-config-airbnb-base": "^12.1.0", - "eslint-import-resolver-babel-module": "^4.0.0", - "eslint-plugin-import": "^2.11.0", - "fast-async": "^6.3.7", - "gulp": "^4.0.0", - "gulp-chug": "^0.5", - "gulp-concat": "^2.6.0", - "gulp-debug": "^2.1.2", - "gulp-if": "^2.0.0", - "gulp-livereload": "^4.0.1", - "gulp-order": "^1.1.1", - "gulp-sass": "^4.0.1", - "gulp-sourcemaps": "^1.6.0", - "gulp-uglifycss": "^1.0.5", - "merge-stream": "^1.0.0", - "rollup": "^0.60.2", - "rollup-plugin-babel": "^3.0.4", - "rollup-plugin-commonjs": "^9.1.3", - "rollup-plugin-inject": "^2.0.0", - "rollup-plugin-node-resolve": "^3.3.0", - "rollup-plugin-uglify": "^4.0.0", - "sass-loader": "^7.0.1", - "upath": "^1.1.0", - "yargs": "^6.4.0" - }, - "scripts": { - "build": "gulp build", - "gulp": "gulp build", - "lint": "yarn lint:js", - "lint:js": "eslint gulpfile.babel.js" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/Sylius/Sylius.git" - }, - "author": "Paweł Jędrzejewski", - "license": "MIT" -} From bcc70b2dfb3be0996dc5987585c79761537bbbc0 Mon Sep 17 00:00:00 2001 From: janpalen Date: Fri, 19 Jul 2024 10:35:36 +0200 Subject: [PATCH 13/15] OP-376 - Add installation to README --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 3493bad..6083fe5 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,7 @@ Like what we do? Want to join us? Check out our job listings on our [career page * [Overview](#overview) * [Support](#we-are-here-to-help) +* [Installation](doc/installation.md) * [Screenshots](#screenshots) * [About us](#about-us) * [Community](#community) From 1ecc346a7f9b511ffe18d1667bdb6887be969e77 Mon Sep 17 00:00:00 2001 From: janpalen Date: Fri, 19 Jul 2024 13:20:42 +0200 Subject: [PATCH 14/15] OP-376 - Change README file --- doc/installation.md | 57 ++++++++++++++++++++++++--------------------- 1 file changed, 31 insertions(+), 26 deletions(-) diff --git a/doc/installation.md b/doc/installation.md index deb236b..773029d 100644 --- a/doc/installation.md +++ b/doc/installation.md @@ -15,12 +15,14 @@ ]; ``` -1. Import required config by adding `config/packages/bitbag_sylius_bonus_points_plugin.yaml` file: +1. Import resource in your `config/packages/_sylius.yaml` ```yaml - # config/packages/bitbag_sylius_bonus_points_plugin.yaml + # config/packages/_sylius.yaml imports: + ... + - { resource: "@BitBagSyliusBonusPointsPlugin/Resources/config/config.yml" } ``` @@ -40,34 +42,37 @@ ```php - - - - - - ``` + /** + * @ORM\Entity + * @ORM\Table(name="sylius_order") + */ + #[ORM\Entity] + #[ORM\Table(name: 'sylius_order')] + class Order extends BaseOrder implements BonusPointsAwareInterface + { + #[ORM\Column(type: 'integer', nullable: true)] + protected ?int $bonusPoints = null; + + public function getBonusPoints(): ?int + { + return $this->bonusPoints; + } + + public function setBonusPoints(?int $bonusPoints): void + { + $this->bonusPoints = $bonusPoints; + } + } 1. Customize shop templates to include bonus points. For starter You may want copy to templates directory everything from plugin's tests/Application/templates From a1763470605dabfcba119260891c0bc2b5be9d18 Mon Sep 17 00:00:00 2001 From: janpalen Date: Wed, 24 Jul 2024 15:37:17 +0200 Subject: [PATCH 15/15] OP-376 - Upgrade for node20 --- .github/workflows/build.yml | 6 ++-- composer.json | 2 +- tests/Application/.env | 2 +- tests/Application/.env.test | 2 +- tests/Application/package.json | 57 ++++++++++++++++++---------------- 5 files changed, 37 insertions(+), 32 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d8632bb..6db7ff8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -21,11 +21,11 @@ jobs: strategy: fail-fast: false matrix: - php: ["8.0", "8.1"] + php: ["8.0", "8.1", "8.2", "8.3"] symfony: ["^5.4", "^6.0"] sylius: ["~1.12.0", "~1.13.0"] - node: ["14.x"] - mysql: ["5.7", "8.0"] + node: ["20.x"] + mysql: ["8.0"] exclude: - sylius: "~1.13.0" php: "8.0" diff --git a/composer.json b/composer.json index d61b28b..40f2ffb 100644 --- a/composer.json +++ b/composer.json @@ -8,7 +8,7 @@ "description": "Bonus points plugin for Sylius.", "license": "MIT", "require": { - "php": "^8.0 || ^8.1", + "php": "^8.0 || ^8.1 || ^8.2 || ^8.3", "sylius/sylius": "~1.12.0 || ~1.13.0" }, "require-dev": { diff --git a/tests/Application/.env b/tests/Application/.env index fe799b5..da00206 100644 --- a/tests/Application/.env +++ b/tests/Application/.env @@ -12,7 +12,7 @@ APP_SECRET=EDITME # Format described at http://docs.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url # For a sqlite database, use: "sqlite:///%kernel.project_dir%/var/data_%kernel.environment%.db.db" # Set "serverVersion" to your server version to avoid edge-case exceptions and extra database calls -DATABASE_URL=mysql://root@127.0.0.1/sylius_bonus_points_%kernel.environment%?serverVersion=5.5 +DATABASE_URL=mysql://root@127.0.0.1/sylius_bonus_points_%kernel.environment%?serverVersion=8.0 ###< doctrine/doctrine-bundle ### ###> symfony/swiftmailer-bundle ### diff --git a/tests/Application/.env.test b/tests/Application/.env.test index 003690d..ac117bc 100644 --- a/tests/Application/.env.test +++ b/tests/Application/.env.test @@ -2,4 +2,4 @@ APP_SECRET='ch4mb3r0f5ecr3ts' KERNEL_CLASS='Tests\BitBag\SyliusBonusPointsPlugin\Application\Kernel' -DATABASE_URL=mysql://root@127.0.0.1/sylius_bonus_points_%kernel.environment%?serverVersion=5.5 +DATABASE_URL=mysql://root@127.0.0.1/sylius_bonus_points_%kernel.environment%?serverVersion=8.0 diff --git a/tests/Application/package.json b/tests/Application/package.json index 7855577..5125560 100644 --- a/tests/Application/package.json +++ b/tests/Application/package.json @@ -1,47 +1,52 @@ { "dependencies": { + "@babel/core": "^7.24.9", + "@babel/preset-env": "^7.14.7", "babel-polyfill": "^6.26.0", - "chart.js": "3.7.1", - "jquery": "^3.5.0", + "chart.js": "3.9.1", + "jquery": "^3.6.0", "jquery.dirtyforms": "^2.0.0", - "lightbox2": "^2.9.0", - "semantic-ui-css": "^2.2.0", + "lightbox2": "^2.11.0", + "semantic-ui-css": "^2.4.0", "slick-carousel": "^1.8.1" }, "devDependencies": { - "@symfony/webpack-encore": "^1.6.1", + "@symfony/webpack-encore": "^4.0.0", "babel-core": "^6.26.3", "babel-plugin-external-helpers": "^6.22.0", - "babel-plugin-module-resolver": "^3.1.1", + "babel-plugin-module-resolver": "^3.2.0", "babel-plugin-transform-object-rest-spread": "^6.26.0", "babel-preset-env": "^1.7.0", "babel-register": "^6.26.0", "dedent": "^0.7.0", - "eslint": "^4.19.1", - "eslint-config-airbnb-base": "^12.1.0", - "eslint-import-resolver-babel-module": "^4.0.0", - "eslint-plugin-import": "^2.11.0", - "fast-async": "^6.3.7", + "eslint": "^8.22.0", + "eslint-config-airbnb-base": "^15.0.0", + "eslint-import-resolver-babel-module": "^5.3.0", + "eslint-plugin-import": "^2.26.0", + "fast-async": "^7.0.0", "gulp": "^4.0.0", "gulp-chug": "^0.5", "gulp-concat": "^2.6.0", - "gulp-debug": "^2.1.2", - "gulp-if": "^2.0.0", + "gulp-debug": "^4.0.0", + "gulp-if": "^3.0.0", "gulp-livereload": "^4.0.1", "gulp-order": "^1.1.1", - "gulp-sass": "^4.0.1", - "gulp-sourcemaps": "^1.6.0", - "gulp-uglifycss": "^1.0.5", - "merge-stream": "^1.0.0", - "rollup": "^0.60.2", - "rollup-plugin-babel": "^3.0.4", - "rollup-plugin-commonjs": "^9.1.3", - "rollup-plugin-inject": "^2.0.0", - "rollup-plugin-node-resolve": "^3.3.0", - "rollup-plugin-uglify": "^4.0.0", - "sass-loader": "^12.1.0", - "upath": "^1.1.0", - "yargs": "^6.4.0" + "gulp-sass": "^5.1.0", + "gulp-sourcemaps": "^3.0.0", + "gulp-uglifycss": "^1.0.9", + "merge-stream": "^2.0.0", + "rollup": "^3.18.0", + "rollup-plugin-babel": "^4.4.0", + "rollup-plugin-commonjs": "^10.1.0", + "rollup-plugin-inject": "^3.0.0", + "rollup-plugin-node-resolve": "^5.2.0", + "rollup-plugin-uglify": "^6.0.0", + "sass": "^1.77.0", + "sass-loader": "^13.0.0", + "upath": "^2.0.0", + "webpack": "^5.93.0", + "webpack-cli": "^5.1.4", + "yargs": "^17.7.1" }, "scripts": { "dev": "yarn encore dev",