/**
  * Delete custom URL Rewrite test.
  *
  * @param UrlRewrite $urlRewrite
  * @return void
  */
 public function test(UrlRewrite $urlRewrite)
 {
     // Precondition
     $urlRewrite->persist();
     // Steps
     $this->urlRewriteIndex->open();
     $filter = ['request_path' => $urlRewrite->getIdentifier()];
     $this->urlRewriteIndex->getUrlRedirectGrid()->searchAndOpen($filter);
     $this->urlRewriteEdit->getFormPageActions()->deleteAndAcceptAlert();
 }
 /**
  * Create product URL Rewrite.
  *
  * @param UrlRewrite $urlRewrite
  * @return void
  */
 public function test(UrlRewrite $urlRewrite)
 {
     //Prepare data for tearDown
     $this->urlRewrite = $urlRewrite;
     //Precondition
     $product = $urlRewrite->getDataFieldConfig('target_path')['source']->getEntity();
     //Steps
     $this->urlRewriteIndex->open();
     $this->urlRewriteIndex->getGridPageActionBlock()->addNew();
     $this->urlRewriteSelect->getSelectTypeForm()->fill($urlRewrite);
     $this->urlRewriteSelectTypeProduct->getProductGridBlock()->searchAndOpen(['id' => $product->getId()]);
     $this->urlRewriteSelectTypeProductCategory->getCategoryTreeBlock()->skipCategorySelection();
     $this->urlRewriteEdit->getEditForm()->fill($urlRewrite);
     $this->urlRewriteEdit->getFormPageActions()->save();
 }
 /**
  * Run update product URL rewrite test.
  *
  * @param UrlRewrite $urlRewriteOrigin
  * @param UrlRewrite $urlRewrite
  * @return array
  */
 public function test(UrlRewrite $urlRewriteOrigin, UrlRewrite $urlRewrite)
 {
     //Preconditions
     $urlRewriteOrigin->persist();
     //Steps
     $this->urlRewriteIndex->open();
     $filter = ['request_path' => $urlRewriteOrigin->getIdentifier()];
     $this->urlRewriteIndex->getUrlRedirectGrid()->searchAndOpen($filter);
     $this->urlRewriteEdit->getEditForm()->fill($urlRewrite);
     $this->urlRewriteEdit->getFormPageActions()->save();
     // Create new url rewrite fixture for asserts
     $data = array_merge($urlRewriteOrigin->getData(), $urlRewrite->getData());
     $data['target_path'] = ['custom' => $urlRewriteOrigin->getTargetPath(), 'readyEntity' => $urlRewriteOrigin->getDataFieldConfig('target_path')['source']->getEntity()];
     $data['store_id'] = ['data' => $urlRewriteOrigin->getStoreId()];
     $urlRewrite = $this->fixtureFactory->createByCode('urlRewrite', ['data' => $data]);
     return ['urlRewrite' => $urlRewrite];
 }
 /**
  * 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];
 }
 /**
  * Assert that category url rewrite not in grid.
  *
  * @param UrlRewriteIndex $urlRewriteIndex
  * @param CatalogCategory $category
  * @return void
  */
 public function processAssert(UrlRewriteIndex $urlRewriteIndex, CatalogCategory $category)
 {
     $urlRewriteIndex->open();
     $filter = ['request_path' => $category->getUrlKey()];
     \PHPUnit_Framework_Assert::assertFalse($urlRewriteIndex->getUrlRedirectGrid()->isRowVisible($filter), "URL Rewrite with request path '{$filter['request_path']}' is present in grid.");
 }
 /**
  * Assert that url rewrite success message is displayed.
  *
  * @param UrlRewriteIndex $urlRewriteIndex
  * @return void
  */
 public function processAssert(UrlRewriteIndex $urlRewriteIndex)
 {
     \PHPUnit_Framework_Assert::assertEquals(self::SUCCESS_MESSAGE, $urlRewriteIndex->getMessagesBlock()->getSuccessMessages());
 }
 /**
  * Assert that url rewrite not in grid.
  *
  * @param UrlRewriteIndex $urlRewriteIndex
  * @param UrlRewrite $urlRewrite
  * @return void
  */
 public function processAssert(UrlRewriteIndex $urlRewriteIndex, UrlRewrite $urlRewrite)
 {
     $urlRewriteIndex->open();
     $filter = ['request_path' => $urlRewrite->getIdentifier()];
     \PHPUnit_Framework_Assert::assertFalse($urlRewriteIndex->getUrlRedirectGrid()->isRowVisible($filter), "URL Rewrite with request path {$urlRewrite->getRequestPath()} is present in grid.");
 }