Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
SalesCouponReportEntityTest.php
Go to the documentation of this file.
1 <?php
8 
9 use Magento\Reports\Test\Page\Adminhtml\SalesCouponReportView;
10 use Magento\Reports\Test\Page\Adminhtml\Statistics;
12 use Magento\Sales\Test\Page\Adminhtml\OrderIndex;
13 use Magento\Sales\Test\Page\Adminhtml\OrderInvoiceNew;
14 use Magento\Sales\Test\Page\Adminhtml\SalesOrderView;
15 use Magento\Mtf\TestCase\Injectable;
16 
33 class SalesCouponReportEntityTest extends Injectable
34 {
35  /* tags */
36  const MVP = 'no';
37  const STABLE = 'no';
38  /* end tags */
39 
45  protected $orderIndex;
46 
52  protected $orderInvoiceNew;
53 
60 
66  protected $salesOrderView;
67 
73  protected $reportStatistic;
74 
85  public function __inject(
86  OrderIndex $orderIndex,
87  OrderInvoiceNew $orderInvoiceNew,
88  SalesCouponReportView $salesCouponReportView,
89  SalesOrderView $salesOrderView,
90  Statistics $reportStatistic
91  ) {
92  $this->orderIndex = $orderIndex;
93  $this->orderInvoiceNew = $orderInvoiceNew;
94  $this->salesCouponReportView = $salesCouponReportView;
95  $this->salesOrderView = $salesOrderView;
96  $this->reportStatistic = $reportStatistic;
97  }
98 
106  public function test(OrderInjectable $order, array $viewsReport)
107  {
108  // Precondition
109  $order->persist();
110  $this->orderIndex->open();
111  $this->orderIndex->getSalesOrderGrid()->searchAndOpen(['id' => $order->getId()]);
112  $this->salesOrderView->getPageActions()->invoice();
113  $this->orderInvoiceNew->getTotalsBlock()->submit();
114  $this->reportStatistic->open();
115  $this->reportStatistic->getGridBlock()->massaction(
116  [['report' => 'Coupons']],
117  'Refresh Statistics for the Last Day',
118  true
119  );
120 
121  // Steps
122  $this->salesCouponReportView->open();
123  $ruleName = $order->getCouponCode()->getName();
124  if (isset($viewsReport['rules_list'])) {
125  $viewsReport['rules_list'] = str_replace('%rule_name%', $ruleName, $viewsReport['rules_list']);
126  }
127  $this->salesCouponReportView->getFilterBlock()->viewsReport($viewsReport);
128  $this->salesCouponReportView->getActionBlock()->showReport();
129  }
130 }
$order
Definition: order.php:55
__inject(OrderIndex $orderIndex, OrderInvoiceNew $orderInvoiceNew, SalesCouponReportView $salesCouponReportView, SalesOrderView $salesOrderView, Statistics $reportStatistic)