diff --git a/tests/Behat/Context/Setup/OrderShipmentContext.php b/tests/Behat/Context/Setup/OrderShipmentContext.php
new file mode 100644
index 000000000..c9f1515c6
--- /dev/null
+++ b/tests/Behat/Context/Setup/OrderShipmentContext.php
@@ -0,0 +1,173 @@
+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 8193ddfc8..eb5b6a771 100644
--- a/tests/Behat/Resources/services.xml
+++ b/tests/Behat/Resources/services.xml
@@ -70,6 +70,19 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/Behat/Resources/suites.yml b/tests/Behat/Resources/suites.yml
index 570a11b9b..0b9452c1e 100644
--- a/tests/Behat/Resources/suites.yml
+++ b/tests/Behat/Resources/suites.yml
@@ -19,7 +19,6 @@ default:
- sylius.behat.context.transform.tax_category
- sylius.behat.context.transform.tax_rate
- sylius.behat.context.transform.zone
-
- Tests\Sylius\RefundPlugin\Behat\Context\Transform\OrderContext
- sylius.behat.context.setup.admin_security
@@ -33,21 +32,22 @@ default:
- sylius.behat.context.setup.shipping
- sylius.behat.context.setup.taxation
- 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
- sylius.behat.context.ui.admin.managing_orders
- Tests\Sylius\RefundPlugin\Behat\Context\Application\EmailsContext
- - Tests\Sylius\RefundPlugin\Behat\Context\Setup\ChannelContext
- Tests\Sylius\RefundPlugin\Behat\Context\Ui\CreditMemoContext
- Tests\Sylius\RefundPlugin\Behat\Context\Ui\ManagingOrdersContext
- Tests\Sylius\RefundPlugin\Behat\Context\Ui\RefundingContext
filters:
tags: "@refunds && @ui"
+
application_refunds:
contexts:
- sylius.behat.context.hook.doctrine_orm
@@ -77,18 +77,16 @@ default:
- sylius.behat.context.setup.shipping
- sylius.behat.context.setup.taxation
- sylius.behat.context.setup.zone
-
- - sylius.behat.context.transform.payment
-
+ - Tests\Sylius\RefundPlugin\Behat\Context\Setup\ChannelContext
- Tests\Sylius\RefundPlugin\Behat\Context\Setup\RefundingContext
- Tests\Sylius\RefundPlugin\Behat\Context\Application\CreditMemoContext
- Tests\Sylius\RefundPlugin\Behat\Context\Application\EmailsContext
- Tests\Sylius\RefundPlugin\Behat\Context\Application\RefundingContext
- - Tests\Sylius\RefundPlugin\Behat\Context\Setup\ChannelContext
filters:
tags: "@refunds && @application"
+
customer_credit_memos:
contexts:
- sylius.behat.context.hook.doctrine_orm
@@ -114,14 +112,12 @@ default:
- sylius.behat.context.setup.shipping
- sylius.behat.context.setup.shop_security
- sylius.behat.context.setup.user
+ - Tests\Sylius\RefundPlugin\Behat\Context\Setup\ChannelContext
+ - Tests\Sylius\RefundPlugin\Behat\Context\Setup\RefundingContext
- sylius.behat.context.ui.shop.account
- - sylius.behat.context.transform.payment
-
- Tests\Sylius\RefundPlugin\Behat\Context\Application\EmailsContext
- - Tests\Sylius\RefundPlugin\Behat\Context\Setup\ChannelContext
- - Tests\Sylius\RefundPlugin\Behat\Context\Setup\RefundingContext
- Tests\Sylius\RefundPlugin\Behat\Context\Ui\Shop\Customer\CreditMemoContext
filters: