function it_adds_new_inventory_units_to_existing_shipment(OrderInterface $order, ShipmentInterface $shipment, ArrayCollection $shipments, InventoryUnitInterface $inventoryUnit, InventoryUnitInterface $inventoryUnitWithoutShipment) { $shipments->first()->willReturn($shipment)->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); }
function it_creates_only_missing_inventory_units_via_the_factory(InventoryUnitFactoryInterface $inventoryUnitFactory, OrderItemInterface $item, ProductVariantInterface $variant, InventoryUnitInterface $unit1, InventoryUnitInterface $unit2) { $item->getInventoryUnits()->shouldBeCalled()->willReturn(new ArrayCollection(array($unit1))); $unit1->getStockable()->willReturn($variant); $unit2->getStockable()->willReturn($variant); $item->getVariant()->willReturn($variant); $item->getQuantity()->willReturn(2); $inventoryUnitFactory->createForStockable($variant, 1, InventoryUnitInterface::STATE_CHECKOUT)->willReturn(array($unit2)); $item->addInventoryUnit($unit1)->shouldNotBeCalled(); $item->addInventoryUnit($unit2)->shouldBeCalled(); $this->processInventoryUnits($item); }
function it_not_a_backorder_if_contains_no_backordered_units(InventoryUnitInterface $unit1, InventoryUnitInterface $unit2, OrderItemInterface $item) { $unit1->getInventoryState()->willReturn(InventoryUnitInterface::STATE_SOLD); $unit2->getInventoryState()->willReturn(InventoryUnitInterface::STATE_SOLD); $item->getInventoryUnits()->willReturn(array($unit1, $unit2)); $item->setOrder($this)->shouldBeCalled(); $this->addItem($item); $this->shouldNotBeBackorder(); }
/** * {@inheritdoc} */ public function removeInventoryUnit(InventoryUnitInterface $unit) { $unit->setOrderItem(null); $this->inventoryUnits->removeElement($unit); return $this; }