public function testHandle()
 {
     $orderService = $this->mockService->getOrderService();
     $orderService->shouldReceive('buyShipmentLabel')->once();
     $orderItem = $this->dummyData->getOrderItem();
     $order = $this->dummyData->getOrder(null, [$orderItem]);
     $orderItemQtyDTO = new OrderItemQtyDTO();
     $orderItemQtyDTO->addOrderItemQty($orderItem->getId(), 2);
     $command = new BuyShipmentLabelCommand($order->getId()->getHex(), $orderItemQtyDTO, 'A comment', 'shp_xxxxxxx', 'rate_xxxxxxx');
     $handler = new BuyShipmentLabelHandler($orderService);
     $handler->handle($command);
 }
 public function testHandle()
 {
     $carrier = $this->dummyData->getShipmentCarrierType();
     $orderService = $this->mockService->getOrderService();
     $orderService->shouldReceive('addShipmentTrackingCode')->once();
     $orderItem = $this->dummyData->getOrderItem();
     $order = $this->dummyData->getOrder(null, [$orderItem]);
     $orderItemQtyDTO = new OrderItemQtyDTO();
     $orderItemQtyDTO->addOrderItemQty($orderItem->getId(), 2);
     $command = new AddShipmentTrackingCodeCommand($order->getId()->getHex(), $orderItemQtyDTO, 'A comment', $carrier->getId(), 'xxxxxx');
     $handler = new AddShipmentTrackingCodeHandler($orderService);
     $handler->handle($command);
 }
 /**
  * @param $orderItemQty
  * @return OrderItemQtyDTO
  */
 private function getOrderItemQtyDTO($orderItemQty)
 {
     $orderItemQtyDTO = new OrderItemQtyDTO();
     foreach ($orderItemQty as $orderItemId => $qty) {
         $orderItemQtyDTO->addOrderItemQty(Uuid::fromString($orderItemId), $qty);
     }
     return $orderItemQtyDTO;
 }
Ejemplo n.º 4
0
 public function testOrderMarkedAsShippedWhen2PartialShipmentsAreFullyShipped()
 {
     $order1 = $this->getPersistedOrderWith2Items();
     $orderItem1 = $order1->getOrderItems()[0];
     $orderItem2 = $order1->getOrderItems()[1];
     $carrierType = $this->dummyData->getShipmentCarrierType();
     $orderItemQtyDTO = new OrderItemQtyDTO();
     $orderItemQtyDTO->addOrderItemQty($orderItem1->getId(), 1);
     $this->orderService->addShipmentTrackingCode($order1->getId(), $orderItemQtyDTO, '1 of 2 items shipped', $carrierType->getId(), 'XXXX');
     $this->assertSame(1, count($order1->getShipments()));
     $this->assertTrue($order1->getStatus()->isPartiallyShipped());
     $orderItemQtyDTO = new OrderItemQtyDTO();
     $orderItemQtyDTO->addOrderItemQty($orderItem2->getId(), 1);
     $this->orderService->addShipmentTrackingCode($order1->getId(), $orderItemQtyDTO, '2 of 2 items shipped. This completes your order', $carrierType->getId(), 'XXXX');
     $this->assertSame(2, count($order1->getShipments()));
     $this->assertTrue($order1->getStatus()->isShipped());
 }