Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
SalesTaxReportEntityTest.php
Go to the documentation of this file.
1 <?php
8 
9 use Magento\Mtf\Fixture\FixtureFactory;
10 use Magento\Mtf\TestCase\Injectable;
11 use Magento\Reports\Test\Page\Adminhtml\SalesTaxReport;
12 use Magento\Reports\Test\Page\Adminhtml\Statistics;
14 use Magento\Sales\Test\Page\Adminhtml\OrderIndex;
15 use Magento\Sales\Test\Page\Adminhtml\OrderInvoiceNew;
16 use Magento\Sales\Test\Page\Adminhtml\SalesOrderView;
18 use Magento\Tax\Test\Page\Adminhtml\TaxRuleIndex;
19 use Magento\Tax\Test\Page\Adminhtml\TaxRuleNew;
20 
41 class SalesTaxReportEntityTest extends Injectable
42 {
43  /* tags */
44  const MVP = 'no';
45  /* end tags */
46 
52  protected $orderIndex;
53 
59  protected $orderInvoiceNew;
60 
66  protected $salesTaxReport;
67 
73  protected $salesOrderView;
74 
80  protected $reportStatistic;
81 
87  protected $taxRuleIndexPage;
88 
94  protected $taxRuleNewPage;
95 
101  protected $taxRule;
102 
108  private $fixtureFactory;
109 
115  public function __prepare()
116  {
117  $deleteTaxRule = $this->objectManager->create(\Magento\Tax\Test\TestStep\DeleteAllTaxRulesStep::class);
118  $deleteTaxRule->run();
119  }
120 
134  public function __inject(
135  OrderIndex $orderIndex,
136  OrderInvoiceNew $orderInvoiceNew,
137  SalesOrderView $salesOrderView,
138  Statistics $reportStatistic,
139  SalesTaxReport $salesTaxReport,
140  TaxRuleIndex $taxRuleIndexPage,
141  TaxRuleNew $taxRuleNewPage,
142  FixtureFactory $fixtureFactory
143  ) {
144  $this->orderIndex = $orderIndex;
145  $this->orderInvoiceNew = $orderInvoiceNew;
146  $this->salesOrderView = $salesOrderView;
147  $this->reportStatistic = $reportStatistic;
148  $this->salesTaxReport = $salesTaxReport;
149  $this->taxRuleIndexPage = $taxRuleIndexPage;
150  $this->taxRuleNewPage = $taxRuleNewPage;
151  $this->fixtureFactory = $fixtureFactory;
152  }
153 
163  public function test(
164  OrderInjectable $order,
165  TaxRule $taxRule,
166  array $report,
167  $orderSteps
168  ) {
169  // Precondition
170  $taxRule->persist();
171  $this->taxRule = $taxRule;
172  $order->persist();
173  $this->orderIndex->open();
174  $this->orderIndex->getSalesOrderGrid()->searchAndOpen(['id' => $order->getId()]);
175  $this->processOrder($orderSteps, $order);
176  $this->reportStatistic->open();
177  $this->reportStatistic->getGridBlock()->massaction(
178  [['report' => 'Tax']],
179  'Refresh Statistics for the Last Day',
180  true
181  );
182 
183  // Steps
184  $this->salesTaxReport->open();
185  $this->salesTaxReport->getFilterBlock()->viewsReport($report);
186  $this->salesTaxReport->getActionBlock()->showReport();
187  }
188 
196  protected function processOrder($orderSteps, OrderInjectable $order)
197  {
198  if ($orderSteps === '-') {
199  return;
200  }
201  $products = $order->getEntityId()['products'];
202  $cart['data']['items'] = ['products' => $products];
203  $cart = $this->fixtureFactory->createByCode('cart', $cart);
204  $orderStatus = explode(',', $orderSteps);
205  foreach ($orderStatus as $orderStep) {
206  $this->objectManager->create(
207  'Magento\Sales\Test\TestStep\\Create' . ucfirst(trim($orderStep)) . 'Step',
208  ['order' => $order, 'cart' => $cart]
209  )->run();
210  }
211  }
212 
218  public function tearDown()
219  {
220  $deleteTaxRule = $this->objectManager->create(\Magento\Tax\Test\TestStep\DeleteAllTaxRulesStep::class);
221  $deleteTaxRule->run();
222  }
223 }
$order
Definition: order.php:55
$orderStatus
Definition: order_status.php:9
__inject(OrderIndex $orderIndex, OrderInvoiceNew $orderInvoiceNew, SalesOrderView $salesOrderView, Statistics $reportStatistic, SalesTaxReport $salesTaxReport, TaxRuleIndex $taxRuleIndexPage, TaxRuleNew $taxRuleNewPage, FixtureFactory $fixtureFactory)
test(OrderInjectable $order, TaxRule $taxRule, array $report, $orderSteps)