/** * Assert that invoiced Grand Total amount is equal to placed order Grand total amount on invoice page (frontend) * * @param OrderHistory $orderHistory * @param OrderInjectable $order * @param CustomerOrderView $customerOrderView * @param InvoiceView $invoiceView * @param array $ids * @return void */ public function processAssert(OrderHistory $orderHistory, OrderInjectable $order, CustomerOrderView $customerOrderView, InvoiceView $invoiceView, array $ids) { $this->loginCustomerAndOpenOrderPage($order->getDataFieldConfig('customer_id')['source']->getCustomer()); $orderHistory->getOrderHistoryBlock()->openOrderById($order->getId()); $customerOrderView->getOrderViewBlock()->openLinkByName('Invoices'); foreach ($ids['invoiceIds'] as $key => $invoiceId) { \PHPUnit_Framework_Assert::assertEquals(number_format($order->getPrice()[$key]['grand_invoice_total'], 2), $invoiceView->getInvoiceBlock()->getItemBlock($invoiceId)->getGrandTotal()); } }
/** * Put created order on hold. * * @param OrderInjectable $order * @return array */ public function test(OrderInjectable $order) { // Preconditions $order->persist(); // Steps $this->orderIndex->open(); $this->orderIndex->getSalesOrderGrid()->searchAndOpen(['id' => $order->getId()]); $this->salesOrderView->getPageActions()->hold(); return ['customer' => $order->getDataFieldConfig('customer_id')['source']->getCustomer()]; }
/** * Assert that shipped items quantity in 'Total Quantity' is equal to data from fixture on My Account page * * @param OrderHistory $orderHistory * @param OrderInjectable $order * @param CustomerOrderView $customerOrderView * @param ShipmentView $shipmentView * @param array $ids * @return void */ public function processAssert(OrderHistory $orderHistory, OrderInjectable $order, CustomerOrderView $customerOrderView, ShipmentView $shipmentView, array $ids) { $totalQty = $order->getTotalQtyOrdered(); $this->loginCustomerAndOpenOrderPage($order->getDataFieldConfig('customer_id')['source']->getCustomer()); $orderHistory->getOrderHistoryBlock()->openOrderById($order->getId()); $customerOrderView->getOrderViewBlock()->openLinkByName('Order Shipments'); foreach ($ids['shipmentIds'] as $key => $shipmentIds) { \PHPUnit_Framework_Assert::assertEquals($totalQty[$key], $shipmentView->getShipmentBlock()->getItemShipmentBlock($shipmentIds)->getTotalQty()); } }
/** * Move last ordered products on order page. * * @param OrderInjectable $order * @return array */ public function test(OrderInjectable $order) { // Preconditions: $order->persist(); $customer = $order->getDataFieldConfig('customer_id')['source']->getCustomer(); // Steps: $this->customerIndex->open(); $this->customerIndex->getCustomerGridBlock()->searchAndOpen(['email' => $customer->getEmail()]); $this->customerIndexEdit->getPageActionsBlock()->createOrder(); $this->orderCreateIndex->getStoreBlock()->selectStoreView(); $products = $order->getEntityId()['products']; $activitiesBlock = $this->orderCreateIndex->getCustomerActivitiesBlock(); $activitiesBlock->getLastOrderedItemsBlock()->addProductsToOrder($products); $activitiesBlock->updateChanges(); return ['products' => $products]; }
/** * Automatic Apply Tax Based on VAT ID. * * @param ConfigData $vatConfig * @param OrderInjectable $order * @param TaxRule $taxRule * @param Cart $cart * @param string $configData * @param string $customerGroup * @return array */ public function test(ConfigData $vatConfig, OrderInjectable $order, TaxRule $taxRule, Cart $cart, $configData, $customerGroup) { // Preconditions $this->configData = $configData; $this->objectManager->create('Magento\\Config\\Test\\TestStep\\SetupConfigurationStep', ['configData' => $this->configData])->run(); $taxRule->persist(); // Prepare data $this->customer = $order->getDataFieldConfig('customer_id')['source']->getCustomer(); $address = $this->customer->getDataFieldConfig('address')['source']->getAddresses()[0]; $this->prepareVatConfig($vatConfig, $customerGroup); $poducts = $order->getEntityId()['products']; $cart = $this->fixtureFactory->createByCode('cart', ['data' => array_merge($cart->getData(), ['items' => ['products' => $poducts]])]); // Steps $order->persist(); $this->objectManager->create('Magento\\Customer\\Test\\TestStep\\LoginCustomerOnFrontendStep', ['customer' => $this->customer])->run(); $this->objectManager->create('Magento\\Checkout\\Test\\TestStep\\AddProductsToTheCartStep', $order->getEntityId())->run(); $this->checkoutCart->open(); $this->checkoutCart->getCartBlock()->waitCartContainerLoading(); $this->checkoutCart->getShippingBlock()->fillEstimateShippingAndTax($address); $this->checkoutCart->getCartBlock()->waitCartContainerLoading(); return ['customer' => $this->customer, 'address' => $address, 'orderId' => $order->getId(), 'cart' => $cart, 'products' => $poducts]; }
/** * Run Update Custom OrderStatus Test. * * @param OrderStatus $orderStatusInitial * @param OrderStatus $orderStatus * @param OrderInjectable $order * @param FixtureFactory $fixtureFactory * @param string $orderExist * @return array */ public function test(OrderStatus $orderStatusInitial, OrderStatus $orderStatus, OrderInjectable $order, FixtureFactory $fixtureFactory, $orderExist) { // Preconditions: $orderStatusInitial->persist(); if ($orderExist == 'Yes') { $config = $fixtureFactory->createByCode('configData', ['dataset' => 'checkmo_custom_new_order_status', 'data' => ['payment/checkmo/order_status' => ['value' => $orderStatusInitial->getStatus()]]]); $config->persist(); $order->persist(); } // Steps: $this->orderStatusIndex->open(); $this->orderStatusIndex->getOrderStatusGrid()->searchAndOpen(['label' => $orderStatusInitial->getLabel()]); $this->orderStatusEdit->getOrderStatusForm()->fill($orderStatus); $this->orderStatusEdit->getFormPageActions()->save(); // Configuring orderStatus for asserts. $orderStatus = $fixtureFactory->createByCode('orderStatus', ['data' => array_merge($orderStatusInitial->getData(), $orderStatus->getData())]); // Prepare data for tear down $this->orderStatus = $orderStatus; $this->orderStatusInitial = $orderStatusInitial; $this->order = $order; return ['orderStatus' => $orderStatus, 'status' => $orderStatus->getLabel(), 'customer' => $order->getDataFieldConfig('customer_id')['source']->getCustomer()]; }
/** * Run Assign Custom OrderStatus. * * @param OrderStatus $orderStatus * @param OrderInjectable $order * @param array $orderStatusState * @param AssertOrderStatusSuccessAssignMessage $assertion * @return array */ public function test(OrderStatus $orderStatus, OrderInjectable $order, array $orderStatusState, AssertOrderStatusSuccessAssignMessage $assertion) { // Preconditions: $orderStatus->persist(); /** @var OrderStatus $orderStatus */ $orderStatus = $this->fixtureFactory->createByCode('orderStatus', ['data' => array_merge($orderStatus->getData(), $orderStatusState)]); $this->orderStatus = $orderStatus; // Steps: $this->orderStatusIndex->open(); $this->orderStatusIndex->getGridPageActions()->assignStatusToState(); $this->orderStatusAssign->getAssignForm()->fill($orderStatus); $this->orderStatusAssign->getPageActionsBlock()->save(); $assertion->processAssert($this->orderStatusIndex); $order->persist(); $this->order = $order; return ['orderId' => $order->getId(), 'customer' => $order->getDataFieldConfig('customer_id')['source']->getCustomer(), 'status' => $orderStatus->getLabel()]; }
/** * Prepare customer data. * * @param array $data * @return array */ protected function prepareCustomerData(array $data) { return ['currency_id' => $data['base_currency_code'], 'customer_id' => $this->customer->getData('id'), 'payment' => $data['payment_authorization_amount'], 'store_id' => $this->order->getDataFieldConfig('store_id')['source']->store->getStoreId()]; }
/** * Open Downloadable Link. * * @param OrderInjectable $order * @param int $downloads * @return void */ protected function openDownloadableLink(OrderInjectable $order, $downloads) { $customerLogin = $this->objectManager->create('Magento\\Customer\\Test\\TestStep\\LoginCustomerOnFrontendStep', ['customer' => $order->getDataFieldConfig('customer_id')['source']->getCustomer()]); $customerLogin->run(); $this->customerAccount->getAccountMenuBlock()->openMenuItem('My Downloadable Products'); $downloadableProductsUrl = $this->browser->getUrl(); foreach ($order->getEntityId()['products'] as $product) { foreach ($product->getDownloadableLinks()['downloadable']['link'] as $link) { for ($i = 0; $i < $downloads; $i++) { $this->browser->open($this->customerProducts->getMainBlock()->getLinkUrl($link['title'])); $this->browser->open($downloadableProductsUrl); } } } }