Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AssertCategoryNavigationMenu.php
Go to the documentation of this file.
1 <?php
8 
10 use Magento\Cms\Test\Page\CmsIndex;
11 use Magento\Mtf\Constraint\AbstractConstraint;
12 
16 class AssertCategoryNavigationMenu extends AbstractConstraint
17 {
21  const DEFAULT_CATEGORY_NAME = 'Default Category';
22 
30  public function processAssert(
31  CmsIndex $cmsIndex,
32  Category $category
33  ) {
34  do {
35  $categoriesNames[] = $category->getName();
36  $category = $category->getDataFieldConfig('parent_id')['source']->getParentCategory();
37  } while ($category->getName() != self::DEFAULT_CATEGORY_NAME);
38 
39  $cmsIndex->open();
40 
41  foreach (array_reverse($categoriesNames) as $category) {
42  \PHPUnit\Framework\Assert::assertTrue(
43  $cmsIndex->getTopmenu()->isCategoryVisible($category),
44  'Category ' . $category . ' is not visible in top menu.'
45  );
46  $cmsIndex->getTopMenu()->hoverCategoryByName($category);
47  }
48  }
49 
55  public function toString()
56  {
57  return 'Topmenu contains correct tree of categories.';
58  }
59 }