コード例 #1
0
 /**
  * Create shipping for order on backend.
  *
  * @return array
  */
 public function run()
 {
     $this->orderIndex->open();
     $this->orderIndex->getSalesOrderGrid()->searchAndOpen(['id' => $this->order->getId()]);
     $this->salesOrderView->getPageActions()->ship();
     if (!empty($this->data)) {
         $this->orderShipmentNew->getFormBlock()->fillData($this->data, $this->order->getEntityId()['products']);
     }
     $this->orderShipmentNew->getFormBlock()->submit();
     return ['shipmentIds' => $this->getShipmentIds()];
 }
コード例 #2
0
 /**
  * Create credit memo from order on backend.
  *
  * @return array
  */
 public function run()
 {
     $this->orderIndex->open();
     $this->orderIndex->getSalesOrderGrid()->searchAndOpen(['id' => $this->order->getId()]);
     $this->salesOrderView->getPageActions()->orderCreditMemo();
     if (!empty($this->data)) {
         $this->orderCreditMemoNew->getFormBlock()->fillProductData($this->data, $this->order->getEntityId()['products']);
         $this->orderCreditMemoNew->getFormBlock()->updateQty();
         $this->orderCreditMemoNew->getFormBlock()->fillFormData($this->data);
     }
     $this->orderCreditMemoNew->getFormBlock()->submit();
     return ['creditMemoIds' => $this->getCreditMemoIds()];
 }
コード例 #3
0
 /**
  * Prepare expected result
  *
  * @param array $expectedSalesData
  * @return array
  */
 protected function prepareExpectedResult(array $expectedSalesData)
 {
     $salesItems = 0;
     $invoice = $this->order->getPrice()[0]['grand_invoice_total'];
     $salesTotal = $this->order->getPrice()[0]['grand_order_total'];
     foreach ($this->order->getEntityId()['products'] as $product) {
         $salesItems += $product->getCheckoutData()['qty'];
     }
     $expectedSalesData['orders'] += 1;
     $expectedSalesData['sales-items'] += $salesItems;
     $expectedSalesData['sales-total'] += $salesTotal;
     $expectedSalesData['invoiced'] += $invoice;
     return $expectedSalesData;
 }
コード例 #4
0
 /**
  * Assert bestseller info in report: date, product name and qty.
  *
  * @param Bestsellers $bestsellers
  * @param OrderInjectable $order
  * @param string $date
  * @return void
  */
 public function processAssert(Bestsellers $bestsellers, OrderInjectable $order, $date)
 {
     /** @var CatalogProductSimple $product */
     $product = $order->getEntityId()['products'][0];
     $filter = ['date' => date($date), 'product' => $product->getName(), 'price' => $product->getPrice(), 'orders' => $product->getCheckoutData()['qty']];
     \PHPUnit_Framework_Assert::assertTrue($bestsellers->getGridBlock()->isRowVisible($filter, false), 'Bestseller does not present in report grid.');
 }
コード例 #5
0
ファイル: Grid.php プロジェクト: kidaa30/magento2-platformsh
 /**
  * Get orders quantity from Ordered Products Report grid
  *
  * @param OrderInjectable $order
  * @return array
  */
 public function getOrdersResults(OrderInjectable $order)
 {
     $products = $order->getEntityId()['products'];
     $views = [];
     foreach ($products as $key => $product) {
         $views[$key] = $this->_rootElement->find(sprintf($this->product, $product->getName()), Locator::SELECTOR_XPATH)->getText();
     }
     return $views;
 }
コード例 #6
0
 /**
  * Prepare order products
  *
  * @param OrderInjectable $order
  * @param array|null $data [optional]
  * @return array
  */
 protected function prepareOrderProducts(OrderInjectable $order, array $data = null)
 {
     $products = $order->getEntityId()['products'];
     $productsData = [];
     /** @var CatalogProductSimple $product */
     foreach ($products as $key => $product) {
         $productsData[] = ['product' => $product->getName(), 'sku' => $product->getSku(), 'qty' => isset($data[$key]['qty']) && $data[$key]['qty'] != '-' ? $data[$key]['qty'] : $product->getCheckoutData()['qty']];
     }
     return $this->sortDataByPath($productsData, $this->sortKey);
 }
