From 0f6219613502180cb140ecdcdeba09cd63ba2e2b Mon Sep 17 00:00:00 2001 From: hatem20 Date: Sun, 14 Feb 2021 02:12:38 +0200 Subject: [PATCH 1/6] [Product][Association] Fix attaching association with numeric code --- .../adding_product_with_associations.feature | 13 +++++++++++++ .../Context/Setup/ProductAssociationContext.php | 8 ++++++++ .../ProductsToProductAssociationsTransformer.php | 2 +- 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/features/product/managing_products/adding_product_with_associations.feature b/features/product/managing_products/adding_product_with_associations.feature index 8a67e18a7b..4b11ed192d 100644 --- a/features/product/managing_products/adding_product_with_associations.feature +++ b/features/product/managing_products/adding_product_with_associations.feature @@ -37,3 +37,16 @@ Feature: Adding a new product with associations And this product should have an association "Accessories" with product "LG headphones" And this product should not have an association "Accessories" with product "LG earphones" And the product "LG G3" should appear in the store + + @ui @javascript + Scenario: Adding a new product with association with numeric code + Given the store has 123 product association type + When I want to create a new simple product + And I specify its code as "lg_g3" + And I name it "LG G3" in "English (United States)" + And I set its price to "$400.00" for "United States" channel + And I associate as 123 the "LG headphones" and "LG earphones" products + And I add it + Then I should be notified that it has been successfully created + And this product should have an association 123 with products "LG headphones" and "LG earphones" + And the product "LG G3" should appear in the store diff --git a/src/Sylius/Behat/Context/Setup/ProductAssociationContext.php b/src/Sylius/Behat/Context/Setup/ProductAssociationContext.php index 5bd275b4d4..09d17f8c6a 100644 --- a/src/Sylius/Behat/Context/Setup/ProductAssociationContext.php +++ b/src/Sylius/Behat/Context/Setup/ProductAssociationContext.php @@ -71,6 +71,14 @@ final class ProductAssociationContext implements Context } } + /** + * @Given the store has :firstName product association type + */ + public function theStoreHasProductAssociationType($name) + { + $this->createProductAssociationType($name); + } + /** * @Given /^the (product "[^"]+") has(?:| also) an (association "[^"]+") with (product "[^"]+")$/ */ diff --git a/src/Sylius/Bundle/ProductBundle/Form/DataTransformer/ProductsToProductAssociationsTransformer.php b/src/Sylius/Bundle/ProductBundle/Form/DataTransformer/ProductsToProductAssociationsTransformer.php index 6981e1e2aa..0920fad836 100644 --- a/src/Sylius/Bundle/ProductBundle/Form/DataTransformer/ProductsToProductAssociationsTransformer.php +++ b/src/Sylius/Bundle/ProductBundle/Form/DataTransformer/ProductsToProductAssociationsTransformer.php @@ -75,7 +75,7 @@ final class ProductsToProductAssociationsTransformer implements DataTransformerI } /** @var ProductAssociationInterface $productAssociation */ - $productAssociation = $this->getProductAssociationByTypeCode($productAssociationTypeCode); + $productAssociation = $this->getProductAssociationByTypeCode((string) $productAssociationTypeCode); $this->setAssociatedProductsByProductCodes($productAssociation, $productCodes); $productAssociations->add($productAssociation); } From b9d2233b075b4e98fab09ea2c8296eaacfb7a47e Mon Sep 17 00:00:00 2001 From: Rafikooo Date: Fri, 7 Apr 2023 13:26:02 +0200 Subject: [PATCH 2/6] [Tasks] Improve Robo task --- RoboFile.php | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/RoboFile.php b/RoboFile.php index 6b86daf3aa..61a894264e 100644 --- a/RoboFile.php +++ b/RoboFile.php @@ -75,8 +75,8 @@ class RoboFile extends Tasks } $task - ->exec('composer validate --ansi --strict') ->exec('composer update --no-scripts --no-interaction') + ->exec('composer validate --ansi --strict') ; if (in_array($package, ['Bundle/AdminBundle', 'Bundle/ApiBundle', 'Bundle/CoreBundle'])) { @@ -103,10 +103,18 @@ class RoboFile extends Tasks private function createTestAssets(string $testAppDirectory): void { - mkdir(sprintf('%s/public/build/admin', $testAppDirectory), 0777, true); - mkdir(sprintf('%s/public/build/shop', $testAppDirectory), 0777, true); - file_put_contents(sprintf('%s/public/build/admin/manifest.json', $testAppDirectory), '{}'); - file_put_contents(sprintf('%s/public/build/shop/manifest.json', $testAppDirectory), '{}'); + $adminBuildDir = sprintf('%s/public/build/admin', $testAppDirectory); + $shopBuildDir = sprintf('%s/public/build/shop', $testAppDirectory); + + if (!file_exists($adminBuildDir)) { + mkdir($adminBuildDir, 0777, true); + file_put_contents(sprintf('%s/manifest.json', $adminBuildDir), '{}'); + } + + if (!file_exists($shopBuildDir)) { + mkdir($shopBuildDir, 0777, true); + file_put_contents(sprintf('%s/manifest.json', $shopBuildDir), '{}'); + } } private function startGroup(string $groupName): void From 5fed4db64e2959c89569972975160b5f20b26e3c Mon Sep 17 00:00:00 2001 From: Sylius Bot Date: Mon, 10 Apr 2023 02:20:12 +0000 Subject: [PATCH 3/6] [CS][DX] Refactor --- .../Bundle/ApiBundle/Controller/DeleteOrderItemAction.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Sylius/Bundle/ApiBundle/Controller/DeleteOrderItemAction.php b/src/Sylius/Bundle/ApiBundle/Controller/DeleteOrderItemAction.php index 6a9fcbbdd4..9a8b90ae74 100644 --- a/src/Sylius/Bundle/ApiBundle/Controller/DeleteOrderItemAction.php +++ b/src/Sylius/Bundle/ApiBundle/Controller/DeleteOrderItemAction.php @@ -26,8 +26,7 @@ final class DeleteOrderItemAction public function __construct( private MessageBusInterface $commandBus, private OrderItemRepositoryInterface $orderItemRepository, - ) - { + ) { } public function __invoke(Request $request): Response From de58169f5803bb72ff27dc82f08b8434c000e3b5 Mon Sep 17 00:00:00 2001 From: Jakub Tobiasz Date: Thu, 13 Apr 2023 08:03:21 +0200 Subject: [PATCH 4/6] Add conflict for doctrine/orm:2.14.2 --- CONFLICTS.md | 5 +++++ composer.json | 1 + 2 files changed, 6 insertions(+) diff --git a/CONFLICTS.md b/CONFLICTS.md index a7b3e3a679..98a241bdf7 100644 --- a/CONFLICTS.md +++ b/CONFLICTS.md @@ -50,3 +50,8 @@ references related issues. This version is missing the service alias `validator.expression` which causes ValidatorException exception to be thrown when using `Expression` constraint. + +- `doctrine/orm:2.14.2`: + + This version introduces not configurable XML validation causing errors when using XML mapping files and gedmo extensions. +- Reference: https://github.com/doctrine/DoctrineBundle/issues/1643 diff --git a/composer.json b/composer.json index ee06aeedcd..3a5642b419 100644 --- a/composer.json +++ b/composer.json @@ -181,6 +181,7 @@ "api-platform/core": "2.7.0", "doctrine/doctrine-bundle": "2.3.0", "doctrine/migrations": "3.5.3", + "doctrine/orm": "2.14.2", "jms/serializer-bundle": "4.1.0", "lexik/jwt-authentication-bundle": "^2.18", "symfony/framework-bundle": "5.4.5 || 6.2.8", From c19bb1d15bd411f566bfdd03393dcc5a6073f0f5 Mon Sep 17 00:00:00 2001 From: Mateusz Zalewski Date: Thu, 13 Apr 2023 16:52:43 +0200 Subject: [PATCH 5/6] Determine Order being processable on itself --- src/Sylius/Component/Core/spec/Model/OrderSpec.php | 11 +++++++++++ src/Sylius/Component/Order/Model/Order.php | 5 +++++ src/Sylius/Component/Order/Model/OrderInterface.php | 2 ++ 3 files changed, 18 insertions(+) diff --git a/src/Sylius/Component/Core/spec/Model/OrderSpec.php b/src/Sylius/Component/Core/spec/Model/OrderSpec.php index c70f05927f..f9f1685632 100644 --- a/src/Sylius/Component/Core/spec/Model/OrderSpec.php +++ b/src/Sylius/Component/Core/spec/Model/OrderSpec.php @@ -832,4 +832,15 @@ final class OrderSpec extends ObjectBehavior $this->getTaxIncludedTotal()->shouldReturn(1500); $this->getTaxExcludedTotal()->shouldReturn(800); } + + function it_can_be_processed(): void + { + $this->setState(OrderInterface::STATE_CART); + + $this->canBeProcessed()->shouldReturn(true); + + $this->setState(OrderInterface::STATE_NEW); + + $this->canBeProcessed()->shouldReturn(false); + } } diff --git a/src/Sylius/Component/Order/Model/Order.php b/src/Sylius/Component/Order/Model/Order.php index 48919dc3db..ca47857e43 100644 --- a/src/Sylius/Component/Order/Model/Order.php +++ b/src/Sylius/Component/Order/Model/Order.php @@ -315,6 +315,11 @@ class Order implements OrderInterface $this->recalculateTotal(); } + public function canBeProcessed(): bool + { + return $this->state === self::STATE_CART; + } + /** * Items total + Adjustments total. */ diff --git a/src/Sylius/Component/Order/Model/OrderInterface.php b/src/Sylius/Component/Order/Model/OrderInterface.php index d71ceff216..e47e85d4c7 100644 --- a/src/Sylius/Component/Order/Model/OrderInterface.php +++ b/src/Sylius/Component/Order/Model/OrderInterface.php @@ -84,4 +84,6 @@ interface OrderInterface extends AdjustableInterface, ResourceInterface, Timesta public function getAdjustmentsTotalRecursively(?string $type = null): int; public function removeAdjustmentsRecursively(?string $type = null): void; + + public function canBeProcessed(): bool; } From 15a38eafb7124d876e78b1a8dec3d14ec5094fcc Mon Sep 17 00:00:00 2001 From: Mateusz Zalewski Date: Thu, 13 Apr 2023 17:03:41 +0200 Subject: [PATCH 6/6] Do not hardcode checking cart state in processors --- .../OrderAdjustmentsClearer.php | 2 +- .../OrderPricesRecalculator.php | 2 +- .../OrderPromotionProcessor.php | 2 +- .../OrderProcessing/OrderShipmentProcessor.php | 2 +- .../OrderProcessing/OrderTaxesProcessor.php | 2 +- .../ShippingChargesProcessor.php | 2 +- .../OrderAdjustmentsClearerSpec.php | 15 ++++++--------- .../OrderPricesRecalculatorSpec.php | 6 +++--- .../OrderPromotionProcessorSpec.php | 6 +++--- .../OrderShipmentProcessorSpec.php | 18 +++++++++--------- .../OrderTaxesProcessorSpec.php | 12 ++++++------ .../ShippingChargesProcessorSpec.php | 8 ++++---- 12 files changed, 37 insertions(+), 40 deletions(-) diff --git a/src/Sylius/Component/Core/OrderProcessing/OrderAdjustmentsClearer.php b/src/Sylius/Component/Core/OrderProcessing/OrderAdjustmentsClearer.php index f542be63bb..8739e7a57e 100644 --- a/src/Sylius/Component/Core/OrderProcessing/OrderAdjustmentsClearer.php +++ b/src/Sylius/Component/Core/OrderProcessing/OrderAdjustmentsClearer.php @@ -43,7 +43,7 @@ final class OrderAdjustmentsClearer implements OrderProcessorInterface public function process(OrderInterface $order): void { - if (OrderInterface::STATE_CART !== $order->getState()) { + if (!$order->canBeProcessed()) { return; } diff --git a/src/Sylius/Component/Core/OrderProcessing/OrderPricesRecalculator.php b/src/Sylius/Component/Core/OrderProcessing/OrderPricesRecalculator.php index ae0db4fcfc..bef5f8cd60 100644 --- a/src/Sylius/Component/Core/OrderProcessing/OrderPricesRecalculator.php +++ b/src/Sylius/Component/Core/OrderProcessing/OrderPricesRecalculator.php @@ -37,7 +37,7 @@ final class OrderPricesRecalculator implements OrderProcessorInterface /** @var OrderInterface $order */ Assert::isInstanceOf($order, OrderInterface::class); - if (OrderInterface::STATE_CART !== $order->getState()) { + if (!$order->canBeProcessed()) { return; } diff --git a/src/Sylius/Component/Core/OrderProcessing/OrderPromotionProcessor.php b/src/Sylius/Component/Core/OrderProcessing/OrderPromotionProcessor.php index 0e35409f34..867acdeb89 100644 --- a/src/Sylius/Component/Core/OrderProcessing/OrderPromotionProcessor.php +++ b/src/Sylius/Component/Core/OrderProcessing/OrderPromotionProcessor.php @@ -30,7 +30,7 @@ final class OrderPromotionProcessor implements OrderProcessorInterface /** @var OrderInterface $order */ Assert::isInstanceOf($order, OrderInterface::class); - if (OrderInterface::STATE_CART !== $order->getState()) { + if (!$order->canBeProcessed()) { return; } diff --git a/src/Sylius/Component/Core/OrderProcessing/OrderShipmentProcessor.php b/src/Sylius/Component/Core/OrderProcessing/OrderShipmentProcessor.php index 47597da0ad..97cc3f0b78 100644 --- a/src/Sylius/Component/Core/OrderProcessing/OrderShipmentProcessor.php +++ b/src/Sylius/Component/Core/OrderProcessing/OrderShipmentProcessor.php @@ -43,7 +43,7 @@ final class OrderShipmentProcessor implements OrderProcessorInterface /** @var OrderInterface $order */ Assert::isInstanceOf($order, OrderInterface::class); - if (OrderInterface::STATE_CART !== $order->getState()) { + if (!$order->canBeProcessed()) { return; } diff --git a/src/Sylius/Component/Core/OrderProcessing/OrderTaxesProcessor.php b/src/Sylius/Component/Core/OrderProcessing/OrderTaxesProcessor.php index b16a69b6da..ecdf399a17 100644 --- a/src/Sylius/Component/Core/OrderProcessing/OrderTaxesProcessor.php +++ b/src/Sylius/Component/Core/OrderProcessing/OrderTaxesProcessor.php @@ -46,7 +46,7 @@ final class OrderTaxesProcessor implements OrderProcessorInterface /** @var OrderInterface $order */ Assert::isInstanceOf($order, OrderInterface::class); - if (OrderInterface::STATE_CART !== $order->getState()) { + if (!$order->canBeProcessed()) { return; } diff --git a/src/Sylius/Component/Core/OrderProcessing/ShippingChargesProcessor.php b/src/Sylius/Component/Core/OrderProcessing/ShippingChargesProcessor.php index a04f119b8d..f3b932d7a5 100644 --- a/src/Sylius/Component/Core/OrderProcessing/ShippingChargesProcessor.php +++ b/src/Sylius/Component/Core/OrderProcessing/ShippingChargesProcessor.php @@ -33,7 +33,7 @@ final class ShippingChargesProcessor implements OrderProcessorInterface /** @var OrderInterface $order */ Assert::isInstanceOf($order, OrderInterface::class); - if (OrderInterface::STATE_CART !== $order->getState()) { + if (!$order->canBeProcessed()) { return; } diff --git a/src/Sylius/Component/Core/spec/OrderProcessing/OrderAdjustmentsClearerSpec.php b/src/Sylius/Component/Core/spec/OrderProcessing/OrderAdjustmentsClearerSpec.php index 463de214bb..6ac59d4bc5 100644 --- a/src/Sylius/Component/Core/spec/OrderProcessing/OrderAdjustmentsClearerSpec.php +++ b/src/Sylius/Component/Core/spec/OrderProcessing/OrderAdjustmentsClearerSpec.php @@ -14,6 +14,7 @@ declare(strict_types=1); namespace spec\Sylius\Component\Core\OrderProcessing; use PhpSpec\ObjectBehavior; +use Prophecy\Argument; use Sylius\Component\Core\Model\AdjustmentInterface; use Sylius\Component\Core\Model\OrderInterface; use Sylius\Component\Order\Processor\OrderProcessorInterface; @@ -27,7 +28,7 @@ final class OrderAdjustmentsClearerSpec extends ObjectBehavior function it_removes_adjustments_with_default_types_from_order_recursively(OrderInterface $order): void { - $order->getState()->willReturn(OrderInterface::STATE_CART); + $order->canBeProcessed()->willReturn(true); $order->removeAdjustmentsRecursively(AdjustmentInterface::ORDER_ITEM_PROMOTION_ADJUSTMENT)->shouldBeCalled(); $order->removeAdjustmentsRecursively(AdjustmentInterface::ORDER_PROMOTION_ADJUSTMENT)->shouldBeCalled(); @@ -45,7 +46,7 @@ final class OrderAdjustmentsClearerSpec extends ObjectBehavior AdjustmentInterface::ORDER_PROMOTION_ADJUSTMENT, ]); - $order->getState()->willReturn(OrderInterface::STATE_CART); + $order->canBeProcessed()->willReturn(true); $order->removeAdjustmentsRecursively(AdjustmentInterface::ORDER_ITEM_PROMOTION_ADJUSTMENT)->shouldBeCalled(); $order->removeAdjustmentsRecursively(AdjustmentInterface::ORDER_PROMOTION_ADJUSTMENT)->shouldBeCalled(); @@ -53,15 +54,11 @@ final class OrderAdjustmentsClearerSpec extends ObjectBehavior $this->process($order); } - function it_does_nothing_if_the_order_is_in_a_state_different_than_cart(OrderInterface $order): void + function it_does_nothing_if_the_order_cannot_be_processed(OrderInterface $order): void { - $order->getState()->willReturn(OrderInterface::STATE_NEW); + $order->canBeProcessed()->willReturn(false); - $order->removeAdjustmentsRecursively(AdjustmentInterface::ORDER_ITEM_PROMOTION_ADJUSTMENT)->shouldNotBeCalled(); - $order->removeAdjustmentsRecursively(AdjustmentInterface::ORDER_PROMOTION_ADJUSTMENT)->shouldNotBeCalled(); - $order->removeAdjustmentsRecursively(AdjustmentInterface::ORDER_SHIPPING_PROMOTION_ADJUSTMENT)->shouldNotBeCalled(); - $order->removeAdjustmentsRecursively(AdjustmentInterface::ORDER_UNIT_PROMOTION_ADJUSTMENT)->shouldNotBeCalled(); - $order->removeAdjustmentsRecursively(AdjustmentInterface::TAX_ADJUSTMENT)->shouldNotBeCalled(); + $order->removeAdjustmentsRecursively(Argument::any())->shouldNotBeCalled(); $this->process($order); } diff --git a/src/Sylius/Component/Core/spec/OrderProcessing/OrderPricesRecalculatorSpec.php b/src/Sylius/Component/Core/spec/OrderProcessing/OrderPricesRecalculatorSpec.php index 3eb5c05f0a..3d2a4de746 100644 --- a/src/Sylius/Component/Core/spec/OrderProcessing/OrderPricesRecalculatorSpec.php +++ b/src/Sylius/Component/Core/spec/OrderProcessing/OrderPricesRecalculatorSpec.php @@ -46,7 +46,7 @@ final class OrderPricesRecalculatorSpec extends ObjectBehavior ProductVariantInterface $variant, ProductVariantPricesCalculatorInterface $productVariantPriceCalculator, ): void { - $order->getState()->willReturn(OrderInterface::STATE_CART); + $order->canBeProcessed()->willReturn(true); $order->getCustomer()->willReturn($customer); $order->getChannel()->willReturn(null); @@ -83,9 +83,9 @@ final class OrderPricesRecalculatorSpec extends ObjectBehavior ; } - function it_does_nothing_if_the_order_is_in_a_state_different_than_cart(OrderInterface $order): void + function it_does_nothing_if_the_order_cannot_be_processed(OrderInterface $order): void { - $order->getState()->willReturn(OrderInterface::STATE_NEW); + $order->canBeProcessed()->willReturn(false); $order->getChannel()->shouldNotBeCalled(); $order->getItems()->shouldNotBeCalled(); diff --git a/src/Sylius/Component/Core/spec/OrderProcessing/OrderPromotionProcessorSpec.php b/src/Sylius/Component/Core/spec/OrderProcessing/OrderPromotionProcessorSpec.php index 812e88b472..7cf71f6062 100644 --- a/src/Sylius/Component/Core/spec/OrderProcessing/OrderPromotionProcessorSpec.php +++ b/src/Sylius/Component/Core/spec/OrderProcessing/OrderPromotionProcessorSpec.php @@ -32,18 +32,18 @@ final class OrderPromotionProcessorSpec extends ObjectBehavior function it_processes_promotions(PromotionProcessorInterface $promotionProcessor, OrderInterface $order): void { - $order->getState()->willReturn(OrderInterface::STATE_CART); + $order->canBeProcessed()->willReturn(true); $promotionProcessor->process($order)->shouldBeCalled(); $this->process($order); } - function it_does_nothing_if_the_order_is_in_a_state_different_than_cart( + function it_does_nothing_if_the_order_cannot_be_processed( PromotionProcessorInterface $promotionProcessor, OrderInterface $order, ): void { - $order->getState()->willReturn(OrderInterface::STATE_NEW); + $order->canBeProcessed()->willReturn(false); $promotionProcessor->process($order)->shouldNotBeCalled(); diff --git a/src/Sylius/Component/Core/spec/OrderProcessing/OrderShipmentProcessorSpec.php b/src/Sylius/Component/Core/spec/OrderProcessing/OrderShipmentProcessorSpec.php index 30348d80ec..54f83ec1da 100644 --- a/src/Sylius/Component/Core/spec/OrderProcessing/OrderShipmentProcessorSpec.php +++ b/src/Sylius/Component/Core/spec/OrderProcessing/OrderShipmentProcessorSpec.php @@ -54,7 +54,7 @@ final class OrderShipmentProcessorSpec extends ObjectBehavior ShippingMethodInterface $defaultShippingMethod, OrderItemInterface $orderItem, ): void { - $order->getState()->willReturn(OrderInterface::STATE_CART); + $order->canBeProcessed()->willReturn(true); $defaultShippingMethodResolver->getDefaultShippingMethod($shipment)->willReturn($defaultShippingMethod); @@ -88,7 +88,7 @@ final class OrderShipmentProcessorSpec extends ObjectBehavior ShipmentInterface $shipment, OrderItemInterface $orderItem, ): void { - $order->getState()->willReturn(OrderInterface::STATE_CART); + $order->canBeProcessed()->willReturn(true); $defaultShippingMethodResolver->getDefaultShippingMethod($shipment)->willThrow(UnresolvedDefaultShippingMethodException::class); @@ -127,7 +127,7 @@ final class OrderShipmentProcessorSpec extends ObjectBehavior OrderItemInterface $orderItem, ProductVariantInterface $productVariant, ): void { - $order->getState()->willReturn(OrderInterface::STATE_CART); + $order->canBeProcessed()->willReturn(true); $defaultShippingMethodResolver->getDefaultShippingMethod($shipment)->willReturn($defaultShippingMethod); @@ -157,7 +157,7 @@ final class OrderShipmentProcessorSpec extends ObjectBehavior ProductVariantInterface $productVariant, ShippingMethodInterface $shippingMethod, ): void { - $order->getState()->willReturn(OrderInterface::STATE_CART); + $order->canBeProcessed()->willReturn(true); $shipments->first()->willReturn($shipment); @@ -197,7 +197,7 @@ final class OrderShipmentProcessorSpec extends ObjectBehavior ): void { $this->beConstructedWith($defaultShippingMethodResolver, $shipmentFactory); - $order->getState()->willReturn(OrderInterface::STATE_CART); + $order->canBeProcessed()->willReturn(true); $shipments->first()->willReturn($shipment); @@ -230,7 +230,7 @@ final class OrderShipmentProcessorSpec extends ObjectBehavior OrderItemUnitInterface $itemUnitWithoutShipment, ShippingMethodInterface $shippingMethod, ): void { - $order->getState()->willReturn(OrderInterface::STATE_CART); + $order->canBeProcessed()->willReturn(true); $shipments->first()->willReturn($shipment); @@ -268,7 +268,7 @@ final class OrderShipmentProcessorSpec extends ObjectBehavior ShippingMethodInterface $firstShippingMethod, ShippingMethodInterface $secondShippingMethod, ): void { - $order->getState()->willReturn(OrderInterface::STATE_CART); + $order->canBeProcessed()->willReturn(true); $shipments->first()->willReturn($shipment); @@ -298,9 +298,9 @@ final class OrderShipmentProcessorSpec extends ObjectBehavior $this->process($order); } - function it_does_nothing_if_the_order_is_in_a_state_different_than_cart(OrderInterface $order): void + function it_does_nothing_if_the_order_cannot_be_processed(OrderInterface $order): void { - $order->getState()->willReturn(OrderInterface::STATE_NEW); + $order->canBeProcessed()->willReturn(false); $order->isEmpty()->shouldNotBeCalled(); $order->getItems()->shouldNotBeCalled(); diff --git a/src/Sylius/Component/Core/spec/OrderProcessing/OrderTaxesProcessorSpec.php b/src/Sylius/Component/Core/spec/OrderProcessing/OrderTaxesProcessorSpec.php index 5f03711fd5..5f432a17cd 100644 --- a/src/Sylius/Component/Core/spec/OrderProcessing/OrderTaxesProcessorSpec.php +++ b/src/Sylius/Component/Core/spec/OrderProcessing/OrderTaxesProcessorSpec.php @@ -55,7 +55,7 @@ final class OrderTaxesProcessorSpec extends ObjectBehavior TaxCalculationStrategyInterface $strategyOne, TaxCalculationStrategyInterface $strategyTwo, ): void { - $order->getState()->willReturn(OrderInterface::STATE_CART); + $order->canBeProcessed()->willReturn(true); $order->getItems()->willReturn(new ArrayCollection([$orderItem->getWrappedObject()])); $order->getShipments()->willReturn(new ArrayCollection([$shipment->getWrappedObject()])); $order->isEmpty()->willReturn(false); @@ -86,7 +86,7 @@ final class OrderTaxesProcessorSpec extends ObjectBehavior ZoneInterface $zone, TaxCalculationStrategyInterface $strategy, ): void { - $order->getState()->willReturn(OrderInterface::STATE_CART); + $order->canBeProcessed()->willReturn(true); $order->getItems()->willReturn(new ArrayCollection([$orderItem->getWrappedObject()])); $order->getShipments()->willReturn(new ArrayCollection([])); $order->isEmpty()->willReturn(false); @@ -107,7 +107,7 @@ final class OrderTaxesProcessorSpec extends ObjectBehavior function it_does_not_process_taxes_if_there_is_no_order_item(OrderInterface $order): void { - $order->getState()->willReturn(OrderInterface::STATE_CART); + $order->canBeProcessed()->willReturn(true); $order->removeAdjustments(AdjustmentInterface::TAX_ADJUSTMENT)->shouldBeCalled(); $order->getItems()->willReturn(new ArrayCollection([])); $order->getShipments()->willReturn(new ArrayCollection([])); @@ -126,7 +126,7 @@ final class OrderTaxesProcessorSpec extends ObjectBehavior OrderItemInterface $orderItem, AddressInterface $address, ): void { - $order->getState()->willReturn(OrderInterface::STATE_CART); + $order->canBeProcessed()->willReturn(true); $order->getItems()->willReturn(new ArrayCollection([$orderItem->getWrappedObject()])); $order->getShipments()->willReturn(new ArrayCollection([])); $order->isEmpty()->willReturn(false); @@ -145,12 +145,12 @@ final class OrderTaxesProcessorSpec extends ObjectBehavior $this->process($order); } - function it_does_nothing_if_the_order_is_in_a_state_different_than_cart( + function it_does_nothing_if_the_order_cannot_be_processed( ZoneProviderInterface $defaultTaxZoneProvider, PrioritizedServiceRegistryInterface $strategyRegistry, OrderInterface $order, ): void { - $order->getState()->willReturn(OrderInterface::STATE_NEW); + $order->canBeProcessed()->willReturn(false); $order->getItems()->shouldNotBeCalled(); $order->getShipments()->shouldNotBeCalled(); diff --git a/src/Sylius/Component/Core/spec/OrderProcessing/ShippingChargesProcessorSpec.php b/src/Sylius/Component/Core/spec/OrderProcessing/ShippingChargesProcessorSpec.php index 00995e5780..49a0686f37 100644 --- a/src/Sylius/Component/Core/spec/OrderProcessing/ShippingChargesProcessorSpec.php +++ b/src/Sylius/Component/Core/spec/OrderProcessing/ShippingChargesProcessorSpec.php @@ -38,7 +38,7 @@ final class ShippingChargesProcessorSpec extends ObjectBehavior function it_removes_existing_shipping_adjustments(OrderInterface $order): void { - $order->getState()->willReturn(OrderInterface::STATE_CART); + $order->canBeProcessed()->willReturn(true); $order->getShipments()->willReturn(new ArrayCollection([])); @@ -47,7 +47,7 @@ final class ShippingChargesProcessorSpec extends ObjectBehavior function it_does_not_apply_any_shipping_charge_if_order_has_no_shipments(OrderInterface $order): void { - $order->getState()->willReturn(OrderInterface::STATE_CART); + $order->canBeProcessed()->willReturn(true); $order->getShipments()->willReturn(new ArrayCollection([])); $order->addAdjustment(Argument::any())->shouldNotBeCalled(); @@ -63,7 +63,7 @@ final class ShippingChargesProcessorSpec extends ObjectBehavior ShipmentInterface $shipment, ShippingMethodInterface $shippingMethod, ): void { - $order->getState()->willReturn(OrderInterface::STATE_CART); + $order->canBeProcessed()->willReturn(true); $adjustmentFactory->createNew()->willReturn($adjustment); $order->getShipments()->willReturn(new ArrayCollection([$shipment->getWrappedObject()])); @@ -93,7 +93,7 @@ final class ShippingChargesProcessorSpec extends ObjectBehavior function it_does_nothing_if_the_order_is_in_a_state_different_than_cart(OrderInterface $order): void { - $order->getState()->willReturn(OrderInterface::STATE_NEW); + $order->canBeProcessed()->willReturn(false); $order->getShipments()->shouldNotBeCalled(); $order->removeAdjustments(AdjustmentInterface::SHIPPING_ADJUSTMENT)->shouldNotBeCalled();