Example #1
0
 /**
  * @Given /^(I) have already placed an order (\d+) times$/
  */
 public function iHaveAlreadyPlacedOrderNthTimes(UserInterface $user, $numberOfOrders)
 {
     $customer = $user->getCustomer();
     for ($i = 0; $i < $numberOfOrders; $i++) {
         $order = $this->createOrder($customer, '#00000' . $i);
         $order->setPaymentState(PaymentInterface::STATE_COMPLETED);
         $order->setCompletedAt(new \DateTime());
         $this->orderRepository->add($order);
     }
 }
Example #2
0
 /**
  * @Given the customer :customer placed an order :orderNumber
  */
 public function theCustomerPlacedAnOrder(CustomerInterface $customer, $orderNumber)
 {
     /** @var OrderInterface $order */
     $order = $this->orderFactory->createNew();
     $order->setCustomer($customer);
     $order->setNumber($orderNumber);
     $order->setChannel($this->sharedStorage->get('channel'));
     $order->setCurrency($this->sharedStorage->get('currency'));
     $this->sharedStorage->set('order', $order);
     $this->orderRepository->add($order);
 }
 function it_creates_customers_order(CustomerInterface $customer, ChannelInterface $channel, CurrencyInterface $currency, FactoryInterface $orderFactory, OrderInterface $order, OrderRepositoryInterface $orderRepository, SharedStorageInterface $sharedStorage)
 {
     $sharedStorage->get('channel')->willReturn($channel);
     $sharedStorage->get('currency')->willReturn($currency);
     $orderFactory->createNew()->willReturn($order);
     $order->setCustomer($customer)->shouldBeCalled();
     $order->setChannel($channel)->shouldBeCalled();
     $order->setCurrency($currency)->shouldBeCalled();
     $order->setNumber('#00000022')->shouldBeCalled();
     $orderRepository->add($order)->shouldBeCalled();
     $sharedStorage->set('order', $order)->shouldBeCalled();
     $this->theCustomerPlacedAnOrder($customer, '#00000022');
 }
Example #4
0
 /**
  * @Given :numberOfCustomers customers have placed :numberOfOrders orders for total of :total
  * @Given then :numberOfCustomers more customers have placed :numberOfOrders orders for total of :total
  */
 public function customersHavePlacedOrdersForTotalOf($numberOfCustomers, $numberOfOrders, $total)
 {
     $customers = $this->generateCustomers($numberOfCustomers);
     $sampleProductVariant = $this->sharedStorage->get('variant');
     $total = $this->getPriceFromString($total);
     for ($i = 0; $i < $numberOfOrders; $i++) {
         $order = $this->createOrder($customers[rand(0, $numberOfCustomers - 1)], '#' . uniqid());
         $order->setPaymentState(PaymentInterface::STATE_COMPLETED);
         $order->setCompletedAt(new \DateTime());
         $price = $i === $numberOfOrders - 1 ? $total : rand(1, $total);
         $total -= $price;
         $item = $this->orderItemFactory->createNew();
         $item->setVariant($sampleProductVariant);
         $item->setUnitPrice($price);
         $this->itemQuantityModifier->modify($item, 1);
         $order->addItem($item);
         $this->orderRepository->add($order);
     }
 }
Example #5
0
 /**
  * @Given :numberOfCustomers customers have placed :numberOfOrders orders for total of :total mostly :product product
  * @Given then :numberOfCustomers more customers have placed :numberOfOrders orders for total of :total mostly :product product
  */
 public function customersHavePlacedOrdersForTotalOfMostlyProduct($numberOfCustomers, $numberOfOrders, $total, ProductInterface $product)
 {
     $customers = $this->generateCustomers($numberOfCustomers);
     $sampleProductVariant = $product->getVariants()->first();
     $total = $this->getPriceFromString($total);
     for ($i = 0; $i < $numberOfOrders; $i++) {
         $order = $this->createOrder($customers[rand(0, $numberOfCustomers - 1)], '#' . uniqid(), $product->getChannels()->first());
         $order->setState(OrderInterface::STATE_NEW);
         $this->applyPaymentTransitionOnOrder($order, PaymentTransitions::TRANSITION_COMPLETE);
         $price = $i === $numberOfOrders - 1 ? $total : rand(1, $total);
         $total -= $price;
         $item = $this->orderItemFactory->createNew();
         $item->setVariant($sampleProductVariant);
         $item->setUnitPrice($price);
         $this->itemQuantityModifier->modify($item, 1);
         $order->addItem($item);
         $this->orderRepository->add($order);
     }
 }
Example #6
0
 /**
  * @Given :numberOfCustomers customers have placed :numberOfOrders orders for total of :total
  * @Given then :numberOfCustomers more customers have placed :numberOfOrders orders for total of :total
  */
 public function customersHavePlacedOrdersForTotalOf($numberOfCustomers, $numberOfOrders, $total)
 {
     $customers = $this->generateCustomers($numberOfCustomers);
     $sampleProductVariant = $this->sharedStorage->get('variant');
     $total = $this->getPriceFromString($total);
     for ($i = 0; $i < $numberOfOrders; $i++) {
         $order = $this->createOrder($customers[rand(0, $numberOfCustomers - 1)], '#' . uniqid());
         $order->setState(OrderInterface::STATE_NEW);
         // Temporary, we should use checkout to place these orders.
         $this->applyPaymentTransitionOnOrder($order, PaymentTransitions::TRANSITION_COMPLETE);
         $price = $i === $numberOfOrders - 1 ? $total : rand(1, $total);
         $total -= $price;
         $item = $this->orderItemFactory->createNew();
         $item->setVariant($sampleProductVariant);
         $item->setUnitPrice($price);
         $this->itemQuantityModifier->modify($item, 1);
         $order->addItem($item);
         $this->orderRepository->add($order);
     }
 }