Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AssertGroupedProductForm.php
Go to the documentation of this file.
1 <?php
8 
10 use Magento\Catalog\Test\Page\Adminhtml\CatalogProductEdit;
11 use Magento\Catalog\Test\Page\Adminhtml\CatalogProductIndex;
12 use Magento\Mtf\Fixture\FixtureInterface;
13 
18 {
19  /* tags */
20  const SEVERITY = 'low';
21  /* end tags */
22 
31  public function processAssert(
32  FixtureInterface $product,
33  CatalogProductIndex $productGrid,
34  CatalogProductEdit $productPage
35  ) {
36  $filter = ['sku' => $product->getSku()];
37  $productGrid->open()->getProductGrid()->searchAndOpen($filter);
38  $fieldsForm = $productPage->getProductForm()->getData($product);
39  $fieldsFixture = $this->prepareFixtureData($product->getData());
40  $fieldsFixture['associated'] = $this->prepareGroupedOptions($fieldsFixture['associated']);
41 
42  $errors = $this->verifyData($fieldsFixture, $fieldsForm);
43  \PHPUnit\Framework\Assert::assertEmpty($errors, $errors);
44  }
45 
52  protected function prepareGroupedOptions(array $fields)
53  {
54  $result = [];
55  foreach ($fields['assigned_products'] as $key => $item) {
56  $result['assigned_products'][$key]['name'] = $item['name'];
57  $result['assigned_products'][$key]['qty'] = $item['qty'];
58  }
59 
60  return $result;
61  }
62 }
$fields
Definition: details.phtml:14
verifyData(array $fixtureData, array $formData, $isStrict=false, $isPrepareError=true)
prepareFixtureData(array $data, array $sortFields=[])
processAssert(FixtureInterface $product, CatalogProductIndex $productGrid, CatalogProductEdit $productPage)
$errors
Definition: overview.phtml:9