コード例 #7
0
 /**
  * Assert bestseller info in report: date, product name and qty
  *
  * @param Bestsellers $bestsellers
  * @param OrderInjectable $order
  * @param string $date
  * @return void
  *
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function processAssert(Bestsellers $bestsellers, OrderInjectable $order, $date)
 {
     $products = $order->getEntityId()['products'];
     $totalQuantity = $bestsellers->getGridBlock()->getViewsResults($products, $date);
     $productQty = [];
     foreach ($products as $key => $product) {
         /** @var CatalogProductSimple $product*/
         $productQty[$key] = $product->getCheckoutData()['qty'];
     }
     \PHPUnit_Framework_Assert::assertEquals($productQty, $totalQuantity);
 }
コード例 #8
0
 /**
  * Assert that ordered products in bestsellers on Dashboard successfully refreshed.
  *
  * @param OrderInjectable $order
  * @param Dashboard $dashboard
  * @return void
  */
 public function processAssert(OrderInjectable $order, Dashboard $dashboard)
 {
     $dashboard->open();
     $dashboard->getStoreStatsBlock()->refreshData();
     /** @var \Magento\Backend\Test\Block\Dashboard\Tab\Products\Ordered $bestsellersGrid */
     $bestsellersGrid = $dashboard->getStoreStatsBlock()->getTabElement('bestsellers')->getBestsellersGrid();
     $products = $order->getEntityId()['products'];
     foreach ($products as $product) {
         \PHPUnit_Framework_Assert::assertTrue($bestsellersGrid->isProductVisible($product), 'Bestseller ' . $product->getName() . ' is not present in report grid after refresh data.');
     }
 }
コード例 #9
0
 /**
  * Assert product name and qty in Ordered Products report
  *
  * @param OrderedProductsReport $orderedProducts
  * @param OrderInjectable $order
  * @return void
  */
 public function processAssert(OrderedProductsReport $orderedProducts, OrderInjectable $order)
 {
     $products = $order->getEntityId()['products'];
     $totalQuantity = $orderedProducts->getGridBlock()->getOrdersResults($order);
     $productQty = [];
     foreach ($totalQuantity as $key => $value) {
         /** @var CatalogProductSimple $product */
         $product = $products[$key];
         $productQty[$key] = $product->getCheckoutData()['qty'];
     }
     \PHPUnit_Framework_Assert::assertEquals($totalQuantity, $productQty);
 }
コード例 #10
0
 /**
  * Assert product info in report: product name, link title, sku, downloads number (Reports > Products > Downloads)
  *
  * @param OrderInjectable $order
  * @param DownloadsReport $downloadsReport
  * @param int $downloads
  * @return void
  */
 public function processAssert(OrderInjectable $order, DownloadsReport $downloadsReport, $downloads)
 {
     $downloadsReport->open();
     foreach ($order->getEntityId()['products'] as $product) {
         foreach ($product->getDownloadableLinks()['downloadable']['link'] as $link) {
             $filter = ['name' => $product->getName(), 'link_title' => $link['title'], 'sku' => $product->getSku()];
             $downloadsReport->getGridBlock()->search($filter);
             $filter[] = $downloads;
             \PHPUnit_Framework_Assert::assertTrue($downloadsReport->getGridBlock()->isRowVisible($filter, false), "Downloads report link {$link['title']} is not present in reports grid.");
         }
     }
 }
コード例 #11
0
 /**
  * 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];
 }
コード例 #12
0
 /**
  * Create credit memo.
  *
  * @return array
  */
 public function run()
 {
     $this->orderIndex->open();
     $this->orderIndex->getSalesOrderGrid()->searchAndOpen(['id' => $this->order->getId()]);
     /** @var \Magento\Sales\Test\Block\Adminhtml\Order\View\Tab\Invoices\Grid $invoicesGrid */
     $invoicesGrid = $this->salesOrderView->getOrderForm()->getTab('invoices')->getGridBlock();
     $this->salesOrderView->getOrderForm()->openTab('invoices');
     $invoicesGrid->viewInvoice();
     $this->salesOrderView->getPageActions()->orderInvoiceCreditMemo();
     if (!empty($this->refundData)) {
         $this->orderCreditMemoNew->getFormBlock()->fillProductData($this->refundData, $this->order->getEntityId()['products']);
         $this->orderCreditMemoNew->getFormBlock()->updateQty();
     }
     $this->orderCreditMemoNew->getFormBlock()->submit();
     return ['ids' => ['creditMemoIds' => $this->getCreditMemoIds()]];
 }
