public function testGenerate() { $storeId = 'store_id'; $saveRewritesHistory = 'flag'; $childCategory = $this->getMockBuilder('Magento\\Catalog\\Model\\Category')->disableOriginalConstructor()->getMock(); $childCategory->expects($this->once())->method('setStoreId')->with($storeId); $childCategory->expects($this->once())->method('setData')->with('save_rewrites_history', $saveRewritesHistory); $this->childrenCategoriesProvider->expects($this->once())->method('getChildren')->with($this->category, false)->will($this->returnValue([$childCategory])); $this->category->expects($this->any())->method('getData')->with('save_rewrites_history')->will($this->returnValue($saveRewritesHistory)); $this->categoryUrlRewriteGeneratorFactory->expects($this->once())->method('create')->will($this->returnValue($this->categoryUrlRewriteGenerator)); $this->categoryUrlRewriteGenerator->expects($this->once())->method('generate')->with($childCategory)->will($this->returnValue([['url-1', 'url-2']])); $this->assertEquals([['url-1', 'url-2']], $this->childrenUrlRewriteGenerator->generate($storeId, $this->category)); }
/** * Generate list of urls per store * * @param string $storeId * @return \Magento\UrlRewrite\Service\V1\Data\UrlRewrite[] */ protected function generateForSpecificStoreView($storeId) { $urls = array_merge($this->canonicalUrlRewriteGenerator->generate($storeId, $this->category), $this->childrenUrlRewriteGenerator->generate($storeId, $this->category), $this->currentUrlRewritesRegenerator->generate($storeId, $this->category)); return $urls; }