/** * {@inheritdoc} */ public function process(OrderInterface $order) { if (OrderInterface::STATE_CANCELLED === $order->getState()) { return; } $this->exchangeRateUpdater->update($order); }
/** * {@inheritdoc} */ public function process(OrderInterface $order) { /** @var CoreOrderInterface $order */ Assert::isInstanceOf($order, CoreOrderInterface::class); if (OrderInterface::STATE_CANCELLED === $order->getState()) { return; } $this->exchangeRateUpdater->update($order); }
function it_handles_cart_currency_code_change(CartContextInterface $cartContext, OrderUpdaterInterface $orderUpdater, EventDispatcherInterface $eventDispatcher, EntityManagerInterface $orderManager, OrderInterface $cart) { $cartContext->getCart()->willReturn($cart); $cart->setCurrencyCode('USD')->shouldBeCalled(); $orderUpdater->update($cart)->shouldBeCalled(); $orderManager->persist($cart)->shouldBeCalled(); $orderManager->flush()->shouldBeCalled(); $eventDispatcher->dispatch(SyliusCartEvents::CART_CHANGE, Argument::type(GenericEvent::class))->shouldBeCalled(); $this->handle('USD'); }
/** * {@inheritdoc} */ public function handle($code) { try { /** @var OrderInterface $cart */ $cart = $this->cartContext->getCart(); $cart->setCurrencyCode($code); $this->exchangeRateUpdater->update($cart); $this->orderManager->persist($cart); $this->orderManager->flush(); $this->eventDispatcher->dispatch(SyliusCartEvents::CART_CHANGE, new CartEvent($cart)); } catch (CartNotFoundException $exception) { throw new HandleException(self::class, 'Sylius was unable to find the cart.', $exception); } }
function it_processes_the_order(OrderUpdaterInterface $orderUpdater, OrderInterface $order) { $order->getState()->willReturn(Argument::not(OrderInterface::STATE_CANCELLED)); $orderUpdater->update($order)->shouldBeCalled(); $this->process($order); }