コード例 #13
0
 /**
  * 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];
 }
コード例 #14
0
ファイル: CreateInvoiceStep.php プロジェクト: opexsw/magento2
 /**
  * Create invoice (with shipment optionally) for order on backend.
  *
  * @return array
  */
 public function run()
 {
     $this->orderIndex->open();
     $this->orderIndex->getSalesOrderGrid()->searchAndOpen(['id' => $this->order->getId()]);
     $this->salesOrderView->getPageActions()->invoice();
     if (!empty($this->data)) {
         $this->orderInvoiceNew->getFormBlock()->fillData($this->data, $this->order->getEntityId()['products']);
         $this->orderInvoiceNew->getFormBlock()->updateQty();
     }
     $this->orderInvoiceNew->getFormBlock()->submit();
     $invoiceIds = $this->getInvoiceIds();
     if (!empty($this->data)) {
         $shipmentIds = $this->getShipmentIds();
     }
     return ['invoiceIds' => $invoiceIds, 'shipmentIds' => isset($shipmentIds) ? $shipmentIds : null];
 }
コード例 #15
0
 /**
  * Get product's fixture.
  *
  * @param OrderInjectable $order
  * @param array $data
  * @param int $index [optional]
  * @return FixtureInterface
  */
 protected function getProduct(OrderInjectable $order, array $data, $index = 0)
 {
     if (!isset($data['items_data'][$index]['back_to_stock']) || $data['items_data'][$index]['back_to_stock'] != 'Yes') {
         return $order->getEntityId()['products'][$index];
     }
     $product = $order->getEntityId()['products'][$index];
     $productData = $product->getData();
     $checkoutDataQty = $productData['checkout_data']['qty'];
     $productData['quantity_and_stock_status']['qty'] -= $checkoutDataQty - $data['items_data'][$index]['qty'];
     $productData = array_diff_key($productData, array_flip($this->skipFields));
     return $this->fixtureFactory->create(get_class($product), ['data' => $productData]);
 }
コード例 #16
0
 /**
  * Assert sales info in report: Tax, Rate, Orders, Tax Amount on tax report page
  *
  * @param SalesTaxReport $salesTaxReport
  * @param OrderInjectable $order
  * @param TaxRule $taxRule
  * @param string $taxAmount
  * @return void
  */
 public function processAssert(SalesTaxReport $salesTaxReport, OrderInjectable $order, TaxRule $taxRule, $taxAmount)
 {
     $filter = ['tax' => $taxRule->getTaxRate()[0], 'rate' => $taxRule->getDataFieldConfig('tax_rate')['source']->getFixture()[0]->getRate(), 'orders' => count($order->getEntityId()['products']), 'tax_amount' => $taxAmount];
     \PHPUnit_Framework_Assert::assertTrue($salesTaxReport->getGridBlock()->isRowVisible($filter, false), "Tax Report is not visible in grid on tax report page.");
 }
コード例 #17
0
 /**
  * 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);
             }
         }
     }
 }
コード例 #18
0
 /**
  * Create order.
  *
  * @return array
  */
 public function run()
 {
     $this->order->persist();
     return ['products' => $this->order->getEntityId()['products'], 'order' => $this->order];
 }
コード例 #19
0
 /**
  * Add products to quote.
  *
  * @param OrderInjectable $order
  * @return void
  * @throws \Exception
  */
 protected function setProducts(OrderInjectable $order)
 {
     $url = $_ENV['app_frontend_url'] . 'rest/V1/carts/' . $this->quote . '/items';
     $products = $order->getEntityId()['products'];
     foreach ($products as $product) {
         $data = ['cartItem' => ['sku' => $product->getSku(), 'qty' => isset($product->getCheckoutData()['qty']) ? $product->getCheckoutData()['qty'] : 1, 'quote_id' => $this->quote]];
         $methodName = 'prepare' . ucfirst($product->getDataConfig()['type_id']) . 'Options';
         if (method_exists($this, $methodName)) {
             $data['cartItem']['product_option'] = $this->{$methodName}($product);
         }
         $this->webapiTransport->write($url, $data);
         $response = (array) json_decode($this->webapiTransport->read(), true);
         $this->webapiTransport->close();
         if (isset($response['message'])) {
             $this->eventManager->dispatchEvent(['webapi_failed'], [$response]);
             throw new \Exception('Could not add product item to quote!');
         }
     }
 }