public function testGetFeeds() { $this->scopeConfig->expects($this->once())->method('isSetFlag')->with('rss/catalog/category', \Magento\Store\Model\ScopeInterface::SCOPE_STORE)->will($this->returnValue(true)); $category = $this->getMockBuilder('\\Magento\\Catalog\\Model\\Category')->setMethods(['__sleep', '__wakeup', 'getTreeModel', 'getResourceCollection', 'getId', 'getName'])->disableOriginalConstructor()->getMock(); $collection = $this->getMockBuilder('\\Magento\\Catalog\\Model\\Resource\\Category\\Collection')->setMethods(['addIdFilter', 'addAttributeToSelect', 'addAttributeToSort', 'load', 'addAttributeToFilter', 'getIterator'])->disableOriginalConstructor()->getMock(); $collection->expects($this->once())->method('addIdFilter')->will($this->returnSelf()); $collection->expects($this->exactly(3))->method('addAttributeToSelect')->will($this->returnSelf()); $collection->expects($this->once())->method('addAttributeToSort')->will($this->returnSelf()); $collection->expects($this->once())->method('addAttributeToFilter')->will($this->returnSelf()); $collection->expects($this->once())->method('load')->will($this->returnSelf()); $collection->expects($this->once())->method('getIterator')->will($this->returnValue(new \ArrayIterator([$category]))); $category->expects($this->once())->method('getId')->will($this->returnValue(1)); $category->expects($this->once())->method('getName')->will($this->returnValue('Category Name')); $category->expects($this->once())->method('getResourceCollection')->will($this->returnValue($collection)); $this->categoryFactory->expects($this->once())->method('create')->will($this->returnValue($category)); $node = new \Magento\Framework\Object(['id' => 1]); $nodes = $this->getMockBuilder('Magento\\Framework\\Data\\Tree\\Node')->setMethods(['getChildren'])->disableOriginalConstructor()->getMock(); $nodes->expects($this->once())->method('getChildren')->will($this->returnValue([$node])); $tree = $this->getMockBuilder('\\Magento\\Catalog\\Model\\Resource\\Category\\Tree')->setMethods(['loadChildren', 'loadNode'])->disableOriginalConstructor()->getMock(); $tree->expects($this->once())->method('loadNode')->will($this->returnSelf()); $tree->expects($this->once())->method('loadChildren')->will($this->returnValue($nodes)); $category->expects($this->once())->method('getTreeModel')->will($this->returnValue($tree)); $category->expects($this->once())->method('getResourceCollection')->will($this->returnValue('')); $this->rssUrlBuilder->expects($this->once())->method('getUrl')->will($this->returnValue('http://magento.com/category-name.html')); $feeds = ['group' => 'Categories', 'feeds' => [['label' => 'Category Name', 'link' => 'http://magento.com/category-name.html']]]; $this->assertEquals($feeds, $this->block->getFeeds()); }