function it_adds_new_item_units_to_existing_shipment(OrderInterface $order, ShipmentInterface $shipment, ArrayCollection $shipments, OrderItemUnitInterface $itemUnit, OrderItemUnitInterface $itemUnitWithoutShipment) { $shipments->first()->willReturn($shipment)->shouldBeCalled(); $order->hasShipments()->willReturn(true)->shouldBeCalled(); $itemUnit->getShipment()->willReturn($shipment); $order->getItemUnits()->willReturn([$itemUnit, $itemUnitWithoutShipment]); $order->getShipments()->willReturn($shipments)->shouldBeCalled(); $shipment->addUnit($itemUnitWithoutShipment)->shouldBeCalled(); $shipment->addUnit($itemUnit)->shouldNotBeCalled(); $this->createForOrder($order); }
function it_adds_new_inventory_units_to_existing_shipment(OrderInterface $order, ShipmentInterface $shipment, ArrayCollection $shipments, InventoryUnitInterface $inventoryUnit, InventoryUnitInterface $inventoryUnitWithoutShipment) { $shipments->first()->willReturn($shipment)->shouldBeCalled(); $order->hasShipments()->willReturn(true)->shouldBeCalled(); $inventoryUnit->getShipment()->willReturn($shipment); $order->getInventoryUnits()->willReturn(array($inventoryUnit, $inventoryUnitWithoutShipment)); $order->getShipments()->willReturn($shipments)->shouldBeCalled(); $shipment->addItem($inventoryUnitWithoutShipment)->shouldBeCalled(); $shipment->addItem($inventoryUnit)->shouldNotBeCalled(); $this->createShipment($order); }
/** * @param OrderInterface $order * * @return ShipmentInterface */ private function getOrderShipment(OrderInterface $order) { if ($order->hasShipments()) { return $order->getShipments()->first(); } /** @var ShipmentInterface $shipment */ $shipment = $this->shipmentFactory->createNew(); $order->addShipment($shipment); $shipment->setMethod($this->defaultShippingMethodResolver->getDefaultShippingMethod($shipment)); return $shipment; }
/** * {@inheritdoc} */ public function createShipment(OrderInterface $order) { if ($order->hasShipments()) { $shipment = $order->getShipments()->first(); } else { $shipment = $this->shipmentRepository->createNew(); $order->addShipment($shipment); } foreach ($order->getInventoryUnits() as $inventoryUnit) { if (null === $inventoryUnit->getShipment()) { $shipment->addItem($inventoryUnit); } } }
/** * {@inheritdoc} */ public function createForOrder(OrderInterface $order) { if ($order->hasShipments()) { $shipment = $order->getShipments()->first(); } else { $shipment = $this->shipmentFactory->createNew(); $order->addShipment($shipment); } foreach ($order->getItemUnits() as $itemUnit) { if (null === $itemUnit->getShipment()) { $shipment->addUnit($itemUnit); } } }