/**
  * 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 'Button name' button is absent order page.
  *
  * @param SalesOrderView $salesOrderView
  * @param SalesOrderIndex $orderIndex
  * @param Order $order
  * @param string|null $orderId
  * @return void
  */
 public function processAssert(SalesOrderView $salesOrderView, SalesOrderIndex $orderIndex, Order $order = null, $orderId = null)
 {
     $orderIndex->open();
     $orderId = $orderId == null ? $order->getId() : $orderId;
     $orderIndex->getSalesOrderGrid()->searchAndOpen(['id' => $orderId]);
     \PHPUnit_Framework_Assert::assertFalse($salesOrderView->getPageActions()->isActionButtonVisible($this->buttonName), "'{$this->buttonName}' button is present on order view page.");
 }
 /**
  * Fill Sales Data.
  *
  * @return array
  */
 public function run()
 {
     $this->salesOrderCreateIndex->getCreateBlock()->submitOrder();
     $this->salesOrderView->getMessagesBlock()->waitSuccessMessage();
     $orderId = $this->salesOrderView->getTitleBlock()->getOrderId();
     $order = $this->fixtureFactory->createByCode('order', ['data' => ['id' => $orderId, 'customer_id' => ['customer' => $this->customer], 'entity_id' => ['products' => $this->products], 'billing_address_id' => ['billingAddress' => $this->billingAddress]]]);
     return ['orderId' => $orderId, 'order' => $order];
 }
 /**
  * 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);
 }
 /**
  * Cancel created order.
  *
  * @param Order $order
  * @return array
  */
 public function test(Order $order)
 {
     // Preconditions
     $order->persist();
     // Steps
     $this->orderIndex->open();
     $this->orderIndex->getSalesOrderGrid()->searchAndOpen(['id' => $order->getId()]);
     $this->salesOrderView->getPageActions()->cancel();
     return ['customer' => $order->getDataFieldConfig('customer_id')['source']->getCustomer(), 'orderId' => $order->getId(), 'product' => $order->getEntityId()['products'][0]];
 }
 /**
  * Get absent buttons.
  *
  * @param SalesOrderView $salesOrderView
  * @param string $orderButtonsAvailable
  * @return array
  */
 protected function getAbsentButtons(SalesOrderView $salesOrderView, $orderButtonsAvailable)
 {
     $buttons = explode(',', $orderButtonsAvailable);
     $absentButtons = [];
     $actionsBlock = $salesOrderView->getPageActions();
     foreach ($buttons as $button) {
         if (!$actionsBlock->isActionButtonVisible(trim($button))) {
             $absentButtons[] = $button;
         }
     }
     return $absentButtons;
 }
Example #7
0
 /**
  * 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.');
 }
 /**
  * Fill Sales Data.
  *
  * @return array
  */
 public function run()
 {
     $this->salesOrderCreateIndex->getCreateBlock()->submitOrder();
     $this->salesOrderView->getMessagesBlock()->waitSuccessMessage();
     $orderId = $this->salesOrderView->getTitleBlock()->getOrderId();
     $order = $this->createOrderFixture($orderId);
     return ['orderId' => $orderId, 'order' => $order];
 }
 /**
  * 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();
 }
 /**
  * Assert that success message present after create invoice.
  *
  * @param SalesOrderView $salesOrderView
  * @return void
  */
 public function processAssert(SalesOrderView $salesOrderView)
 {
     \PHPUnit_Framework_Assert::assertEquals(self::SUCCESS_CREATE_MESSAGE, $salesOrderView->getMessagesBlock()->getSuccessMessages());
 }
 /**
  * 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.');
 }
Example #15
0
 /**
  * Get order totals.
  *
  * @return array
  */
 public function getOrderTotals()
 {
     $totalsBlock = $this->orderView->getOrderTotalsBlock();
     return $this->getTypeBlockData($totalsBlock);
 }
Example #16
0
 /**
  * Click reorder.
  *
  * @return void
  */
 public function run()
 {
     $this->salesOrderView->getPageActions()->reorder();
 }