public function testGenerate() { $requestPath = 'category.html'; $targetPath = 'target-path'; $storeId = 'store_id'; $categoryId = 'category_id'; $this->category->expects($this->any())->method('getId')->will($this->returnValue($categoryId)); $this->categoryUrlPathGenerator->expects($this->any())->method('getUrlPathWithSuffix')->will($this->returnValue($requestPath)); $this->categoryUrlPathGenerator->expects($this->any())->method('getCanonicalUrlPath')->will($this->returnValue($targetPath)); $this->urlRewrite->expects($this->any())->method('setStoreId')->with($storeId)->will($this->returnSelf()); $this->urlRewrite->expects($this->any())->method('setEntityId')->with($categoryId)->will($this->returnSelf()); $this->urlRewrite->expects($this->any())->method('setEntityType')->with(CategoryUrlRewriteGenerator::ENTITY_TYPE)->will($this->returnSelf()); $this->urlRewrite->expects($this->any())->method('setRequestPath')->with($requestPath)->will($this->returnSelf()); $this->urlRewrite->expects($this->any())->method('setTargetPath')->with($targetPath)->will($this->returnSelf()); $this->urlRewriteFactory->expects($this->any())->method('create')->will($this->returnValue($this->urlRewrite)); $this->assertEquals(['category.html_store_id' => $this->urlRewrite], $this->canonicalUrlRewriteGenerator->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; }