Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AssertChildProductsInGrid.php
Go to the documentation of this file.
1 <?php
8 
9 use Magento\Catalog\Test\Page\Adminhtml\CatalogProductIndex;
11 use Magento\Mtf\Constraint\AbstractConstraint;
12 
17 class AssertChildProductsInGrid extends AbstractConstraint
18 {
22  const NOT_VISIBLE_INDIVIDUALLY = 'Not Visible Individually';
23 
31  public function processAssert(CatalogProductIndex $productGrid, ConfigurableProduct $product)
32  {
33  $configurableAttributesData = $product->getConfigurableAttributesData();
34  $errors = [];
35 
36  $productGrid->open();
37  foreach ($configurableAttributesData['matrix'] as $variation) {
38  $filter = [
39  'name' => $variation['name'],
40  'type' => (isset($variation['weight']) && (int)$variation['weight'] > 0)
41  ? 'Simple Product' : 'Virtual Product',
42  'sku' => $variation['sku'],
43  'visibility' => self::NOT_VISIBLE_INDIVIDUALLY,
44  ];
45 
46  if (!$productGrid->getProductGrid()->isRowVisible($filter)) {
47  $errors[] = sprintf(
48  'Child product with name: "%s" and sku:"%s" is absent in grid.',
49  $filter['name'],
50  $filter['sku']
51  );
52  }
53  }
54 
55  \PHPUnit\Framework\Assert::assertEmpty($errors, implode(' ', $errors));
56  }
57 
63  public function toString()
64  {
65  return 'Child products generated during configurable product are present in products grid.';
66  }
67 }
processAssert(CatalogProductIndex $productGrid, ConfigurableProduct $product)
$configurableAttributesData
$errors
Definition: overview.phtml:9