Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AssertGlobalSearchPreview.php
Go to the documentation of this file.
1 <?php
8 
10 use Magento\Backend\Test\Page\Adminhtml\Dashboard;
11 use Magento\Mtf\Constraint\AbstractConstraint;
12 
17 class AssertGlobalSearchPreview extends AbstractConstraint
18 {
26  public function processAssert(Dashboard $dashboard, GlobalSearch $search)
27  {
28  $types = ['Products', 'Customers', 'Orders', 'Pages'];
29  foreach ($types as $type) {
30  $this->adminSearchAssert($dashboard, $search, $type);
31  }
32  }
33 
41  private function adminSearchAssert($dashboard, $search, $type)
42  {
43  $adminSearchPreview = '"' . $search->getQuery() . '" in '. $type;
44  $isVisibleInResult = $dashboard->getAdminPanelHeader()->isAdminSearchPreviewVisible($adminSearchPreview, $type);
45  \PHPUnit\Framework\Assert::assertTrue(
46  $isVisibleInResult,
47  'Search Preview for ' . $type . ' is not in search results'
48  );
49  }
50 
56  public function toString()
57  {
58  return 'Search preview is present in search results';
59  }
60 }
processAssert(Dashboard $dashboard, GlobalSearch $search)
$type
Definition: item.phtml:13