/**
  * Assert Cache is Invalidated and Refreshable.
  *
  * @param AdminCache $adminCache
  * @param array $cacheTags
  * @return void
  */
 public function processAssert(AdminCache $adminCache, $cacheTags)
 {
     $items = [];
     foreach ($cacheTags as $cacheTag) {
         $items[] = ['tags' => $cacheTag, 'status' => 'Invalidated'];
     }
     $adminCache->open();
     $adminCache->getGridBlock()->massaction($items, 'Refresh');
     \PHPUnit_Framework_Assert::assertEquals(sprintf(self::SUCCESS_MESSAGE, count($items)), $adminCache->getMessagesBlock()->getSuccessMessage(), 'Cache is Invalid and refreshable.');
 }
 /**
  * Assert that created widget is absent on frontend on Home page
  *
  * @param CmsIndex $cmsIndex
  * @param Widget $widget
  * @param AdminCache $adminCache
  * @return void
  */
 public function processAssert(CmsIndex $cmsIndex, Widget $widget, AdminCache $adminCache)
 {
     // Flush cache
     $adminCache->open();
     $adminCache->getActionsBlock()->flushMagentoCache();
     $adminCache->getMessagesBlock()->waitSuccessMessage();
     $cmsIndex->open();
     $widgetText = $widget->getParameters()['anchor_text'];
     \PHPUnit_Framework_Assert::assertFalse($cmsIndex->getWidgetView()->isWidgetVisible($widget, $widgetText), 'Widget is present on Home page.');
 }
 /**
  * Assert that created widget displayed on frontend on Product page.
  *
  * @param CatalogProductView $productView
  * @param BrowserInterface $browser
  * @param Widget $widget
  * @param AdminCache $adminCache
  * @return void
  */
 public function processAssert(CatalogProductView $productView, BrowserInterface $browser, Widget $widget, AdminCache $adminCache)
 {
     // Flush cache
     $adminCache->open();
     $adminCache->getActionsBlock()->flushMagentoCache();
     $adminCache->getMessagesBlock()->waitSuccessMessage();
     $urlKey = $widget->getWidgetInstance()[0]['entities']['url_key'];
     $browser->open($_ENV['app_frontend_url'] . $urlKey . '.html');
     $widgetText = $widget->getParameters()['link_text'];
     \PHPUnit_Framework_Assert::assertTrue($productView->getWidgetView()->isWidgetVisible($widget, $widgetText), 'Widget is absent on Product page.');
 }
 /**
  * Assert that after click on widget link on frontend system redirects you to Product page defined in widget.
  *
  * @param CmsIndex $cmsIndex
  * @param CatalogProductView $productView
  * @param Widget $widget
  * @param AdminCache $adminCache
  * @return void
  */
 public function processAssert(CmsIndex $cmsIndex, CatalogProductView $productView, Widget $widget, AdminCache $adminCache)
 {
     // Flush cache
     $adminCache->open();
     $adminCache->getActionsBlock()->flushMagentoCache();
     $adminCache->getMessagesBlock()->waitSuccessMessage();
     $cmsIndex->open();
     $cmsIndex->getTopmenu()->selectCategoryByName($widget->getWidgetInstance()[0]['entities']->getName());
     $cmsIndex->getWidgetView()->clickToWidget($widget, $widget->getParameters()['anchor_text']);
     $title = $productView->getTitleBlock()->getTitle();
     \PHPUnit_Framework_Assert::assertEquals($widget->getParameters()['entities'][0]->getName(), $title, 'Wrong product title.');
 }
 /**
  * Assert that created widget displayed on frontend on Home page and on Advanced Search and
  * after click on widget link on frontend system redirects you to catalog page.
  *
  * @param CmsIndex $cmsIndex
  * @param CatalogCategoryView $categoryView
  * @param Widget $widget
  * @param AdminCache $adminCache
  * @return void
  */
 public function processAssert(CmsIndex $cmsIndex, CatalogCategoryView $categoryView, Widget $widget, AdminCache $adminCache)
 {
     // Flush cache
     $adminCache->open();
     $adminCache->getActionsBlock()->flushMagentoCache();
     $adminCache->getMessagesBlock()->waitSuccessMessage();
     $cmsIndex->open();
     $widgetText = $widget->getParameters()['anchor_text'];
     \PHPUnit_Framework_Assert::assertTrue($cmsIndex->getWidgetView()->isWidgetVisible($widget, $widgetText), 'Widget with type catalog category link is absent on Home page.');
     $cmsIndex->getWidgetView()->clickToWidget($widget, $widgetText);
     $title = $categoryView->getTitleBlock()->getTitle();
     \PHPUnit_Framework_Assert::assertEquals($widget->getParameters()['entities'][0]->getName(), $title, 'Wrong category title.');
     $cmsIndex->getFooterBlock()->openAdvancedSearch();
     \PHPUnit_Framework_Assert::assertTrue($cmsIndex->getWidgetView()->isWidgetVisible($widget, $widgetText), 'Widget with type catalog category link is absent on Advanced Search page.');
 }
 /**
  * Assert that created widget displayed on frontent on Home page and on Advanced Search and
  * after click on widget link on frontend system redirects you to cms page.
  *
  * @param CmsIndex $cmsIndex
  * @param Widget $widget
  * @param AdminCache $adminCache
  * @return void
  */
 public function processAssert(CmsIndex $cmsIndex, Widget $widget, AdminCache $adminCache)
 {
     // Flush cache
     $adminCache->open();
     $adminCache->getActionsBlock()->flushMagentoCache();
     $adminCache->getMessagesBlock()->waitSuccessMessage();
     $cmsIndex->open();
     $widgetText = $widget->getParameters()['anchor_text'];
     \PHPUnit_Framework_Assert::assertTrue($cmsIndex->getWidgetView()->isWidgetVisible($widget, $widgetText), 'Widget with type CmsPageLink is absent on Home page.');
     $title = isset($widget->getParameters()['node']) ? $widget->getParameters()['entities'][0]->getLabel() : $widget->getParameters()['entities'][0]->getContentHeading();
     $cmsIndex->getWidgetView()->clickToWidget($widget, $widgetText);
     $pageTitle = $cmsIndex->getCmsPageBlock()->getPageTitle();
     \PHPUnit_Framework_Assert::assertEquals($title, $pageTitle, 'Wrong page title on Cms page.');
     $cmsIndex->getFooterBlock()->openAdvancedSearch();
     \PHPUnit_Framework_Assert::assertTrue($cmsIndex->getWidgetView()->isWidgetVisible($widget, $widgetText), 'Widget with type CmsPageLink is absent on Advanced Search page.');
 }
 /**
  * Assert that widget with type Recently Viewed Products is present on category page
  *
  * @param CmsIndex $cmsIndex
  * @param AdminCache $adminCache
  * @param CatalogCategoryView $catalogCategoryView
  * @param BrowserInterface $browser
  * @param CatalogProductSimple $productSimple
  * @param Category $category
  * @param Customer $customer
  * @return void
  */
 public function processAssert(CmsIndex $cmsIndex, AdminCache $adminCache, CatalogCategoryView $catalogCategoryView, BrowserInterface $browser, CatalogProductSimple $productSimple, Category $category, Customer $customer)
 {
     $this->browser = $browser;
     $this->cmsIndex = $cmsIndex;
     $this->catalogCategoryView = $catalogCategoryView;
     // Flush cache
     $adminCache->open();
     $adminCache->getActionsBlock()->flushMagentoCache();
     $adminCache->getMessagesBlock()->waitSuccessMessage();
     // Log in customer
     $customer->persist();
     $this->objectManager->create('Magento\\Customer\\Test\\TestStep\\LoginCustomerOnFrontendStep', ['customer' => $customer])->run();
     // Open products
     $productSimple->persist();
     $category->persist();
     $this->browser->open($_ENV['app_frontend_url'] . $productSimple->getUrlKey() . '.html');
     $this->checkRecentlyViewedBlockOnCategory($productSimple, $category);
 }
 /**
  * Assert that widget with type Recently Compared Products is present on Product Compare page
  *
  * @param CatalogProductCompare $catalogProductCompare
  * @param CmsIndex $cmsIndex
  * @param CatalogProductView $catalogProductView
  * @param BrowserInterface $browser
  * @param Widget $widget
  * @param CatalogProductSimple $productSimple1
  * @param CatalogProductSimple $productSimple2
  * @param AdminCache $adminCache
  * @var string
  * @return void
  */
 public function processAssert(CatalogProductCompare $catalogProductCompare, CmsIndex $cmsIndex, CatalogProductView $catalogProductView, BrowserInterface $browser, Widget $widget, CatalogProductSimple $productSimple1, CatalogProductSimple $productSimple2, AdminCache $adminCache)
 {
     // Flush cache
     $adminCache->open();
     $adminCache->getActionsBlock()->flushMagentoCache();
     $adminCache->getMessagesBlock()->waitSuccessMessage();
     $this->catalogProductCompare = $catalogProductCompare;
     $this->catalogProductView = $catalogProductView;
     $this->browser = $browser;
     $this->cmsIndex = $cmsIndex;
     $productSimple1->persist();
     $products[] = $productSimple1;
     $productSimple2->persist();
     $products[] = $productSimple2;
     $cmsIndex->open();
     $this->addProducts($products);
     $this->removeCompareProducts();
     \PHPUnit_Framework_Assert::assertTrue($this->catalogProductCompare->getWidgetView()->isWidgetVisible($widget, 'Recently Compared'), 'Widget is absent on Product Compare page.');
 }
 /**
  * Assert that created widget displayed on frontent in Catalog.
  *
  * @param CmsIndex $cmsIndex
  * @param CatalogCategoryView $catalogCategoryView
  * @param Widget $widget
  * @param AdminCache $adminCache
  * @return void
  */
 public function processAssert(CmsIndex $cmsIndex, CatalogCategoryView $catalogCategoryView, Widget $widget, AdminCache $adminCache)
 {
     // Flush cache
     $adminCache->open();
     $adminCache->getActionsBlock()->flushMagentoCache();
     $adminCache->getMessagesBlock()->waitSuccessMessage();
     $cmsIndex->open();
     if (isset($widget->getWidgetInstance()[0]['entities'])) {
         $categoryName = $widget->getWidgetInstance()[0]['entities']->getName();
     } else {
         $categoryName = $widget->getParameters()['entities']->getCategoyId()[0];
     }
     if ($widget->getCode() == 'CMS Static Block') {
         $widgetText = $widget->getParameters()['entities'][0]->getContent();
     } else {
         $widgetText = $widget->getParameters()['anchor_text'];
     }
     $cmsIndex->getTopmenu()->selectCategoryByName($categoryName);
     \PHPUnit_Framework_Assert::assertTrue($catalogCategoryView->getWidgetView()->isWidgetVisible($widget, $widgetText), 'Widget is absent on Category page.');
 }
 /**
  * Assert that locale options can be changed and checks new text on index page.
  *
  * @param SystemConfig $systemConfig
  * @param Store $store
  * @param CmsIndex $cmsIndex
  * @param AdminCache $adminCache
  * @param string $locale
  * @param string $welcomeText
  */
 public function processAssert(SystemConfig $systemConfig, Store $store, CmsIndex $cmsIndex, AdminCache $adminCache, $locale, $welcomeText)
 {
     // Set locale options
     $systemConfig->open();
     $systemConfig->getPageActions()->selectStore($store->getGroupId() . "/" . $store->getName());
     $systemConfig->getModalBlock()->acceptAlert();
     $configGroup = $systemConfig->getForm()->getGroup('general', 'locale', 'code');
     $configGroup->setValue('general', 'locale', 'code', $locale);
     $systemConfig->getPageActions()->save();
     $systemConfig->getMessagesBlock()->waitSuccessMessage();
     // Flush cache
     $adminCache->open();
     $adminCache->getActionsBlock()->flushMagentoCache();
     $adminCache->getMessagesBlock()->waitSuccessMessage();
     // Check presents income text on index page
     $cmsIndex->open();
     if ($cmsIndex->getFooterBlock()->isStoreGroupSwitcherVisible() && $cmsIndex->getFooterBlock()->isStoreGroupVisible($store)) {
         $cmsIndex->getFooterBlock()->selectStoreGroup($store);
     }
     $cmsIndex->getStoreSwitcherBlock()->selectStoreView($store->getName());
     \PHPUnit_Framework_Assert::assertTrue($cmsIndex->getSearchBlock()->isPlaceholderContains($welcomeText), "Locale not applied.");
 }
 /**
  * Assert success message for cache flush.
  *
  * @param AdminCache $adminCache
  * @param string $successMessage
  * @return void
  */
 public function processAssert(AdminCache $adminCache, $successMessage)
 {
     \PHPUnit_Framework_Assert::assertEquals($successMessage, $adminCache->getMessagesBlock()->getSuccessMessage(), 'Action is not successful.');
 }