function it_adds_single_item_by_customer(FactoryInterface $orderItemFactory, OrderInterface $order, OrderItemInterface $item, OrderItemQuantityModifierInterface $itemQuantityModifier, ProductInterface $product, SharedStorageInterface $sharedStorage, ProductVariantInterface $variant, ObjectManager $objectManager)
 {
     $sharedStorage->get('order')->willReturn($order);
     $orderItemFactory->createNew()->willReturn($item);
     $product->getMasterVariant()->willReturn($variant);
     $product->getPrice()->willReturn(1234);
     $itemQuantityModifier->modify($item, 1)->shouldBeCalled();
     $item->setVariant($variant)->shouldBeCalled();
     $item->setUnitPrice(1234)->shouldBeCalled();
     $order->addItem($item)->shouldBeCalled();
     $objectManager->flush()->shouldBeCalled();
     $this->theCustomerBoughtSingle($product);
 }
Exemple #2
0
 /**
  * @Given the customer bought a single :product using :coupon coupon
  */
 public function theCustomerBoughtSingleUsing(ProductInterface $product, CouponInterface $coupon)
 {
     $order = $this->addProductVariantToOrder($product->getFirstVariant(), $product->getPrice());
     $order->setPromotionCoupon($coupon);
     $this->orderRecalculator->recalculate($order);
     $this->objectManager->flush();
 }
 /**
  * @Given the customer bought single :product
  */
 public function theCustomerBoughtSingle(ProductInterface $product)
 {
     /** @var OrderInterface $order */
     $order = $this->sharedStorage->get('order');
     /** @var OrderItemInterface $item */
     $item = $this->orderItemFactory->createNew();
     $item->setVariant($product->getMasterVariant());
     $item->setUnitPrice($product->getPrice());
     $this->itemQuantityModifier->modify($item, 1);
     $order->addItem($item);
     $this->objectManager->flush();
 }