/** * Assert that product attribute is searchable on Frontend. * * @param CatalogProductAttribute $attribute * @param CmsIndex $cmsIndex * @param InjectableFixture $product * @param CatalogsearchResult $catalogSearchResult * @return void */ public function processAssert(CatalogProductAttribute $attribute, CmsIndex $cmsIndex, InjectableFixture $product, CatalogsearchResult $catalogSearchResult) { $searchValue = $this->getSearchValue($attribute); $cmsIndex->open(); $cmsIndex->getSearchBlock()->search($searchValue); $isVisible = $catalogSearchResult->getListProductBlock()->getProductItem($product)->isVisible(); while (!$isVisible && $catalogSearchResult->getBottomToolbar()->nextPage()) { $isVisible = $catalogSearchResult->getListProductBlock()->getProductItem($product)->isVisible(); } \PHPUnit_Framework_Assert::assertTrue($isVisible, 'Product attribute is not searchable on Frontend.'); }
/** * Assert that product can be searched via Quick Search using searchable product attributes (Search by SKU) * * @param CatalogsearchResult $catalogSearchResult * @param CmsIndex $cmsIndex * @param FixtureInterface $product * @return void */ public function processAssert(CatalogsearchResult $catalogSearchResult, CmsIndex $cmsIndex, FixtureInterface $product) { $cmsIndex->open(); $cmsIndex->getSearchBlock()->search($product->getSku()); $isInStock = $product->getQuantityAndStockStatus(); if ($product->getVisibility() === 'Catalog' || isset($isInStock['is_in_stock']) && $isInStock['is_in_stock'] === 'Out of Stock') { $isVisible = !$catalogSearchResult->getListProductBlock()->isProductVisible($product->getName()); $this->errorMessage = 'Product successfully found by SKU.'; $this->successfulMessage = 'The product has not been found by SKU.'; } else { $isVisible = $catalogSearchResult->getListProductBlock()->isProductVisible($product->getName()); } \PHPUnit_Framework_Assert::assertTrue($isVisible, $this->errorMessage); }
/** * Assert that product attribute is searchable on Frontend. * * @param CmsIndex $cmsIndex * @param InjectableFixture $product * @param AdvancedSearch $searchPage * @param CatalogsearchResult $catalogSearchResult * @param FixtureFactory $fixtureFactory * @return void */ public function processAssert(CmsIndex $cmsIndex, InjectableFixture $product, AdvancedSearch $searchPage, CatalogsearchResult $catalogSearchResult, FixtureFactory $fixtureFactory) { $this->fixtureFactory = $fixtureFactory; $cmsIndex->open(); $cmsIndex->getFooterBlock()->openAdvancedSearch(); $searchForm = $searchPage->getForm(); $productSearch = $this->prepareFixture($product); $searchForm->fill($productSearch); $searchForm->submit(); $isVisible = $catalogSearchResult->getListProductBlock()->getProductItem($product)->isVisible(); while (!$isVisible && $catalogSearchResult->getBottomToolbar()->nextPage()) { $isVisible = $catalogSearchResult->getListProductBlock()->getProductItem($product)->isVisible(); } \PHPUnit_Framework_Assert::assertTrue($isVisible, 'Product attribute is not searchable on Frontend.'); }
/** * Verify product displaying on frontend * * @param FixtureInterface $product * @return array */ protected function isNotDisplayingOnFrontendAssert(FixtureInterface $product) { $errors = []; // Check the product page is not available // TODO fix initialization url for frontend page $this->browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html'); $titleBlock = $this->catalogProductView->getTitleBlock(); if ($titleBlock->getTitle() !== self::NOT_FOUND_MESSAGE) { $errors[] = '- the headline on the page does not match, the text should be -> "' . self::NOT_FOUND_MESSAGE . '".'; } $this->cmsIndex->open(); $this->cmsIndex->getSearchBlock()->search($product->getSku()); if ($this->catalogSearchResult->getListProductBlock()->isProductVisible($product->getName())) { $errors[] = '- successful product search.'; } $categoryName = $product->hasData('category_ids') ? $product->getCategoryIds()[0] : $this->category->getName(); $this->cmsIndex->open(); $this->cmsIndex->getTopmenu()->selectCategoryByName($categoryName); $isProductVisible = $this->catalogCategoryView->getListProductBlock()->isProductVisible($product->getName()); while (!$isProductVisible && $this->catalogCategoryView->getBottomToolbar()->nextPage()) { $isProductVisible = $this->catalogCategoryView->getListProductBlock()->isProductVisible($product->getName()); } if ($isProductVisible) { $errors[] = "- product with name '{$product->getName()}' is found in this category."; } return $errors; }
/** * Assert that product can be searched via Quick Search using searchable product attributes (Search by SKU) * * @param CatalogsearchResult $catalogSearchResult * @param CmsIndex $cmsIndex * @param FixtureInterface $product * @return void * * @SuppressWarnings(PHPMD.NPathComplexity) */ public function processAssert(CatalogsearchResult $catalogSearchResult, CmsIndex $cmsIndex, FixtureInterface $product) { $cmsIndex->open(); $sku = $product->hasData('sku') !== false ? $product->getSku() : $product->getName(); $cmsIndex->getSearchBlock()->search($sku); $quantityAndStockStatus = $product->getQuantityAndStockStatus(); $stockStatus = isset($quantityAndStockStatus['is_in_stock']) ? $quantityAndStockStatus['is_in_stock'] : null; $isVisible = $catalogSearchResult->getListProductBlock()->getProductItem($product)->isVisible(); while (!$isVisible && $catalogSearchResult->getBottomToolbar()->nextPage()) { $isVisible = $catalogSearchResult->getListProductBlock()->getProductItem($product)->isVisible(); } 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); }
/** * Assert that products generated during configurable product creation - are not visible on frontend(by default). * * @param CatalogSearchResult $catalogSearchResult * @param CmsIndex $cmsIndex * @param ConfigurableProduct $product * @return void */ public function processAssert(CatalogsearchResult $catalogSearchResult, CmsIndex $cmsIndex, ConfigurableProduct $product) { $configurableAttributesData = $product->getConfigurableAttributesData(); $errors = []; $cmsIndex->open(); foreach ($configurableAttributesData['matrix'] as $variation) { $cmsIndex->getSearchBlock()->search($variation['sku']); $isVisibleProduct = $catalogSearchResult->getListProductBlock()->isProductVisible($variation['name']); while (!$isVisibleProduct && $catalogSearchResult->getBottomToolbar()->nextPage()) { $isVisibleProduct = $catalogSearchResult->getListProductBlock()->isProductVisible($product->getName()); } if ($isVisibleProduct) { $errors[] = sprintf("\nChild product with sku: \"%s\" is visible on frontend(by default).", $variation['sku']); } } \PHPUnit_Framework_Assert::assertEmpty($errors, implode(' ', $errors)); }
/** * Assert search has no results and product list in absent. * * @param CatalogsearchResult $catalogsearchResult * @return void */ public function processAssert(CatalogsearchResult $catalogsearchResult) { \PHPUnit_Framework_Assert::assertFalse($catalogsearchResult->getListProductBlock()->isVisible(), 'Search result has been found.'); }
/** * Assert that product cannot be found via Quick Search using searchable product attributes. * * @param CatalogsearchResult $catalogSearchResult * @param CmsIndex $cmsIndex * @param FixtureInterface $product * @return void */ public function processAssert(CatalogsearchResult $catalogSearchResult, CmsIndex $cmsIndex, FixtureInterface $product) { $cmsIndex->open(); $cmsIndex->getSearchBlock()->search($product->getSku()); \PHPUnit_Framework_Assert::assertFalse($catalogSearchResult->getListProductBlock()->getProductItem($product)->isVisible(), 'Product was found by SKU.'); }
/** * 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.'); }