/**
  * Create custom URL Rewrite.
  *
  * @param UrlRewrite $urlRewrite
  * @return void
  */
 public function test(UrlRewrite $urlRewrite)
 {
     $this->urlRewriteIndex->open();
     $this->urlRewriteIndex->getPageActionsBlock()->addNew();
     $this->urlRewriteEdit->getFormBlock()->fill($urlRewrite);
     $this->urlRewriteEdit->getPageMainActions()->save();
 }
 /**
  * Update category URL rewrites
  *
  * @param UrlRewrite $categoryRedirect
  * @param UrlRewrite $urlRewrite
  * @return void
  */
 public function test(UrlRewrite $categoryRedirect, UrlRewrite $urlRewrite)
 {
     //Steps
     $this->urlRewriteIndex->open();
     $filter = ['request_path' => $categoryRedirect->getRequestPath()];
     $this->urlRewriteIndex->getUrlRedirectGrid()->searchAndOpen($filter);
     $this->urlRewriteEdit->getFormBlock()->fill($urlRewrite);
     $this->urlRewriteEdit->getPageMainActions()->save();
 }
 /**
  * Delete CMS page rewrites entity.
  *
  * @param UrlRewrite $urlRewrite
  * @return void
  */
 public function test(UrlRewrite $urlRewrite)
 {
     // Precondition
     $urlRewrite->persist();
     // Steps
     $this->urlRewriteIndex->open();
     $this->urlRewriteIndex->getUrlRedirectGrid()->searchAndOpen(['request_path' => $urlRewrite->getRequestPath()]);
     $this->urlRewriteEdit->getPageMainActions()->delete();
 }
 /**
  * Test check create category rewrites
  *
  * @param UrlRewrite $urlRewrite
  * @param Category $category
  * @return void
  */
 public function test(UrlRewrite $urlRewrite, Category $category)
 {
     //Steps
     $this->urlRewriteIndex->open();
     $this->urlRewriteIndex->getPageActionsBlock()->addNew();
     $this->urlRewriteEdit->getFormBlock()->fill($urlRewrite);
     $this->urlRewriteEdit->getTreeBlock()->selectCategory($category);
     $this->urlRewriteEdit->getFormBlock()->fill($urlRewrite);
     $this->urlRewriteEdit->getPageMainActions()->save();
 }
 /**
  * Delete product url rewrites entity.
  *
  * @param UrlRewrite $productRedirect
  * @return void
  */
 public function test(UrlRewrite $productRedirect)
 {
     // Precondition
     $productRedirect->persist();
     // Steps
     $this->urlRewriteIndex->open();
     $filter = ['request_path' => $productRedirect->getRequestPath()];
     $this->urlRewriteIndex->getUrlRedirectGrid()->searchAndOpen($filter);
     $this->urlRewriteEdit->getPageMainActions()->delete();
     $this->urlRewriteEdit->getModalBlock()->acceptAlert();
 }
 /**
  * Update product URL rewrites
  *
  * @param UrlRewrite $urlRewrite
  * @param FixtureFactory $fixtureFactory
  * @return void
  */
 public function test(UrlRewrite $urlRewrite, FixtureFactory $fixtureFactory)
 {
     /** @var UrlRewrite $productRedirect */
     $productRedirect = $fixtureFactory->createByCode('urlRewrite', ['dataset' => 'default', 'data' => ['target_path' => $urlRewrite->getTargetPath()]]);
     $productRedirect->persist();
     //Steps
     $this->urlRewriteIndex->open();
     $filter = ['request_path' => $productRedirect->getRequestPath()];
     $this->urlRewriteIndex->getUrlRedirectGrid()->searchAndOpen($filter);
     $this->urlRewriteEdit->getFormBlock()->fill($urlRewrite);
     $this->urlRewriteEdit->getPageMainActions()->save();
 }
 /**
  * Update custom URL Rewrite.
  *
  * @param UrlRewrite $initialRewrite
  * @param UrlRewrite $urlRewrite
  * @return void
  */
 public function test(UrlRewrite $initialRewrite, UrlRewrite $urlRewrite)
 {
     //Precondition
     $initialRewrite->persist();
     //Steps
     $this->urlRewriteIndex->open();
     $filter = ['request_path' => $initialRewrite->getRequestPath()];
     $replaceData = $this->getReplaceData($urlRewrite);
     $this->urlRewriteIndex->getUrlRedirectGrid()->searchAndOpen($filter);
     $this->urlRewriteEdit->getFormBlock()->fill($urlRewrite, null, $replaceData);
     $this->urlRewriteEdit->getPageMainActions()->save();
 }
 /**
  * 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.");
 }
 /**
  * Create CMS page rewrites.
  *
  * @param UrlRewrite $urlRewrite
  * @return array
  */
 public function test(UrlRewrite $urlRewrite)
 {
     //Steps
     $this->urlRewriteIndex->open();
     $this->urlRewriteIndex->getPageActionsBlock()->addNew();
     $this->urlRewriteEdit->getUrlRewriteTypeSelectorBlock()->selectType($urlRewrite->getEntityType());
     $cmsPage = $urlRewrite->getDataFieldConfig('target_path')['source']->getEntity();
     $filter = ['title' => $cmsPage->getTitle()];
     $this->urlRewriteEdit->getCmsGridBlock()->searchAndOpen($filter);
     $this->urlRewriteEdit->getFormBlock()->fill($urlRewrite);
     $this->urlRewriteEdit->getPageMainActions()->save();
     return ['cmsPage' => $cmsPage];
 }
 /**
  * Delete category Url Rewrite
  *
  * @param UrlRewrite $urlRewrite
  * @return void
  */
 public function test(UrlRewrite $urlRewrite)
 {
     //Precondition
     $urlRewrite->persist();
     //Steps
     $this->urlRewriteIndex->open();
     if ($urlRewrite->getRequestPath()) {
         $filter = ['request_path' => $urlRewrite->getRequestPath()];
     } else {
         $filter = ['target_path' => $urlRewrite->getTargetPath()];
     }
     $this->urlRewriteIndex->getUrlRedirectGrid()->searchAndOpen($filter);
     $this->urlRewriteEdit->getPageMainActions()->delete();
 }
 /**
  * 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();
 }
 /**
  * Update CMS page rewrites.
  *
  * @param UrlRewrite $urlRewrite
  * @param UrlRewrite $cmsPageRewrite
  * @return array
  */
 public function test(UrlRewrite $urlRewrite, UrlRewrite $cmsPageRewrite)
 {
     // Preconditions
     $cmsPageRewrite->persist();
     // Steps
     $this->urlRewriteIndex->open();
     $this->storeName = $urlRewrite->getStoreId();
     $filter = ['request_path' => $cmsPageRewrite->getRequestPath()];
     $this->urlRewriteIndex->getUrlRedirectGrid()->searchAndOpen($filter);
     $this->urlRewriteEdit->getFormBlock()->fill($urlRewrite);
     $this->urlRewriteEdit->getPageMainActions()->save();
     return ['cmsPage' => $cmsPageRewrite->getDataFieldConfig('target_path')['source']->getEntity()];
 }
 /**
  * Assert that url rewrite category in grid
  *
  * @param Category $category
  * @param UrlRewriteIndex $urlRewriteIndex
  * @return void
  */
 public function processAssert(Category $category, UrlRewriteIndex $urlRewriteIndex)
 {
     $urlRewriteIndex->open();
     $filter = ['target_path' => strtolower($category->getUrlKey())];
     \PHPUnit_Framework_Assert::assertTrue($urlRewriteIndex->getUrlRedirectGrid()->isRowVisible($filter, true, false), 'URL Rewrite with request path "' . $category->getUrlKey() . '" is absent in grid.');
 }
 /**
  * Assert that url rewrite success message is displayed
  *
  * @param UrlRewriteIndex $index
  * @return void
  */
 public function processAssert(UrlRewriteIndex $index)
 {
     $actualMessage = $index->getMessagesBlock()->getSuccessMessage();
     \PHPUnit_Framework_Assert::assertEquals(self::SUCCESS_MESSAGE, $actualMessage, 'Wrong success message is displayed.' . "\nExpected: " . self::SUCCESS_MESSAGE . "\nActual: " . $actualMessage);
 }
 /**
  * Assert that url rewrite not in grid
  *
  * @param UrlRewriteIndex $urlRewriteIndex
  * @param UrlRewrite $productRedirect
  * @return void
  */
 public function processAssert(UrlRewriteIndex $urlRewriteIndex, UrlRewrite $productRedirect)
 {
     $urlRewriteIndex->open();
     $filter = ['request_path' => $productRedirect->getRequestPath()];
     \PHPUnit_Framework_Assert::assertFalse($urlRewriteIndex->getUrlRedirectGrid()->isRowVisible($filter), 'URL Rewrite with request path \'' . $productRedirect->getRequestPath() . '\' is present in grid.');
 }
 /**
  * Assert that category url rewrite not in grid
  *
  * @param UrlRewriteIndex $urlRewriteIndex
  * @param Category $category
  * @return void
  */
 public function processAssert(UrlRewriteIndex $urlRewriteIndex, Category $category)
 {
     $urlRewriteIndex->open();
     $filter = ['request_path' => $category->getUrlKey()];
     \PHPUnit_Framework_Assert::assertFalse($urlRewriteIndex->getUrlRedirectGrid()->isRowVisible($filter), "URL Rewrite with request path '{$category->getUrlKey()}' is present in grid.");
 }