/** * Assert that shipment is present in the Shipments tab with correct shipped items quantity * * @param SalesOrderView $salesOrderView * @param OrderIndex $orderIndex * @param OrderInjectable $order * @param array $ids * @return void */ public function processAssert(SalesOrderView $salesOrderView, OrderIndex $orderIndex, OrderInjectable $order, array $ids) { $orderIndex->open(); $orderIndex->getSalesOrderGrid()->searchAndOpen(['id' => $order->getId()]); $salesOrderView->getOrderForm()->openTab('shipments'); $totalQty = $order->getTotalQtyOrdered(); $totalQty = is_array($totalQty) ? $totalQty : [$totalQty]; foreach ($ids['shipmentIds'] as $key => $shipmentId) { $filter = ['id' => $shipmentId, 'qty_from' => $totalQty[$key], 'qty_to' => $totalQty[$key]]; \PHPUnit_Framework_Assert::assertTrue($salesOrderView->getOrderForm()->getTabElement('shipments')->getGridBlock()->isRowVisible($filter), 'Shipment is absent on shipments tab.'); } }
/** * Assert that refund is present in the tab with ID and refunded amount(depending on full/partial refund). * * @param SalesOrderView $salesOrderView * @param OrderIndex $orderIndex * @param OrderInjectable $order * @param array $ids * @return void */ public function processAssert(SalesOrderView $salesOrderView, OrderIndex $orderIndex, OrderInjectable $order, array $ids) { $orderIndex->open(); $orderIndex->getSalesOrderGrid()->searchAndOpen(['id' => $order->getId()]); $salesOrderView->getOrderForm()->openTab('creditmemos'); /** @var Grid $grid */ $grid = $salesOrderView->getOrderForm()->getTab('creditmemos')->getGridBlock(); $amount = $order->getPrice(); foreach ($ids['creditMemoIds'] as $key => $creditMemoId) { $filter = ['id' => $creditMemoId, 'amount_from' => $amount[$key]['grand_creditmemo_total'], 'amount_to' => $amount[$key]['grand_creditmemo_total']]; \PHPUnit_Framework_Assert::assertTrue($grid->isRowVisible($filter, true, false), 'Credit memo is absent on credit memos tab.'); } }
/** * Assert that invoice is present in the invoices tab of the order with corresponding amount(Grand Total) * * @param SalesOrderView $salesOrderView * @param OrderIndex $orderIndex * @param OrderInjectable $order * @param array $ids * @return void */ public function processAssert(SalesOrderView $salesOrderView, OrderIndex $orderIndex, OrderInjectable $order, array $ids) { $orderIndex->open(); $orderIndex->getSalesOrderGrid()->searchAndOpen(['id' => $order->getId()]); $salesOrderView->getOrderForm()->openTab('invoices'); /** @var Grid $grid */ $grid = $salesOrderView->getOrderForm()->getTabElement('invoices')->getGridBlock(); $amount = $order->getPrice(); foreach ($ids['invoiceIds'] as $key => $invoiceId) { $filter = ['id' => $invoiceId, 'amount_from' => $amount[$key]['grand_invoice_total'], 'amount_to' => $amount[$key]['grand_invoice_total']]; $grid->search($filter); $filter['amount_from'] = number_format($amount[$key]['grand_invoice_total'], 2); $filter['amount_to'] = number_format($amount[$key]['grand_invoice_total'], 2); \PHPUnit_Framework_Assert::assertTrue($grid->isRowVisible($filter, false, false), 'Invoice is absent on invoices tab.'); } }
/** * Assert that status is correct on order page in backend (same with value of orderStatus variable) * * @param string $status * @param string $orderId * @param OrderIndex $salesOrder * @param SalesOrderView $salesOrderView * @param string|null $statusToCheck * @return void */ public function processAssert($status, $orderId, OrderIndex $salesOrder, SalesOrderView $salesOrderView, $statusToCheck = null) { $salesOrder->open(); $salesOrder->getSalesOrderGrid()->searchAndOpen(['id' => $orderId]); $orderStatus = $statusToCheck == null ? $status : $statusToCheck; \PHPUnit_Framework_Assert::assertEquals($salesOrderView->getOrderForm()->getOrderInfoBlock()->getOrderStatus(), $orderStatus); }
/** * Assert that comment about authorized amount exist in Comments History section on order page in Admin. * * @param SalesOrderView $salesOrderView * @param OrderIndex $salesOrder * @param string $orderId * @param array $transactionDetails * @throws \Exception */ public function processAssert(SalesOrderView $salesOrderView, OrderIndex $salesOrder, $orderId, array $transactionDetails) { $transactionId = ''; $salesOrder->open(); $salesOrder->getSalesOrderGrid()->searchAndOpen(['id' => $orderId]); $comment = $salesOrderView->getOrderHistoryBlock()->getCommentsHistory(); preg_match('/(ID: ")(\\w+-*\\w+)(")/', $comment, $matches); if (!empty($matches[2])) { $transactionId = $matches[2]; } \PHPUnit_Framework_Assert::assertNotEmpty($transactionId); $orderForm = $salesOrderView->getOrderForm()->openTab('transactions'); /** @var Grid $grid */ $grid = $orderForm->getTab('transactions')->getGridBlock(); $actualTxnIds = $grid->getIds(); \PHPUnit_Framework_Assert::assertEquals($transactionDetails, $actualTxnIds[$transactionId], 'Incorrect transaction details for the order #' . $orderId); }
/** * Get credit memo ids. * * @return array */ protected function getCreditMemoIds() { $this->salesOrderView->getOrderForm()->openTab('creditmemos'); return $this->salesOrderView->getOrderForm()->getTab('creditmemos')->getGridBlock()->getIds(); }
/** * Assert that status is correct on order page in backend (same with value of orderStatus variable) * * @param string $previousOrderStatus * @param OrderInjectable $order * @param OrderIndex $salesOrder * @param SalesOrderView $salesOrderView * @return void */ public function processAssert($previousOrderStatus, OrderInjectable $order, OrderIndex $salesOrder, SalesOrderView $salesOrderView) { $salesOrder->open(); $salesOrder->getSalesOrderGrid()->searchAndOpen(['id' => $order->getId()]); \PHPUnit_Framework_Assert::assertEquals($previousOrderStatus, $salesOrderView->getOrderForm()->getOrderInfoBlock()->getOrderStatus(), 'Order status is incorrect on order page in backend.'); }
/** * Get shipment ids. * * @return array */ protected function getShipmentIds() { $this->salesOrderView->getOrderForm()->openTab('shipments'); return $this->salesOrderView->getOrderForm()->getTab('shipments')->getGridBlock()->getIds(); }