Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AssertGroupedProductInItemsOrderedGrid.php
Go to the documentation of this file.
1 <?php
8 
10 use Magento\Sales\Test\Page\Adminhtml\OrderCreateIndex;
11 use Magento\Mtf\Constraint\AbstractConstraint;
12 
17 class AssertGroupedProductInItemsOrderedGrid extends AbstractConstraint
18 {
19  /* tags */
20  const SEVERITY = 'low';
21  /* end tags */
22 
28  protected $fields = ['name' => '', 'price' => '', 'checkout_data' => ['qty' => '']];
29 
36 
45  public function processAssert(OrderCreateIndex $orderCreateIndex, array $products)
46  {
47  if (empty($products)) {
48  throw new \Exception("No products");
49  }
50  $data = $this->prepareData($products, $orderCreateIndex->getCreateBlock()->getItemsBlock());
51 
52  \PHPUnit\Framework\Assert::assertEquals(
53  $data['fixtureData'],
54  $data['pageData'],
55  'Grouped product data on order create page not equals to passed from fixture.'
56  );
57  }
58 
66  protected function prepareData(array $data, Items $itemsBlock)
67  {
68  $fixtureData = [];
69  foreach ($data as $product) {
70  $products = $product->getAssociated()['products'];
71  foreach ($products as $key => $value) {
72  $fixtureData[$key]['name'] = $value->getName();
73  $fixtureData[$key]['price'] = number_format($value->getPrice(), 2);
74  }
75  $options = $product->getCheckoutData()['options'];
76  foreach ($options as $key => $option) {
77  $fixtureData[$key]['checkout_data']['qty'] = $option['qty'];
78  }
79  }
80  $pageData = $itemsBlock->getProductsDataByFields($this->fields);
81 
82  return ['fixtureData' => $fixtureData, 'pageData' => $pageData];
83  }
84 
90  public function toString()
91  {
92  return 'Product is added to Items Ordered grid from "Last Ordered Items" section on Order creation page.';
93  }
94 }
$value
Definition: gender.phtml:16