Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AssertGlobalSearchProductName.php
Go to the documentation of this file.
1 <?php
8 
10 use Magento\Backend\Test\Page\Adminhtml\Dashboard;
12 use Magento\Mtf\Constraint\AbstractConstraint;
13 
18 class AssertGlobalSearchProductName extends AbstractConstraint
19 {
27  public function processAssert(Dashboard $dashboard, GlobalSearch $search)
28  {
29  $entity = $search->getDataFieldConfig('query')['source']->getEntity();
30  $product = $entity instanceof OrderInjectable
31  ? $entity->getEntityId()['products'][0]
32  : $entity;
33  $productName = $product->getName();
34  $isVisibleInResult = $dashboard->getAdminPanelHeader()->isSearchResultVisible($productName);
35 
36  \PHPUnit\Framework\Assert::assertTrue(
37  $isVisibleInResult,
38  'Product name ' . $productName . ' is absent in search results'
39  );
40  }
41 
47  public function toString()
48  {
49  return 'Product name is present in search results';
50  }
51 }
$entity
Definition: element.phtml:22