/** * Assert that Order Grand Total is correct on order page in backend. * * @param SalesOrderIndex $salesOrder * @param SalesOrderView $salesOrderView * @param mixed $grandTotal * @param string $orderId * @return void */ public function processAssert(SalesOrderIndex $salesOrder, SalesOrderView $salesOrderView, $grandTotal, $orderId) { $salesOrder->open()->getSalesOrderGrid()->searchAndOpen(['id' => $orderId]); $expected = number_format(is_array($grandTotal) ? array_sum($grandTotal) : $grandTotal, 2); $actual = $salesOrderView->getOrderForm()->getTabElement('information')->getOrderTotalsBlock()->getData('grand_total'); \PHPUnit_Framework_Assert::assertEquals($expected, $actual, "Expected: {$expected}; Actual: {$actual}"); }
/** * Assert that address on order page in backend is same as address in PayPal. * * @param SalesOrderIndex $salesOrderIndex * @param SalesOrderView $salesOrderView * @param PaypalCustomer $paypalCustomer * @param string $orderId * @return void */ public function processAssert(SalesOrderIndex $salesOrderIndex, SalesOrderView $salesOrderView, PaypalCustomer $paypalCustomer, $orderId) { $addressBlock = "get{$this->addressType}AddressBlock"; $salesOrderIndex->open()->getSalesOrderGrid()->searchAndOpen(['id' => $orderId]); /** @var Info $informationTab */ $informationTab = $salesOrderView->getOrderForm()->getTabElement('information'); $orderAddress = $informationTab->{$addressBlock}()->getAddress(); $payPalShippingAddress = $this->prepareCustomerAddress($paypalCustomer, $orderAddress); \PHPUnit_Framework_Assert::assertEquals($payPalShippingAddress, $orderAddress); }
/** * Assert that message like this persist on Comments History section on order page in backend: * "transaction_type amount of some_amount. Transaction ID: "transaction_id" * * @param SalesOrderIndex $salesOrderIndex * @param SalesOrderView $salesOrderView * @param string $orderId * @param string $transactionType * @param string $paymentAction * @param string $grandTotal * @return void */ public function processAssert(SalesOrderIndex $salesOrderIndex, SalesOrderView $salesOrderView, $orderId, $transactionType, $paymentAction, $grandTotal) { $filter = ['order_id' => $orderId, 'transaction_type' => $transactionType]; $salesOrderIndex->open()->getSalesOrderGrid()->searchAndOpen(['id' => $orderId]); $orderForm = $salesOrderView->getOrderForm(); /** Check if transaction present in comments block. */ /** @var Info $informationTab */ $informationTab = $orderForm->getTabElement('information'); $text = $this->prepareSearchedText($grandTotal); \PHPUnit_Framework_Assert::assertTrue($informationTab->getCommentsBlock()->isCommentPresent($text), 'Searched text is not present in order comments.'); \PHPUnit_Framework_Assert::assertTrue($informationTab->getCommentsBlock()->isCommentPresent($paymentAction), 'Order has a wrong payment action.'); /** Check if transaction present in transactions Grid. */ $orderForm->openTab('transactions'); /** @var Transactions $transactionsTab */ $transactionsTab = $orderForm->getTabElement('transactions'); \PHPUnit_Framework_Assert::assertTrue($transactionsTab->getGrid()->isRowVisible($filter), 'Searched transaction is not present in transaction grid.'); }
/** * Get sales entity id. * * @param string $entity * @return array */ public function getEntityIds($entity) { $this->salesOrderView->getOrderForm()->openTab($entity . 's'); return $this->salesOrderView->getOrderForm()->getTabElement($entity . 's')->getGrid()->getIds(); }
/** * Get grid for assert. * * @return Grid */ protected function getGrid() { return $this->salesOrderView->getOrderForm()->getTabElement($this->entityType . 's')->getGrid(); }
/** * Get shipping address data from order form. * * @param SalesOrderView $salesOrderView * @return string */ protected function getFormAddress(SalesOrderView $salesOrderView) { return $salesOrderView->getOrderForm()->getTabElement('information')->getShippingAddressBlock()->getAddress(); }
/** * Assert that status is correct on order page in backend (same with value of orderStatus variable). * * @param SalesOrderIndex $salesOrder * @param SalesOrderView $salesOrderView * @param string $status * @param string $orderId * @return void */ public function processAssert(SalesOrderIndex $salesOrder, SalesOrderView $salesOrderView, $status, $orderId) { $salesOrder->open()->getSalesOrderGrid()->searchAndOpen(['id' => $orderId]); \PHPUnit_Framework_Assert::assertEquals($status, $salesOrderView->getOrderForm()->getTabElement('information')->getOrderInfoBlock()->getOrderStatus()); }
/** * Assert that status is correct on order page in backend (same with value of orderStatus variable). * * @param string $previousOrderStatus * @param Order $order * @param SalesOrderIndex $salesOrder * @param SalesOrderView $salesOrderView * @return void */ public function processAssert($previousOrderStatus, Order $order, SalesOrderIndex $salesOrder, SalesOrderView $salesOrderView) { $salesOrder->open()->getSalesOrderGrid()->searchAndOpen(['id' => $order->getId()]); \PHPUnit_Framework_Assert::assertEquals($previousOrderStatus, $salesOrderView->getOrderForm()->getTabElement('information')->getOrderInfoBlock()->getOrderStatus(), 'Order status is incorrect on order page in backend.'); }