Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AssertWidgetOnProductPage.php
Go to the documentation of this file.
1 <?php
8 
10 use Magento\Catalog\Test\Page\Product\CatalogProductView;
12 use Magento\Mtf\Client\BrowserInterface;
13 use Magento\Mtf\Constraint\AbstractConstraint;
14 
18 class AssertWidgetOnProductPage extends AbstractConstraint
19 {
29  public function processAssert(
30  CatalogProductView $productView,
31  BrowserInterface $browser,
32  Widget $widget,
34  ) {
35  // Flush cache
36  $cache->flush();
37 
38  $urlKey = $widget->getWidgetInstance()[0]['entities']['url_key'];
39  $browser->open($_ENV['app_frontend_url'] . $urlKey . '.html');
40  $widgetText = $widget->getParameters()['link_text'];
41 
42  \PHPUnit\Framework\Assert::assertTrue(
43  $productView->getWidgetView()->isWidgetVisible($widget, $widgetText),
44  'Widget is absent on Product page.'
45  );
46  }
47 
53  public function toString()
54  {
55  return "Widget is present on Product page.";
56  }
57 }
processAssert(CatalogProductView $productView, BrowserInterface $browser, Widget $widget, Cache $cache)