function it_executes_request(InvoiceNumberGeneratorInterface $invoiceNumberGenerator, CurrencyConverterInterface $currencyConverter, Convert $request, PaymentInterface $payment, OrderInterface $order, OrderItemInterface $orderItem, ProductVariantInterface $productVariant, ProductInterface $product) { $request->getTo()->willReturn('array'); $payment->getId()->willReturn(19); $order->getId()->willReturn(92); $order->getId()->willReturn(92); $order->getCurrencyCode()->willReturn('PLN'); $order->getTotal()->willReturn(22000); $order->getItems()->willReturn([$orderItem]); $order->getAdjustmentsTotalRecursively(AdjustmentInterface::TAX_ADJUSTMENT)->willReturn(0); $order->getOrderPromotionTotal()->willReturn(0); $order->getShippingTotal()->willReturn(2000); $orderItem->getVariant()->willReturn($productVariant); $orderItem->getDiscountedUnitPrice()->willReturn(20000); $orderItem->getQuantity()->willReturn(1); $productVariant->getProduct()->willReturn($product); $product->getName()->willReturn('Lamborghini Aventador Model'); $request->getSource()->willReturn($payment); $payment->getOrder()->willReturn($order); $invoiceNumberGenerator->generate($order, $payment)->willReturn('19-92'); $currencyConverter->convertFromBase(22000, 'PLN')->willReturn(88000); $currencyConverter->convertFromBase(20000, 'PLN')->willReturn(80000); $currencyConverter->convertFromBase(2000, 'PLN')->willReturn(8000); $details = ['PAYMENTREQUEST_0_INVNUM' => '19-92', 'PAYMENTREQUEST_0_CURRENCYCODE' => 'PLN', 'PAYMENTREQUEST_0_AMT' => 880.0, 'PAYMENTREQUEST_0_ITEMAMT' => 880.0, 'L_PAYMENTREQUEST_0_NAME0' => 'Lamborghini Aventador Model', 'L_PAYMENTREQUEST_0_AMT0' => 800.0, 'L_PAYMENTREQUEST_0_QTY0' => 1, 'L_PAYMENTREQUEST_0_NAME1' => 'Shipping Total', 'L_PAYMENTREQUEST_0_AMT1' => 80.0, 'L_PAYMENTREQUEST_0_QTY1' => 1]; $request->setResult($details)->shouldBeCalled(); $this->execute($request); }
/** * @When I delete the order :order */ public function iDeleteTheOrder(OrderInterface $order) { $adjustmentsId = []; foreach ($order->getAdjustments() as $adjustment) { $adjustmentsId[] = $adjustment->getId(); } $this->sharedStorage->set('deleted_adjustments', $adjustmentsId); $this->sharedStorage->set('deleted_addresses', [$order->getShippingAddress()->getId(), $order->getBillingAddress()->getId()]); $this->sharedStorage->set('order_id', $order->getId()); $this->orderRepository->remove($order); }
/** * Mark the order as completed. * * @param OrderInterface $order */ protected function completeOrder(OrderInterface $order) { $this->get('session')->set('sylius_order_id', $order->getId()); $this->dispatchCheckoutEvent(SyliusOrderEvents::PRE_CREATE, $order); $this->dispatchCheckoutEvent(SyliusCheckoutEvents::FINALIZE_PRE_COMPLETE, $order); $this->get('sm.factory')->get($order, OrderTransitions::GRAPH)->apply(OrderTransitions::SYLIUS_CREATE, true); $manager = $this->get('sylius.manager.order'); $manager->persist($order); $manager->flush(); $this->dispatchCheckoutEvent(SyliusCheckoutEvents::FINALIZE_COMPLETE, $order); $this->dispatchCheckoutEvent(SyliusOrderEvents::POST_CREATE, $order); }
/** * Mark the order as completed. * * @param OrderInterface $order */ protected function completeOrder(OrderInterface $order) { $this->get('session')->set('sylius_order_id', $order->getId()); $currencyProvider = $this->get('sylius.currency_provider'); $this->dispatchCheckoutEvent(SyliusOrderEvents::PRE_CREATE, $order); $this->dispatchCheckoutEvent(SyliusCheckoutEvents::FINALIZE_PRE_COMPLETE, $order); $this->get('sm.factory')->get($order, OrderTransitions::GRAPH)->apply(OrderTransitions::SYLIUS_CREATE, true); if ($order->getCurrency() !== $currencyProvider->getBaseCurrency()) { $currencyRepository = $this->get('sylius.repository.currency'); $currency = $currencyRepository->findOneBy(['code' => $order->getCurrency()]); $order->setExchangeRate($currency->getExchangeRate()); } $manager = $this->get('sylius.manager.order'); $manager->persist($order); $manager->flush(); $this->dispatchCheckoutEvent(SyliusCheckoutEvents::FINALIZE_COMPLETE, $order); $this->dispatchCheckoutEvent(SyliusOrderEvents::POST_CREATE, $order); }
/** * @When /^I want to modify a customer's shipping address of (this order)$/ */ public function iWantToModifyACustomerSShippingAddress(OrderInterface $order) { $this->updateShippingAddressPage->open(['id' => $order->getId()]); }
/** * @Then /^(the administrator) should see that (order placed by "[^"]+") has "([^"]+)" currency$/ */ public function theAdministratorShouldSeeThatThisOrderHasBeenPlacedIn(AdminUserInterface $user, OrderInterface $order, $currency) { $this->sharedSecurityService->performActionAsAdminUser($user, function () use($order, $currency) { $this->showPage->open(['id' => $order->getId()]); Assert::same($this->showPage->getOrderCurrency(), $currency, 'The order has been placed in %s, but it was expected to be placed in %s'); }); }
function it_throws_an_exception_if_order_still_exists(OrderRepositoryInterface $orderRepository, OrderInterface $order) { $order->getId()->willReturn(1); $orderRepository->find(1)->willReturn($order); $this->shouldThrow(NotEqualException::class)->during('orderShouldNotExistInTheRegistry', [$order]); }
/** * @Then /^(the administrator) should know about (this additional note) for (this order made by "[^"]+")$/ */ public function theCustomerServiceShouldKnowAboutThisAdditionalNotes(UserInterface $user, $note, OrderInterface $order) { $this->securityService->performActionAs($user, function () use($note, $order) { $this->showPage->open(['id' => $order->getId()]); Assert::true($this->showPage->hasNote($note), sprintf('I should see %s note, but I do not see', $note)); }); }
/** * @When I view the summary of the order :order */ public function iSeeTheOrder(OrderInterface $order) { $this->showPage->open(['id' => $order->getId()]); }
/** * @Then /^(this cart) should not be deleted$/ */ public function thisCartShouldNotBeDeleted(OrderInterface $cart) { $this->expiredCartsRemover->remove(); Assert::notNull($cart->getId(), 'This cart should be in registry but it is not.'); }