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);
 }
Exemple #2
0
 /**
  * {@inheritdoc}
  */
 public function createShipment(OrderInterface $order)
 {
     $shipment = $order->getShipments()->first();
     if (!$shipment) {
         $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->getInventoryUnits() as $inventoryUnit) {
         if (null === $inventoryUnit->getShipment()) {
             $shipment->addItem($inventoryUnit);
         }
     }
 }
Exemple #4
0
 protected function createShipment(OrderInterface $order)
 {
     /* @var $shipment ShipmentInterface */
     $shipment = $this->getShipmentRepository()->createNew();
     $shipment->setMethod($this->getReference('Sylius.ShippingMethod.UPS Ground'));
     $shipment->setState($this->getShipmentState());
     foreach ($order->getInventoryUnits() as $item) {
         $shipment->addItem($item);
     }
     $order->addShipment($shipment);
 }