Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AssertGlobalSearchCustomerName.php
Go to the documentation of this file.
1 <?php
8 
10 use Magento\Backend\Test\Page\Adminhtml\Dashboard;
11 use Magento\Customer\Test\Page\Adminhtml\CustomerIndex;
12 use Magento\Mtf\Constraint\AbstractConstraint;
13 
18 class AssertGlobalSearchCustomerName extends AbstractConstraint
19 {
28  public function processAssert(Dashboard $dashboard, GlobalSearch $search, CustomerIndex $customerIndex)
29  {
30  $customer = $search->getDataFieldConfig('query')['source']->getEntity();
31  $customerName = $customer->getFirstname() . " " . $customer->getLastname();
32  $isVisibleInResult = $dashboard->getAdminPanelHeader()->isSearchResultVisible($customerName);
33  \PHPUnit\Framework\Assert::assertTrue(
34  $isVisibleInResult,
35  'Customer name ' . $customerName . ' is absent in search results'
36  );
37 
38  $dashboard->getAdminPanelHeader()->navigateToGrid("Customers");
39  $isCustomerGridVisible = $customerIndex->getCustomerGridBlock()->isVisible();
40  \PHPUnit\Framework\Assert::assertTrue(
41  $isCustomerGridVisible,
42  'Customer grid is not visible'
43  );
44  \PHPUnit\Framework\Assert::assertContains(
45  (string) $customer->getId(),
46  $customerIndex->getCustomerGridBlock()->getAllIds(),
47  'Customer grid does not have ' . $customerName . ' in search results'
48  );
49  }
50 
56  public function toString()
57  {
58  return 'Customer name is present in search results';
59  }
60 }
$customer
Definition: customers.php:11
processAssert(Dashboard $dashboard, GlobalSearch $search, CustomerIndex $customerIndex)