Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AssertWidgetCmsPageLink.php
Go to the documentation of this file.
1 <?php
8 
10 use Magento\Cms\Test\Page\CmsIndex;
12 use Magento\Mtf\Constraint\AbstractConstraint;
13 
18 class AssertWidgetCmsPageLink extends AbstractConstraint
19 {
29  public function processAssert(
30  CmsIndex $cmsIndex,
31  Widget $widget,
33  ) {
34  // Flush cache
35  $cache->flush();
36 
37  $cmsIndex->open();
38  $widgetText = $widget->getParameters()['anchor_text'];
39  \PHPUnit\Framework\Assert::assertTrue(
40  $cmsIndex->getWidgetView()->isWidgetVisible($widget, $widgetText),
41  'Widget with type CmsPageLink is absent on Home page.'
42  );
43 
44  $title = isset($widget->getParameters()['node']) ?
45  $widget->getParameters()['entities'][0]->getLabel() :
46  $widget->getParameters()['entities'][0]->getContentHeading();
47  $cmsIndex->getWidgetView()->clickToWidget($widget, $widgetText);
48  $pageTitle = $cmsIndex->getCmsPageBlock()->getPageTitle();
49  \PHPUnit\Framework\Assert::assertEquals(
50  $title,
51  $pageTitle,
52  'Wrong page title on Cms page.'
53  );
54 
55  $cmsIndex->getFooterBlock()->openAdvancedSearch();
56  \PHPUnit\Framework\Assert::assertTrue(
57  $cmsIndex->getWidgetView()->isWidgetVisible($widget, $widgetText),
58  'Widget with type CmsPageLink is absent on Advanced Search page.'
59  );
60  }
61 
67  public function toString()
68  {
69  return "Widget with type CmsPageLink is present on Home page and on Advanced Search.";
70  }
71 }
$title
Definition: default.phtml:14