コード例 #1
0
 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);
 }
コード例 #2
0
ファイル: ProductContext.php プロジェクト: ahmadrabie/Sylius
 /**
  * @Given /^([^"]+) belongs to ("[^"]+" tax category)$/
  */
 public function productBelongsToTaxCategory(ProductInterface $product, TaxCategoryInterface $taxCategory)
 {
     $product->getMasterVariant()->setTaxCategory($taxCategory);
     $this->objectManager->flush();
 }
コード例 #3
0
 /**
  * @param ProductInterface $product
  * @param array            $data
  */
 private function configureProductPricingCalculator(ProductInterface $product, array $data)
 {
     $product->getMasterVariant()->setPricingCalculator($data['pricing calculator']);
     if (!isset($data['calculator configuration']) || '' === $data['calculator configuration']) {
         throw new \InvalidArgumentException('You must set chosen calculator configuration');
     }
     $product->getMasterVariant()->setPricingConfiguration($this->getPricingCalculatorConfiguration($data));
 }
コード例 #4
0
ファイル: LoadProductsData.php プロジェクト: vikey89/Sylius
 /**
  * Adds master variant to product.
  *
  * @param ProductInterface $product
  * @param string           $sku
  */
 protected function addMasterVariant(ProductInterface $product, $sku = null)
 {
     $variant = $product->getMasterVariant();
     $variant->setProduct($product);
     $variant->setPrice($this->faker->randomNumber(4));
     $variant->setSku(null === $sku ? $this->getUniqueSku() : $sku);
     $variant->setAvailableOn($this->faker->dateTimeThisYear);
     $variant->setOnHand($this->faker->randomNumber(1));
     $variant->setTaxCategory($this->getTaxCategory('Taxable goods'));
     $productName = explode(' ', $product->getName());
     $image = clone $this->getReference('Sylius.Image.' . strtolower($productName[0]));
     $variant->addImage($image);
     $this->setReference('Sylius.Variant-' . $this->totalVariants, $variant);
     ++$this->totalVariants;
     $product->setMasterVariant($variant);
 }
コード例 #5
0
 /**
  * @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();
 }
コード例 #6
0
ファイル: OrderContext.php プロジェクト: ahmadrabie/Sylius
 /**
  * @Then the order item with product :product should not exist
  */
 public function orderItemShouldNotExistInTheRegistry(ProductInterface $product)
 {
     $orderItems = $this->orderItemRepository->findBy(['variant' => $product->getMasterVariant()]);
     expect($orderItems)->toBe([]);
 }
コード例 #7
0
ファイル: OrderContext.php プロジェクト: rpg600/Sylius
 /**
  * @Given the customer bought single :product using :coupon coupon
  */
 public function theCustomerBoughtSingleUsing(ProductInterface $product, CouponInterface $coupon)
 {
     $order = $this->addSingleProductVariantToOrder($product->getMasterVariant(), $product->getPrice());
     $order->setPromotionCoupon($coupon);
     $this->orderRecalculator->recalculate($order);
     $this->objectManager->flush();
 }
コード例 #8
0
 function it_throws_an_exception_if_order_item_still_exist(RepositoryInterface $orderItemRepository, ProductInterface $product, ProductVariantInterface $productVariant, OrderItemInterface $orderItem)
 {
     $product->getMasterVariant()->willReturn($productVariant);
     $orderItemRepository->findBy(['variant' => $productVariant])->willReturn([$orderItem]);
     $this->shouldThrow(NotEqualException::class)->during('orderItemShouldNotExistInTheRegistry', [$product]);
 }