Exemplo n.º 1
0
 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);
 }
Exemplo n.º 2
0
 /**
  * {@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);
         }
     }
 }
Exemplo n.º 3
0
 protected function createShipment(OrderInterface $order)
 {
     /* @var $shipment ShipmentInterface */
     $shipment = $this->getShipmentFactory()->createNew();
     $shipment->setMethod($this->getReference('Sylius.ShippingMethod.UPS Ground'));
     $shipment->setState($this->getShipmentState());
     foreach ($order->getItemUnits() as $item) {
         $shipment->addItem($item);
     }
     $order->addShipment($shipment);
 }
Exemplo n.º 4
0
 protected function createShipment(OrderInterface $order)
 {
     /* @var $shipment ShipmentInterface */
     $shipment = $this->getShipmentFactory()->createNew();
     $shipment->setMethod($this->getReference('Sylius.ShippingMethod.ups_ground'));
     $shipment->setState($this->faker->boolean(50) ? ShipmentInterface::STATE_READY : ShipmentInterface::STATE_SHIPPED);
     foreach ($order->getItemUnits() as $item) {
         $shipment->addUnit($item);
     }
     $order->addShipment($shipment);
 }