/**
  * Flush cache storage and assert success message.
  *
  * @return void
  */
 protected function flushCacheStorageWithAssert()
 {
     $this->cachePage->open();
     $this->cachePage->getActionsBlock()->flushCacheStorage();
     $this->cachePage->getModalBlock()->acceptAlert();
     \PHPUnit_Framework_Assert::assertTrue($this->cachePage->getActionsBlock()->isStorageCacheFlushed(), 'Cache is not flushed.');
 }
 /**
  * Assert Flush Static Files Cache button visibility.
  *
  * @param AdminCache $adminCache
  * @return void
  */
 public function processAssert(AdminCache $adminCache)
 {
     if ($_ENV['mage_mode'] === 'production') {
         \PHPUnit_Framework_Assert::assertFalse($adminCache->getAdditionalBlock()->isFlushCacheButtonVisible(self::FLUSH_STATIC_FILES_CACHE), self::FLUSH_STATIC_FILES_CACHE . ' button should not be visible in production mode.');
     } else {
         \PHPUnit_Framework_Assert::assertTrue($adminCache->getAdditionalBlock()->isFlushCacheButtonVisible(self::FLUSH_STATIC_FILES_CACHE), self::FLUSH_STATIC_FILES_CACHE . ' button should be visible in developer or default mode.');
     }
 }
 /**
  * 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 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.');
 }
 /**
  * Open admin cache management page and click button to flush cache.
  *
  * @param AdminCache $adminCache
  * @param string $flushButtonName
  * @return void
  */
 public function test(AdminCache $adminCache, $flushButtonName)
 {
     /**
      * Skip test for 'Flush Static Files Cache' in production mode.
      */
     if ($flushButtonName === 'Flush Static Files Cache' && $_ENV['mage_mode'] === 'production') {
         $this->markTestSkipped('Skip flushing static files cache test when in production mode.');
     }
     $adminCache->open();
     $adminCache->getAdditionalBlock()->clickFlushCache($flushButtonName);
 }
 /**
  * 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 product review available on product page.
  *
  * @param CatalogProductView $catalogProductView
  * @param Review $review
  * @param FixtureInterface $product
  * @param BrowserInterface $browser
  * @param AdminCache $cachePage
  * @return void
  */
 public function processAssert(CatalogProductView $catalogProductView, Review $review, FixtureInterface $product, BrowserInterface $browser, AdminCache $cachePage)
 {
     $errors = [];
     $cachePage->open()->getActionsBlock()->flushMagentoCache();
     $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html');
     $reviewBlock = $catalogProductView->getCustomerReviewBlock();
     $catalogProductView->getViewBlock()->selectTab('Reviews');
     \PHPUnit_Framework_Assert::assertContains(sprintf("You're reviewing:\n%s", $product->getName()), $catalogProductView->getReviewFormBlock()->getLegend()->getText());
     foreach ($review->getData() as $name => $value) {
         $reviewValue = $reviewBlock->getFieldValue($name);
         if ($reviewValue !== null && 0 !== strcasecmp($value, trim($reviewValue))) {
             $errors[] = '- field "' . $name . '" is not equals submitted one, error value "' . $value . '"';
         }
     }
     \PHPUnit_Framework_Assert::assertEmpty($errors, 'The Review contains the following errors:' . PHP_EOL . implode(PHP_EOL, $errors));
 }
 /**
  * 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.");
 }
 /**
  * Check 'Flush Static Files Cache' not visible in production mode.
  *
  *
  * @param AdminCache $adminCache
  * @return void
  */
 public function test(AdminCache $adminCache)
 {
     $adminCache->open();
 }
 /**
  * Assert that success message is displayed after 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.');
 }