/**
  * Assert that message from dataSet is displayed for each items on order(s) view page on frontend
  *
  * @param GiftMessage $giftMessage
  * @param Customer $customer
  * @param OrderHistory $orderHistory
  * @param CustomerOrderView $customerOrderView
  * @param CustomerAccountLogout $customerAccountLogout
  * @param string $orderId
  * @param array $products
  * @return void
  */
 public function processAssert(GiftMessage $giftMessage, Customer $customer, OrderHistory $orderHistory, CustomerOrderView $customerOrderView, CustomerAccountLogout $customerAccountLogout, $orderId, $products = [])
 {
     $this->objectManager->create('Magento\\Customer\\Test\\TestStep\\LoginCustomerOnFrontendStep', ['customer' => $customer])->run();
     $expectedData = ['sender' => $giftMessage->getSender(), 'recipient' => $giftMessage->getRecipient(), 'message' => $giftMessage->getMessage()];
     $orderHistory->open();
     $orderHistory->getOrderHistoryBlock()->openOrderById($orderId);
     foreach ($products as $key => $product) {
         if ($giftMessage->hasData('items')) {
             $itemGiftMessage = $giftMessage->getItems()[$key];
             $expectedData = ['sender' => $itemGiftMessage->getSender(), 'recipient' => $itemGiftMessage->getRecipient(), 'message' => $itemGiftMessage->getMessage()];
         }
         \PHPUnit_Framework_Assert::assertEquals($expectedData, $customerOrderView->getGiftMessageForItemBlock()->getGiftMessage($product->getName()), 'Wrong gift message is displayed on "' . $product->getName() . '" item.');
     }
     $customerAccountLogout->open();
 }
 /**
  * Assert that message from dataset is displayed on order(s) view page on frontend.
  *
  * @param GiftMessage $giftMessage
  * @param Customer $customer
  * @param OrderHistory $orderHistory
  * @param CustomerOrderView $customerOrderView
  * @param CustomerAccountLogout $customerAccountLogout
  * @param string $orderId
  * @return void
  */
 public function processAssert(GiftMessage $giftMessage, Customer $customer, OrderHistory $orderHistory, CustomerOrderView $customerOrderView, CustomerAccountLogout $customerAccountLogout, $orderId)
 {
     $this->objectManager->create('Magento\\Customer\\Test\\TestStep\\LoginCustomerOnFrontendStep', ['customer' => $customer])->run();
     $expectedData = ['sender' => $giftMessage->getSender(), 'recipient' => $giftMessage->getRecipient(), 'message' => $giftMessage->getMessage()];
     $orderHistory->open();
     $orderHistory->getOrderHistoryBlock()->openOrderById($orderId);
     \PHPUnit_Framework_Assert::assertEquals($expectedData, $customerOrderView->getGiftMessageForOrderBlock()->getGiftMessage(), 'Wrong gift message is displayed on order.');
     $customerAccountLogout->open();
 }
 /**
  * Assert order is not visible in customer account on frontend
  *
  * @param OrderInjectable $order
  * @param Customer $customer
  * @param CustomerAccountIndex $customerAccountIndex
  * @param OrderHistory $orderHistory
  * @param string $status
  * @return void
  */
 public function processAssert(OrderInjectable $order, Customer $customer, CustomerAccountIndex $customerAccountIndex, OrderHistory $orderHistory, $status)
 {
     $filter = ['id' => $order->getId(), 'status' => $status];
     $this->objectManager->create('Magento\\Customer\\Test\\TestStep\\LoginCustomerOnFrontendStep', ['customer' => $customer])->run();
     $customerAccountIndex->getAccountMenuBlock()->openMenuItem('My Orders');
     \PHPUnit_Framework_Assert::assertFalse($orderHistory->getOrderHistoryBlock()->isVisible() && $orderHistory->getOrderHistoryBlock()->isOrderVisible($filter), 'Order with following data \'' . implode(', ', $filter) . '\' is present in Orders block on frontend.');
 }
 /**
  * Assert that order is present in Orders grid on frontend.
  *
  * @param OrderInjectable $order
  * @param Customer $customer
  * @param ObjectManager $objectManager
  * @param CustomerAccountIndex $customerAccountIndex
  * @param OrderHistory $orderHistory
  * @param string $status
  * @param string $orderId
  * @param string|null $statusToCheck
  * @return void
  */
 public function processAssert(OrderInjectable $order, Customer $customer, ObjectManager $objectManager, CustomerAccountIndex $customerAccountIndex, OrderHistory $orderHistory, $status, $orderId = '', $statusToCheck = null)
 {
     $filter = ['id' => $order->hasData('id') ? $order->getId() : $orderId, 'status' => $statusToCheck === null ? $status : $statusToCheck];
     $objectManager->create('Magento\\Customer\\Test\\TestStep\\LoginCustomerOnFrontendStep', ['customer' => $customer])->run();
     $customerAccountIndex->getAccountMenuBlock()->openMenuItem('My Orders');
     $errorMessage = implode(', ', $filter);
     \PHPUnit_Framework_Assert::assertTrue($orderHistory->getOrderHistoryBlock()->isOrderVisible($filter), 'Order with following data \'' . $errorMessage . '\' is absent in Orders block on frontend.');
 }
 /**
  * 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());
     }
 }
 /**
  * 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());
     }
 }