public function processOrderCurrency(CartEvent $event)
 {
     $order = $event->getCart();
     if (!$order instanceof OrderInterface) {
         throw new UnexpectedTypeException($order, 'Sylius\\Component\\Core\\Model\\OrderInterface');
     }
     $order->setCurrency($this->currencyContext->getCurrency());
 }
Exemple #2
0
 function it_should_not_save_an_invalid_cart($manager, $provider, $validator, CartEvent $event, CartInterface $cart, ConstraintViolationListInterface $constraintList)
 {
     $constraintList->count()->willReturn(1);
     $event->getCart()->willReturn($cart);
     $validator->validate($cart)->shouldBeCalled()->willReturn($constraintList);
     $manager->persist($cart)->shouldNotBeCalled();
     $manager->flush()->shouldNotBeCalled();
     $provider->setCart($cart)->shouldNotBeCalled();
     $this->saveCart($event);
 }
Exemple #3
0
 public function saveCart(CartEvent $event)
 {
     $cart = $event->getCart();
     $errors = $this->validator->validate($cart);
     $valid = 0 === count($errors);
     if ($valid) {
         $this->cartManager->persist($cart);
         $this->cartManager->flush();
         $this->cartProvider->setCart($cart);
     }
 }
 function it_sets_currency_on_order($currencyContext, CartEvent $event, OrderInterface $order)
 {
     $event->getCart()->willReturn($order);
     $currencyContext->getCurrency()->shouldBeCalled()->willReturn('PLN');
     $this->processOrderCurrency($event);
 }