From ea68f3ee902e23ce2fe992d7f827c62965875261 Mon Sep 17 00:00:00 2001 From: Grzegorz Sadowski Date: Mon, 18 Nov 2024 15:13:58 +0100 Subject: [PATCH] [Behat] Remove unneeded context --- .../Context/Setup/OrderShipmentContext.php | 163 ------------------ tests/Behat/Resources/services.xml | 13 -- .../Resources/suites/application/refunds.yaml | 1 - tests/Behat/Resources/suites/ui/refunds.yaml | 1 - 4 files changed, 178 deletions(-) delete mode 100644 tests/Behat/Context/Setup/OrderShipmentContext.php diff --git a/tests/Behat/Context/Setup/OrderShipmentContext.php b/tests/Behat/Context/Setup/OrderShipmentContext.php deleted file mode 100644 index c4ead078..00000000 --- a/tests/Behat/Context/Setup/OrderShipmentContext.php +++ /dev/null @@ -1,163 +0,0 @@ -sharedStorage = $sharedStorage; - $this->orderItemFactory = $orderItemFactory; - $this->shipmentFactory = $shipmentFactory; - $this->stateMachineFactory = $stateMachineFactory; - $this->orderRepository = $orderRepository; - $this->paymentMethodRepository = $paymentMethodRepository; - $this->shippingMethodRepository = $shippingMethodRepository; - $this->variantResolver = $variantResolver; - $this->itemQuantityModifier = $itemQuantityModifier; - $this->objectManager = $objectManager; - } - - /** - * @Given the customer bought another :product with separate :shippingMethod shipment - */ - public function theCustomerBoughtAnotherProductWithSeparateShipment( - ProductInterface $product, - ShippingMethodInterface $shippingMethod - ): void { - $this->addProductVariantToOrder($this->variantResolver->getVariant($product), 1); - - /** @var OrderInterface $order */ - $order = $this->sharedStorage->get('order'); - - /** @var ShipmentInterface $shipment */ - $shipment = $this->shipmentFactory->createNew(); - $shipment->setMethod($shippingMethod); - $shipment->setOrder($order); - $order->addShipment($shipment); - - $this->objectManager->flush(); - } - - /** - * @Given /^the customer chose ("[^"]+" shipping method) (to "[^"]+")$/ - */ - public function theCustomerChoseShippingTo(ShippingMethodInterface $shippingMethod, AddressInterface $address): void - { - /** @var OrderInterface $order */ - $order = $this->sharedStorage->get('order'); - - $order->setShippingAddress($address); - $order->setBillingAddress(clone $address); - - $this->applyTransitionOnOrderCheckout($order, OrderCheckoutTransitions::TRANSITION_ADDRESS); - - foreach ($order->getShipments() as $shipment) { - $shipment->setMethod($shippingMethod); - } - $this->applyTransitionOnOrderCheckout($order, OrderCheckoutTransitions::TRANSITION_SELECT_SHIPPING); - - $this->objectManager->flush(); - } - - private function addProductVariantToOrder( - ProductVariantInterface $productVariant, - int $quantity = 1, - ?ChannelInterface $channel = null - ): OrderInterface { - $order = $this->sharedStorage->get('order'); - - $this->addProductVariantsToOrderWithChannelPrice( - $order, - $channel ?? $this->sharedStorage->get('channel'), - $productVariant, - (int) $quantity - ); - - return $order; - } - - private function addProductVariantsToOrderWithChannelPrice( - OrderInterface $order, - ChannelInterface $channel, - ProductVariantInterface $productVariant, - int $quantity = 1 - ) { - /** @var OrderItemInterface $item */ - $item = $this->orderItemFactory->createNew(); - $item->setVariant($productVariant); - - /** @var ChannelPricingInterface $channelPricing */ - $channelPricing = $productVariant->getChannelPricingForChannel($channel); - $item->setUnitPrice($channelPricing->getPrice()); - - $this->itemQuantityModifier->modify($item, $quantity); - - $order->addItem($item); - } - - private function applyTransitionOnOrderCheckout(OrderInterface $order, string $transition): void - { - $this->stateMachineFactory->get($order, OrderCheckoutTransitions::GRAPH)->apply($transition); - } - } -} else { - final class OrderShipmentContext implements Context - { - } -} diff --git a/tests/Behat/Resources/services.xml b/tests/Behat/Resources/services.xml index 6be8f913..6b8c5189 100644 --- a/tests/Behat/Resources/services.xml +++ b/tests/Behat/Resources/services.xml @@ -77,19 +77,6 @@ - - - - - - - - - - - - - diff --git a/tests/Behat/Resources/suites/application/refunds.yaml b/tests/Behat/Resources/suites/application/refunds.yaml index 3d8df949..8c9917e9 100644 --- a/tests/Behat/Resources/suites/application/refunds.yaml +++ b/tests/Behat/Resources/suites/application/refunds.yaml @@ -31,7 +31,6 @@ default: - sylius.behat.context.setup.taxation - sylius.behat.context.setup.zone - Tests\Sylius\RefundPlugin\Behat\Context\Setup\ChannelContext - - Tests\Sylius\RefundPlugin\Behat\Context\Setup\OrderShipmentContext - Tests\Sylius\RefundPlugin\Behat\Context\Setup\RefundingContext - Tests\Sylius\RefundPlugin\Behat\Context\Application\CreditMemoContext diff --git a/tests/Behat/Resources/suites/ui/refunds.yaml b/tests/Behat/Resources/suites/ui/refunds.yaml index 028cecd8..fdc8c282 100644 --- a/tests/Behat/Resources/suites/ui/refunds.yaml +++ b/tests/Behat/Resources/suites/ui/refunds.yaml @@ -35,7 +35,6 @@ default: - sylius.behat.context.setup.zone - Tests\Sylius\RefundPlugin\Behat\Context\Setup\ChannelContext - Tests\Sylius\RefundPlugin\Behat\Context\Setup\OrderContext - - Tests\Sylius\RefundPlugin\Behat\Context\Setup\OrderShipmentContext - Tests\Sylius\RefundPlugin\Behat\Context\Setup\ProductContext - Tests\Sylius\RefundPlugin\Behat\Context\Setup\RefundingContext