/**
  * @param GenericEvent $event
  *
  * @throws UnexpectedTypeException
  */
 public function recalculateOrder(GenericEvent $event)
 {
     $order = $event->getSubject();
     if (!$order instanceof OrderInterface) {
         throw new UnexpectedTypeException($order, OrderInterface::class);
     }
     $this->orderProcessor->process($order);
 }
 /**
  * @param Event $event
  *
  * @throws UnexpectedTypeException
  */
 public function recalculateCartWhileLogin(Event $event)
 {
     try {
         $cart = $this->cartContext->getCart();
     } catch (CartNotFoundException $exception) {
         return;
     }
     if (!$cart instanceof OrderInterface) {
         throw new UnexpectedTypeException($cart, OrderInterface::class);
     }
     $this->orderProcessor->process($cart);
 }
Beispiel #3
0
 /**
  * @Given /^the customer chose ("[^"]+" shipping method) with ("[^"]+" payment)$/
  * @Given /^I chose ("[^"]+" shipping method) with ("[^"]+" payment)$/
  */
 public function theCustomerChoseShippingWithPayment(ShippingMethodInterface $shippingMethod, PaymentMethodInterface $paymentMethod)
 {
     /** @var OrderInterface $order */
     $order = $this->sharedStorage->get('order');
     $this->orderProcessor->process($order);
     $order->getShipments()->first()->setMethod($shippingMethod);
     $this->applyTransitionOnOrderCheckout($order, OrderCheckoutTransitions::TRANSITION_SELECT_SHIPPING);
     $payment = $order->getLastPayment();
     $payment->setMethod($paymentMethod);
     $this->applyTransitionOnOrderCheckout($order, OrderCheckoutTransitions::TRANSITION_SELECT_PAYMENT);
     $this->applyTransitionOnOrderCheckout($order, OrderCheckoutTransitions::TRANSITION_COMPLETE);
     $this->objectManager->flush();
 }
 function it_uses_order_processor_to_recalculate_order(OrderProcessorInterface $orderProcessor, GenericEvent $event, OrderInterface $order)
 {
     $event->getSubject()->willReturn($order);
     $orderProcessor->process($order)->shouldBeCalled();
     $this->recalculateOrder($event);
 }
Beispiel #5
0
 function it_removes_an_order_item_from_an_order(OrderInterface $order, OrderItemInterface $orderItem, OrderProcessorInterface $orderProcessor)
 {
     $order->removeItem($orderItem)->shouldBeCalled();
     $orderProcessor->process($order)->shouldBeCalled();
     $this->removeFromOrder($order, $orderItem);
 }
 function it_does_nothing_if_cannot_find_cart(CartContextInterface $cartContext, OrderProcessorInterface $orderProcessor, Event $event)
 {
     $cartContext->getCart()->willThrow(CartNotFoundException::class);
     $orderProcessor->process(Argument::any())->shouldNotBeCalled();
     $this->recalculateCartWhileLogin($event);
 }
Beispiel #7
0
 /**
  * @param CartInterface $cart
  * @param CartItemInterface $item
  */
 public function removeFromCart(CartInterface $cart, CartItemInterface $item)
 {
     $cart->removeItem($item);
     $this->orderProcessor->process($cart);
 }
 function it_removes_cart_item_from_cart(OrderProcessorInterface $orderProcessor, CartInterface $cart, CartItemInterface $cartItem)
 {
     $cart->removeItem($cartItem)->shouldBeCalled();
     $orderProcessor->process($cart)->shouldBeCalled();
     $this->removeFromCart($cart, $cartItem);
 }
Beispiel #9
0
 /**
  * @param OrderInterface $order
  * @param OrderItemInterface $item
  */
 public function removeFromOrder(OrderInterface $order, OrderItemInterface $item)
 {
     $order->removeItem($item);
     $this->orderProcessor->process($order);
 }