10 use Magento\Catalog\Test\Page\Category\CatalogCategoryView;
11 use Magento\Mtf\Client\BrowserInterface;
12 use Magento\Mtf\Constraint\AbstractConstraint;
35 CatalogCategoryView $catalogCategoryView,
37 BrowserInterface $browser
39 $this->browser = $browser;
40 $this->openCategory(
$category->getDataFieldConfig(
'parent_id')[
'source']->getParentCategory());
42 \PHPUnit\Framework\Assert::assertTrue(
43 $catalogCategoryView->getLayeredNavigationBlock()->isCategoryVisible(
$category, 1),
44 'Category ' .
$category->getName() .
' is absent in Layered Navigation.' 47 $productsOnCategoryPage = $catalogCategoryView->getListProductBlock()->getProductNames();
48 $productsInCategory =
$category->getDataFieldConfig(
'category_products')[
'source']->getProducts();
49 foreach ($productsInCategory as
$product) {
50 \PHPUnit\Framework\Assert::assertTrue(
51 in_array(
$product->getName(), $productsOnCategoryPage),
52 'Product ' .
$product->getName() .
' is absent on category page.' 63 private function openCategory(Category
$category)
68 $categoryUrlKey[] =
$category->hasData(
'url_key')
70 : trim(strtolower(preg_replace(
'#[^0-9a-z%]+#i',
'-',
$category->getName())),
'-');
77 $categoryUrlKey = $_ENV[
'app_frontend_url'] . implode(
'/', array_reverse($categoryUrlKey)) .
'.html';
79 $this->browser->open($categoryUrlKey);
89 return 'Category is present in layered navigation and product is visible in product grid.';
processAssert(CatalogCategoryView $catalogCategoryView, Category $category, BrowserInterface $browser)