예제 #1
0
 /**
  * @param CartInterface $cart
  * @param CartItemInterface $item
  */
 private function resolveCartItem(CartInterface $cart, CartItemInterface $item)
 {
     foreach ($cart->getItems() as $existingItem) {
         if ($item->equals($existingItem)) {
             $this->orderItemQuantityModifier->modify($existingItem, $existingItem->getQuantity() + $item->getQuantity());
             return;
         }
     }
     $cart->addItem($item);
 }
예제 #2
0
 public function setCart(CartInterface $cart)
 {
     $user = $this->getUser();
     if ($cart !== $this->getCart()) {
         $this->abandonCart();
     }
     if ($cart instanceof OrderInterface && $user instanceof UserInterface) {
         $cart->setUser($user);
         $cart->setExpiresAt(null);
     }
 }
예제 #3
0
 function it_sets_cart_identifier_via_session($session, CartInterface $cart)
 {
     $cart->getIdentifier()->will(function () {
         return 3;
     });
     $session->set(SessionCartStorage::KEY, 3)->will(function () use($session) {
         $session->get(SessionCartStorage::KEY)->willReturn(3);
     });
     $this->setCurrentCartIdentifier($cart);
     $this->getCurrentCartIdentifier()->shouldReturn(3);
 }
예제 #4
0
 function it_throw_exception_if_subject_is_not_a_cart(GenericEvent $event, CartInterface $cart)
 {
     $event->getSubject()->shouldBeCalled()->willReturn(null);
     $cart->calculateTotal()->shouldNotBeCalled();
     $this->shouldThrow('\\InvalidArgumentException')->during('refreshCart', array($event));
 }
예제 #5
0
 /**
  * {@inheritdoc}
  */
 public function setCurrentCartIdentifier(CartInterface $cart)
 {
     $this->session->set($this->key, $cart->getIdentifier());
 }
예제 #6
0
 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);
 }
예제 #7
0
 /**
  * {@inheritdoc}
  */
 public function setCurrentCartIdentifier(CartInterface $cart)
 {
     $this->storage->setData(self::STORAGE_KEY, $cart->getIdentifier());
 }