/**
  * Assert that product can be found via Quick Search using searchable product attributes label.
  *
  * @param CatalogsearchResult $catalogSearchResult
  * @param CmsIndex $cmsIndex
  * @param InjectableFixture $product
  * @param CatalogProductAttribute $attribute
  * @return void
  */
 public function processAssert(CatalogsearchResult $catalogSearchResult, CmsIndex $cmsIndex, InjectableFixture $product, CatalogProductAttribute $attribute)
 {
     $cmsIndex->open();
     $filter = $this->prepareFilter($product, $attribute);
     $cmsIndex->getSearchBlock()->search($filter);
     $isProductVisible = $catalogSearchResult->getListProductBlock()->isProductVisible($product);
     while (!$isProductVisible && $catalogSearchResult->getBottomToolbar()->nextPage()) {
         $isProductVisible = $catalogSearchResult->getListProductBlock()->isProductVisible($product);
     }
     \PHPUnit_Framework_Assert::assertTrue($isProductVisible, 'Product was not found by option label.');
 }
 /**
  * Verify product displaying on frontend.
  *
  * @param InjectableFixture $product
  * @return array
  */
 protected function isNotDisplayingOnFrontendAssert(InjectableFixture $product)
 {
     $errors = [];
     //Check that product is not available by url
     $this->browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html');
     if ($this->catalogProductView->getViewBlock()->isVisible()) {
         $errors[] = '- product view block is visible in product page.';
     }
     //Check that product can't be found
     $this->cmsIndex->open()->getSearchBlock()->search($product->getSku());
     if ($this->catalogSearchResult->getListProductBlock()->isProductVisible($product)) {
         $errors[] = '- successful product search.';
     }
     //Check that product is not available in category page
     $categoryName = $product->hasData('category_ids') ? $product->getCategoryIds()[0] : $this->category->getName();
     $this->cmsIndex->open()->getTopmenu()->selectCategory($categoryName);
     $isProductVisible = $this->catalogCategoryView->getListProductBlock()->isProductVisible($product);
     $bottomToolBar = $this->catalogCategoryView->getBottomToolbar();
     while (!$isProductVisible && $bottomToolBar->nextPage()) {
         $isProductVisible = $this->catalogCategoryView->getListProductBlock()->isProductVisible($product);
     }
     if ($isProductVisible) {
         $errors[] = "- product with name '{$product->getName()}' is found in this category.";
     }
     return $errors;
 }
 /**
  * Assert that attribute present in sort dropdown on search results page on frontend.
  *
  * @param CmsIndex $cmsIndex
  * @param CatalogsearchResult $catalogsearchResult
  * @param CatalogProductAttribute $attribute
  * @param InjectableFixture $product
  * @return void
  */
 public function processAssert(CmsIndex $cmsIndex, CatalogsearchResult $catalogsearchResult, CatalogProductAttribute $attribute, InjectableFixture $product)
 {
     $cmsIndex->open()->getSearchBlock()->search($product->getName());
     $label = $attribute->hasData('manage_frontend_label') ? $attribute->getManageFrontendLabel() : $attribute->getFrontendLabel();
     \PHPUnit_Framework_Assert::assertTrue(in_array($label, $catalogsearchResult->getListProductBlock()->getSortByValues()), 'Attribute is absent in sort dropdown on search results page on frontend.');
 }
 /**
  * Process assert search result.
  *
  * @param CatalogsearchResult $catalogSearchResult
  * @param CmsIndex $cmsIndex
  * @param InjectableFixture $product
  * @param string $param
  * @throws \Exception
  * @return void
  *
  * @SuppressWarnings(PHPMD.NPathComplexity)
  */
 protected function verifySearchResult(CatalogsearchResult $catalogSearchResult, CmsIndex $cmsIndex, InjectableFixture $product, $param)
 {
     $cmsIndex->open();
     $searchValue = $product->hasData($param) !== false ? $product->getData($param) : null;
     if ($searchValue === null) {
         throw new \Exception("Product '{$product->getName}()' doesn't have '{$param}' parameter.");
     }
     $param = strtoupper($param);
     $this->errorMessage = sprintf($this->formatForErrorMessage, $param);
     $this->successfulMessage = sprintf($this->formatForSuccessfulMessage, $param);
     $cmsIndex->getSearchBlock()->search($searchValue);
     $quantityAndStockStatus = $product->getStockData();
     $stockStatus = isset($quantityAndStockStatus['is_in_stock']) ? $quantityAndStockStatus['is_in_stock'] : null;
     $isVisible = $catalogSearchResult->getListProductBlock()->isProductVisible($product);
     while (!$isVisible && $catalogSearchResult->getBottomToolbar()->nextPage()) {
         $isVisible = $catalogSearchResult->getListProductBlock()->isProductVisible($product);
     }
     if ($product->getVisibility() === 'Catalog' || $stockStatus === 'Out of Stock') {
         $isVisible = !$isVisible;
         list($this->errorMessage, $this->successfulMessage) = [$this->successfulMessage, $this->errorMessage];
     }
     \PHPUnit_Framework_Assert::assertTrue($isVisible, $this->errorMessage);
 }
 /**
  * Check out if the attribute in the navigation bar on the search results page in Layered navigation.
  *
  * @param CmsIndex $cmsIndex
  * @param CatalogsearchResult $catalogsearchResult
  * @param InjectableFixture $product
  * @param CatalogProductAttribute $attribute
  * @return void
  */
 public function processAssert(CmsIndex $cmsIndex, CatalogsearchResult $catalogsearchResult, InjectableFixture $product, CatalogProductAttribute $attribute)
 {
     $cmsIndex->open()->getSearchBlock()->search($product->getName());
     $label = $attribute->hasData('manage_frontend_label') ? $attribute->getManageFrontendLabel() : $attribute->getFrontendLabel();
     \PHPUnit_Framework_Assert::assertTrue(in_array(strtoupper($label), $catalogsearchResult->getLayeredNavigationBlock()->getFilters()), 'Attribute is absent in layered navigation on search page.');
 }
 /**
  * Assert that product cannot be found via Quick Search using searchable product attributes.
  *
  * @param CatalogsearchResult $catalogSearchResult
  * @param CmsIndex $cmsIndex
  * @param InjectableFixture $product
  * @return void
  */
 public function processAssert(CatalogsearchResult $catalogSearchResult, CmsIndex $cmsIndex, InjectableFixture $product)
 {
     $cmsIndex->open();
     $cmsIndex->getSearchBlock()->search($product->getSku());
     \PHPUnit_Framework_Assert::assertFalse($catalogSearchResult->getListProductBlock()->isProductVisible($product), 'Product was found by SKU.');
 }