Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AssertCatalogSearchResult.php
Go to the documentation of this file.
1 <?php
8 
10 use Magento\CatalogSearch\Test\Page\AdvancedResult;
11 use Magento\Mtf\Constraint\AbstractConstraint;
12 
16 class AssertCatalogSearchResult extends AbstractConstraint
17 {
18  /* tags */
19  const SEVERITY = 'high';
20  /* end tags */
21 
29  public function processAssert(CatalogSearchQuery $catalogSearch, AdvancedResult $resultPage)
30  {
31  $product = $catalogSearch->getDataFieldConfig('query_text')['source']->getFirstProduct();
32 
33  do {
34  $isProductVisible = $resultPage->getListProductBlock()->getProductItem($product)->isVisible();
35  } while (!$isProductVisible && $resultPage->getBottomToolbar()->nextPage());
36 
37  \PHPUnit\Framework\Assert::assertTrue(
38  $isProductVisible,
39  "A product with name '" . $product->getName() . "' was not found."
40  );
41  }
42 
48  public function toString()
49  {
50  return 'Searched product has been successfully found.';
51  }
52 }
processAssert(CatalogSearchQuery $catalogSearch, AdvancedResult $resultPage)