/**
  * Sales coupon report
  *
  * @param OrderInjectable $order
  * @param array $viewsReport
  * @return void
  */
 public function test(OrderInjectable $order, array $viewsReport)
 {
     // Precondition
     $order->persist();
     $this->orderIndex->open();
     $this->orderIndex->getSalesOrderGrid()->searchAndOpen(['id' => $order->getId()]);
     $this->orderView->getPageActions()->invoice();
     $this->orderInvoiceNew->getTotalsBlock()->submit();
     $this->reportStatistic->open();
     $this->reportStatistic->getGridBlock()->massaction([['report' => 'Coupons']], 'Refresh Statistics for the Last Day', true);
     // Steps
     $this->salesCouponReportView->open();
     $ruleName = $order->getCouponCode()->getName();
     $viewsReport['rules_list'] = str_replace('%rule_name%', $ruleName, $viewsReport['rules_list']);
     $this->salesCouponReportView->getFilterBlock()->viewsReport($viewsReport);
     $this->salesCouponReportView->getActionBlock()->showReport();
 }
 /**
  * Assert that specified prices are actual on order, invoice and refund pages.
  *
  * @param array $prices
  * @param InjectableFixture $product
  * @param OrderIndex $orderIndex
  * @param SalesOrderView $salesOrderView
  * @param OrderInvoiceNew $orderInvoiceNew
  * @param OrderCreditMemoNew $orderCreditMemoNew
  * @return void
  */
 public function processAssert(array $prices, InjectableFixture $product, OrderIndex $orderIndex, SalesOrderView $salesOrderView, OrderInvoiceNew $orderInvoiceNew, OrderCreditMemoNew $orderCreditMemoNew)
 {
     $this->salesOrderView = $salesOrderView;
     $this->orderInvoiceNew = $orderInvoiceNew;
     $this->orderCreditMemoNew = $orderCreditMemoNew;
     $orderIndex->open();
     $orderIndex->getSalesOrderGrid()->openFirstRow();
     //Check prices on order page
     $actualPrices = [];
     $actualPrices = $this->getOrderPrices($actualPrices, $product);
     $actualPrices = $this->getOrderTotals($actualPrices);
     $prices = $this->preparePrices($prices);
     $message = 'Prices on order view page should be equal to defined in dataset.';
     \PHPUnit_Framework_Assert::assertEquals($prices, array_filter($actualPrices), $message);
     $salesOrderView->getPageActions()->invoice();
     //Check prices on invoice creation page
     $actualPrices = [];
     $actualPrices = $this->getInvoiceNewPrices($actualPrices, $product);
     $actualPrices = $this->getInvoiceNewTotals($actualPrices);
     $message = 'Prices on invoice new page should be equal to defined in dataset.';
     \PHPUnit_Framework_Assert::assertEquals($prices, array_filter($actualPrices), $message);
     $orderInvoiceNew->getTotalsBlock()->submit();
     //Check prices after invoice on order page
     $actualPrices = [];
     $actualPrices = $this->getOrderPrices($actualPrices, $product);
     $actualPrices = $this->getOrderTotals($actualPrices);
     $message = 'Prices on invoice page should be equal to defined in dataset.';
     \PHPUnit_Framework_Assert::assertEquals($prices, array_filter($actualPrices), $message);
     $salesOrderView->getPageActions()->orderCreditMemo();
     //Check prices on credit memo creation page
     $actualPrices = [];
     $actualPrices = $this->getCreditMemoNewPrices($actualPrices, $product);
     $actualPrices = $this->getCreditMemoNewTotals($actualPrices);
     $message = 'Prices on credit memo new page should be equal to defined in dataset.';
     \PHPUnit_Framework_Assert::assertEquals(array_diff_key($prices, ['shipping_excl_tax' => null, 'shipping_incl_tax' => null]), array_filter($actualPrices), $message);
     $orderCreditMemoNew->getFormBlock()->submit();
     //Check prices after refund on order page
     $actualPrices = [];
     $actualPrices = $this->getOrderPrices($actualPrices, $product);
     $actualPrices = $this->getOrderTotals($actualPrices);
     $message = 'Prices on credit memo page should be equal to defined in dataset.';
     \PHPUnit_Framework_Assert::assertEquals($prices, array_filter($actualPrices), $message);
 }