/**
  * Assert that product url in url rewrite grid.
  *
  * @param CatalogProductSimple $product
  * @param CatalogProductSimple $initialProduct
  * @param UrlRewriteIndex $urlRewriteIndex
  * @return void
  */
 public function processAssert(CatalogProductSimple $product, CatalogProductSimple $initialProduct, UrlRewriteIndex $urlRewriteIndex)
 {
     $urlRewriteIndex->open();
     $category = $product->getDataFieldConfig('category_ids')['source']->getCategories()[0];
     $targetPath = "catalog/product/view/id/{$initialProduct->getId()}/category/{$category->getId()}";
     $url = strtolower($product->getCategoryIds()[0] . '/' . $product->getUrlKey());
     $filter = ['request_path' => $url, 'target_path' => $targetPath];
     \PHPUnit_Framework_Assert::assertTrue($urlRewriteIndex->getUrlRedirectGrid()->isRowVisible($filter, true, false), "URL Rewrite with request path '{$url}' is absent in grid.");
     $categoryInitial = $initialProduct->getDataFieldConfig('category_ids')['source']->getCategories()[0];
     $targetPath = "catalog/product/view/id/{$initialProduct->getId()}/category/{$categoryInitial->getId()}";
     \PHPUnit_Framework_Assert::assertFalse($urlRewriteIndex->getUrlRedirectGrid()->isRowVisible(['target_path' => $targetPath], true, false), "URL Rewrite with target path '{$targetPath}' is present in grid.");
 }
 /**
  * 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()->selectCategoryByName($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.');
 }
 /**
  * Create product URL Rewrite.
  *
  * @param CatalogProductSimple $product
  * @param UrlRewrite $urlRewrite
  * @return void
  */
 public function test(CatalogProductSimple $product, UrlRewrite $urlRewrite)
 {
     //Precondition
     $product->persist();
     $filter = ['id' => $product->getId()];
     //Steps
     $this->urlRewriteIndex->open();
     $this->urlRewriteIndex->getPageActionsBlock()->addNew();
     $this->urlRewriteEdit->getFormBlock()->fill($urlRewrite);
     $this->urlRewriteEdit->getProductGridBlock()->searchAndOpen($filter);
     $category = $product->hasData('category_ids') ? $product->getDataFieldConfig('category_ids')['source']->getCategories()[0] : null;
     $this->urlRewriteEdit->getTreeBlock()->selectCategory($category);
     $this->urlRewriteEdit->getFormBlock()->fill($urlRewrite);
     $this->urlRewriteEdit->getPageMainActions()->save();
 }
 /**
  * Create product URL Rewrite
  *
  * @param CatalogProductSimple $product
  * @param UrlRewrite $urlRewrite
  * @return void
  */
 public function testProductUrlRewrite(CatalogProductSimple $product, UrlRewrite $urlRewrite)
 {
     //Precondition
     $product->persist();
     $filter = ['id' => $product->getId()];
     //Steps
     $this->urlRewriteIndex->open();
     $this->urlRewriteIndex->getPageActionsBlock()->addNew();
     $this->urlRewriteEdit->getUrlRewriteTypeSelectorBlock()->selectType('For product');
     $this->urlRewriteEdit->getProductGridBlock()->searchAndOpen($filter);
     $this->urlRewriteEdit->getTreeBlock()->skipCategorySelection();
     $this->urlRewriteEdit->getFormBlock()->fill($urlRewrite);
     $this->urlRewriteEdit->getPageMainActions()->save();
 }