Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AssertBIEssentialsLink.php
Go to the documentation of this file.
1 <?php
8 
9 use Magento\Mtf\Client\BrowserInterface;
10 use Magento\Mtf\Constraint\AbstractConstraint;
11 use Magento\Backend\Test\Page\Adminhtml\Dashboard;
12 
16 class AssertBIEssentialsLink extends AbstractConstraint
17 {
21  const MAX_TRY_COUNT = 2;
22 
28  protected $browser;
29 
40  public function processAssert(
41  BrowserInterface $browser,
42  $businessIntelligenceLink,
43  Dashboard $dashboard,
44  $menuItem,
45  $waitMenuItemNotVisible = false
46  ) {
53  $this->browser = $browser;
54  $count = 0;
55  $isVisible = false;
56  do {
57  try {
58  $this->browser->selectWindow();
59  $isVisible = $this->browser->waitUntil(function () use ($businessIntelligenceLink) {
60  return ($this->browser->getUrl() === $businessIntelligenceLink) ?: null;
61  });
62  break;
63  } catch (\Throwable $e) {
64  $dashboard->open();
65  $dashboard->getMenuBlock()->navigate($menuItem, $waitMenuItemNotVisible);
66  $count++;
67  }
68  } while ($count < self::MAX_TRY_COUNT);
69 
70  \PHPUnit\Framework\Assert::assertTrue(
71  $isVisible,
72  "BI Essentials Sign Up page was not opened by link.\n
73  Actual link is '{$this->browser->getUrl()}'\n
74  Expected link is '$businessIntelligenceLink'"
75  );
76  }
77 
83  public function toString()
84  {
85  return 'BI Essentials Sign Up page is opened by link';
86  }
87 }
$count
Definition: recent.phtml:13