/** * Check whether the attribute filter is displayed on the frontend in Layered navigation. * * @param CatalogCategoryView $catalogCategoryView * @param InjectableFixture $product * @param CatalogProductAttribute $attribute * @param CmsIndex $cmsIndex * @param FixtureFactory $fixtureFactory * @return void */ public function processAssert(CatalogCategoryView $catalogCategoryView, InjectableFixture $product, CatalogProductAttribute $attribute, CmsIndex $cmsIndex, FixtureFactory $fixtureFactory) { $fixtureFactory->createByCode('catalogProductSimple', ['dataSet' => 'product_with_category_with_anchor', 'data' => ['category_ids' => ['presets' => null, 'category' => $product->getDataFieldConfig('category_ids')['source']->getCategories()[0]]]])->persist(); $cmsIndex->open()->getTopmenu()->selectCategoryByName($product->getCategoryIds()[0]); $label = $attribute->hasData('manage_frontend_label') ? $attribute->getManageFrontendLabel() : $attribute->getFrontendLabel(); \PHPUnit_Framework_Assert::assertTrue(in_array($label, $catalogCategoryView->getLayeredNavigationBlock()->getFilters()), 'Attribute is absent in layered navigation on category page.'); }
/** * Assertion that filtered product list via layered navigation are displayed correctly. * * @param Category $category * @param CmsIndex $cmsIndex * @param CatalogCategoryView $catalogCategoryView * @param array $layeredNavigation * @return void */ public function processAssert(Category $category, CmsIndex $cmsIndex, CatalogCategoryView $catalogCategoryView, array $layeredNavigation) { $this->products = $category->getDataFieldConfig('category_products')['source']->getProducts(); $cmsIndex->open(); $cmsIndex->getTopmenu()->selectCategoryByName($category->getName()); foreach ($layeredNavigation as $filters) { foreach ($filters as $filter) { $catalogCategoryView->getLayeredNavigationBlock()->applyFilter($filter['title'], $filter['linkPattern']); $productNames = $this->getProductNames($filter['products']); sort($productNames); $pageProductNames = $catalogCategoryView->getListProductBlock()->getProductNames(); sort($pageProductNames); \PHPUnit_Framework_Assert::assertEquals($productNames, $pageProductNames); } $catalogCategoryView->getLayeredNavigationBlock()->clearAll(); } }
/** * Check out if the attribute in the navigation bar on the search results page in Layered navigation. * * @param CmsIndex $cmsIndex * @param CatalogCategoryView $catalogCategoryView * @param InjectableFixture $product * @param CatalogProductAttribute $attribute * @return void */ public function processAssert(CmsIndex $cmsIndex, CatalogCategoryView $catalogCategoryView, 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($label, $catalogCategoryView->getLayeredNavigationBlock()->getFilters()), 'Attribute is absent in layered navigation on search page.'); }