/** * Assert that the category is no longer available on the top menu bar * * @param CmsIndex $cmsIndex * @param CatalogCategory $category * @param Browser $browser * @param CatalogCategoryView $categoryView * @return void */ public function processAssert(CmsIndex $cmsIndex, CatalogCategory $category, Browser $browser, CatalogCategoryView $categoryView) { $cmsIndex->open(); \PHPUnit_Framework_Assert::assertFalse($cmsIndex->getTopmenu()->isCategoryVisible($category->getName()), 'Category can be accessed from the navigation bar in the frontend.'); $browser->open($_ENV['app_frontend_url'] . $category->getUrlKey() . '.html'); \PHPUnit_Framework_Assert::assertEquals($category->getName(), $categoryView->getTitleBlock()->getTitle(), 'Wrong page is displayed.'); if (isset($category->getDataFieldConfig('category_products')['source'])) { $products = $category->getDataFieldConfig('category_products')['source']->getProducts(); foreach ($products as $productFixture) { \PHPUnit_Framework_Assert::assertTrue($categoryView->getListProductBlock()->isProductVisible($productFixture->getName()), "Products '{$productFixture->getName()}' not find."); } } }
/** * Assert that displayed assigned products on category page equals passed from fixture * * @param CatalogCategory $category * @param CatalogCategoryView $categoryView * @param Browser $browser * @return void */ public function processAssert(CatalogCategory $category, CatalogCategoryView $categoryView, Browser $browser) { $browser->open($_ENV['app_frontend_url'] . strtolower($category->getUrlKey()) . '.html'); $products = $category->getDataFieldConfig('category_products')['source']->getProducts(); foreach ($products as $productFixture) { \PHPUnit_Framework_Assert::assertTrue($categoryView->getListProductBlock()->isProductVisible($productFixture->getName()), "Products '{$productFixture->getName()}' not find."); } }
/** * Prepare category path * * @param CatalogCategory $category * @return array */ protected function prepareFullCategoryPath(CatalogCategory $category) { $path = []; $parentCategory = $category->getDataFieldConfig('parent_id')['source']->getParentCategory(); if ($parentCategory != null) { $path = $this->prepareFullCategoryPath($parentCategory); } return array_filter(array_merge($path, [$category->getPath(), $category->getName()])); }