/**
  * Assert that after applying changes, currency symbol changed on Catalog page.
  *
  * @param CmsIndex $cmsIndex
  * @param CatalogCategoryView $catalogCategoryView
  * @param CatalogProductSimple $product
  * @param CurrencySymbolEntity $currencySymbol
  * @return void
  */
 public function processAssert(CmsIndex $cmsIndex, CatalogCategoryView $catalogCategoryView, CatalogProductSimple $product, CurrencySymbolEntity $currencySymbol)
 {
     $categoryName = $product->getCategoryIds()[0];
     $cmsIndex->open();
     $cmsIndex->getCurrencyBlock()->switchCurrency($currencySymbol);
     $cmsIndex->getTopmenu()->selectCategory($categoryName);
     $price = $catalogCategoryView->getListProductBlock()->getPrice($product->getId());
     preg_match('`(.*?)\\d`', $price, $matches);
     $symbolOnPage = isset($matches[1]) ? $matches[1] : null;
     \PHPUnit_Framework_Assert::assertEquals($currencySymbol->getCustomCurrencySymbol(), $symbolOnPage, 'Wrong Currency Symbol is displayed on Category page.');
 }
 /**
  * Assert that banner presents on specific category page.
  *
  * @param CatalogProductSimple $product
  * @param CmsIndex $cmsIndex
  * @param Banner $banner
  * @param CatalogCategoryView $catalogCategoryView
  * @param Customer $customer[optional]
  * @param Cache $adminCache
  * @return void
  */
 public function processAssert(CatalogProductSimple $product, CmsIndex $cmsIndex, Banner $banner, CatalogCategoryView $catalogCategoryView, Customer $customer = null, Cache $adminCache)
 {
     // Flush cache
     $adminCache->open();
     $adminCache->getPageActions()->flushCacheStorage();
     $adminCache->getMessagesBlock()->waitSuccessMessage();
     if ($customer !== null) {
         $this->objectManager->create('Mage\\Customer\\Test\\TestStep\\LoginCustomerOnFrontendStep', ['customer' => $customer])->run();
     } else {
         $cmsIndex->open();
     }
     $cmsIndex->getTopmenu()->selectCategory($product->getCategoryIds()[0]);
     \PHPUnit_Framework_Assert::assertTrue($catalogCategoryView->getBannerViewBlock()->checkWidgetBanners($banner), 'Banner is absent on Category page.');
 }
 /**
  * Assert that event block is absent on category/product pages.
  *
  * @param CmsIndex $cmsIndex
  * @param CatalogCategoryView $catalogCategoryView
  * @param CatalogProductSimple $product
  * @param CatalogProductView $catalogProductView
  * @param Cache $adminCache
  * @return void
  */
 public function processAssert(CmsIndex $cmsIndex, CatalogCategoryView $catalogCategoryView, CatalogProductSimple $product, CatalogProductView $catalogProductView, Cache $adminCache)
 {
     // Flush cache
     $adminCache->open();
     $adminCache->getPageActions()->flushCacheStorage();
     $adminCache->getMessagesBlock()->waitSuccessMessage();
     $categoryName = $product->getCategoryIds()[0];
     $cmsIndex->open();
     $cmsIndex->getTopmenu()->selectCategory($categoryName);
     \PHPUnit_Framework_Assert::assertFalse($catalogCategoryView->getEventBlock()->isVisible(), "Event block is present on Category page.");
     $cmsIndex->open();
     $cmsIndex->getTopmenu()->selectCategory($categoryName);
     $catalogCategoryView->getListProductBlock()->openProductViewPage($product->getName());
     \PHPUnit_Framework_Assert::assertFalse($catalogProductView->getEventBlock()->isVisible(), "Event block is present on Product page.");
 }
 /**
  * Run delete Catalog Event test.
  *
  * @param CatalogProductSimple $product
  * @return void
  */
 public function test(CatalogProductSimple $product)
 {
     //Steps
     $this->catalogEventIndex->open();
     $this->catalogEventIndex->getEventGrid()->searchAndOpen(['category_name' => $product->getCategoryIds()[0]]);
     $this->catalogEventNew->getPageActions()->deleteAndAcceptAlert();
 }
 /**
  * Open product category.
  *
  * @param CatalogProductSimple $product
  * @return void
  */
 protected function openCategory(CatalogProductSimple $product)
 {
     $this->cmsIndex->open();
     $this->cmsIndex->getTopmenu()->selectCategory($product->getCategoryIds()[0]);
 }
 /**
  * Create product URL Rewrite.
  *
  * @param CatalogProductSimple $product
  * @param UrlRewrite $urlRewrite
  * @return array
  */
 public function test(CatalogProductSimple $product, UrlRewrite $urlRewrite)
 {
     //Prepare data for tearDown
     $this->urlRewrite = $urlRewrite;
     //Precondition
     $product->persist();
     //Steps
     $filter = ['id' => $product->getId(), 'name' => $product->getName(), 'sku' => $product->getSku()];
     $this->urlRewriteIndex->open();
     $this->urlRewriteIndex->getGridPageActionBlock()->addNew();
     $this->urlRewriteSelect->getSelectTypeForm()->fill($urlRewrite);
     $this->urlRewriteSelectTypeProduct->getProductGridBlock()->searchAndOpen($filter);
     $this->urlRewriteSelectTypeProductCategory->getCategoryTreeBlock()->selectCategory($product->getCategoryIds());
     $this->urlRewriteEdit->getEditForm()->fill($urlRewrite);
     $this->urlRewriteEdit->getFormPageActions()->save();
     return ['product' => $product];
 }