public function testGetMenuCategoryData()
 {
     $category = $this->getMock('Magento\\Catalog\\Model\\Category', ['getId', 'getName'], [], '', false);
     $category->expects($this->once())->method('getId')->willReturn('id');
     $category->expects($this->once())->method('getName')->willReturn('name');
     $this->_catalogCategory->expects($this->once())->method('getCategoryUrl')->willReturn('url');
     $this->assertEquals(['name' => 'name', 'id' => 'category-node-id', 'url' => 'url', 'is_active' => false, 'has_active' => false], $this->_observer->getMenuCategoryData($category));
 }
 /**
  * Recursively adds categories to top menu
  *
  * @param \Magento\Framework\Data\Tree\Node\Collection|array $categories
  * @param \Magento\Framework\Data\Tree\Node $parentCategoryNode
  * @param \Magento\Theme\Block\Html\Topmenu $block
  * @return void
  */
 protected function _addCategoriesToMenu($categories, $parentCategoryNode, $block)
 {
     foreach ($categories as $category) {
         if (!$category->getIsActive()) {
             continue;
         }
         $block->addIdentity(\Magento\Catalog\Model\Category::CACHE_TAG . '_' . $category->getId());
         $tree = $parentCategoryNode->getTree();
         $categoryData = $this->menuCategoryData->getMenuCategoryData($category);
         $categoryNode = new \Magento\Framework\Data\Tree\Node($categoryData, 'id', $tree, $parentCategoryNode);
         $parentCategoryNode->addChild($categoryNode);
         if ($this->categoryFlatState->isFlatEnabled() && $category->getUseFlatResource()) {
             $subcategories = (array) $category->getChildrenNodes();
         } else {
             $subcategories = $category->getChildren();
         }
         $this->_addCategoriesToMenu($subcategories, $categoryNode, $block);
     }
 }