6 declare(strict_types=1);
11 use Magento\Catalog\Test\Page\Category\CatalogCategoryView;
12 use Magento\Mtf\Client\BrowserInterface;
13 use Magento\Mtf\Constraint\AbstractConstraint;
32 private $catalogCategoryView;
44 CatalogCategoryView $catalogCategoryView,
46 BrowserInterface $browser,
49 $this->browser = $browser;
50 $this->catalogCategoryView = $catalogCategoryView;
52 $parentCategory =
$category->getDataFieldConfig(
'parent_id')[
'source']->getParentCategory();
53 if ($parentCategory && $parentCategory->getData(
'is_anchor') ==
'No') {
54 $this->openCategory($parentCategory);
55 \PHPUnit\Framework\Assert::assertTrue(
56 $this->catalogCategoryView->getLayeredNavigationBlock()->isCategoryVisible(
60 'Category ' .
$category->getName() .
' is absent in Layered Navigation or products count is wrong' 73 private function openCategory(Category
$category)
78 $categoryUrlKey[] =
$category->hasData(
'url_key')
80 : trim(strtolower(preg_replace(
'#[^0-9a-z%]+#i',
'-',
$category->getName())),
'-');
87 $categoryUrlKey = $_ENV[
'app_frontend_url'] . implode(
'/', array_reverse($categoryUrlKey)) .
'.html';
89 $this->browser->open($categoryUrlKey);
99 return 'Category is present in layered navigation and product is visible in product grid.';
processAssert(CatalogCategoryView $catalogCategoryView, Category $category, BrowserInterface $browser, string $productsCount)