/**
  * @param mixed $storeId
  * @param mixed $categoryId
  * @param mixed $requestPath
  * @param mixed $targetPath
  * @param mixed $redirectType
  */
 protected function prepareUrlRewriteMock($storeId, $categoryId, $requestPath, $targetPath, $redirectType)
 {
     $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->urlRewrite->expects($this->any())->method('setIsAutogenerated')->with(0)->will($this->returnSelf());
     $this->urlRewrite->expects($this->any())->method('setRedirectType')->with($redirectType)->will($this->returnSelf());
     $this->urlRewrite->expects($this->any())->method('setMetadata')->with([])->will($this->returnSelf());
     $this->urlRewriteFactory->expects($this->any())->method('create')->will($this->returnValue($this->urlRewrite));
 }
 /**
  * @param mixed $storeId
  * @param mixed $productId
  * @param mixed $requestPath
  * @param mixed $targetPath
  * @param mixed $redirectType
  * @param mixed $metadata
  * @param mixed $description
  */
 protected function prepareUrlRewriteMock($storeId, $productId, $requestPath, $targetPath, $redirectType, $metadata, $description)
 {
     $this->urlRewrite->expects($this->any())->method('setStoreId')->with($storeId)->will($this->returnSelf());
     $this->urlRewrite->expects($this->any())->method('setEntityId')->with($productId)->will($this->returnSelf());
     $this->urlRewrite->expects($this->any())->method('setEntityType')->with(ProductUrlRewriteGenerator::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->urlRewrite->expects($this->any())->method('setIsAutogenerated')->with(0)->will($this->returnSelf());
     $this->urlRewrite->expects($this->any())->method('setRedirectType')->with($redirectType)->will($this->returnSelf());
     $this->urlRewrite->expects($this->any())->method('setMetadata')->with($metadata)->will($this->returnSelf());
     $this->urlRewriteFactory->expects($this->any())->method('create')->will($this->returnValue($this->urlRewrite));
     $this->urlRewrite->expects($this->once())->method('setDescription')->with($description)->will($this->returnSelf());
 }
 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));
 }
 public function testGenerate()
 {
     $requestPath = 'simple-product.html';
     $storeId = 10;
     $productId = 'product_id';
     $targetPath = 'catalog/product/view/id/' . $productId;
     $this->product->expects($this->any())->method('getId')->will($this->returnValue($productId));
     $this->productUrlPathGenerator->expects($this->any())->method('getUrlPathWithSuffix')->will($this->returnValue($requestPath));
     $this->productUrlPathGenerator->expects($this->any())->method('getCanonicalUrlPath')->will($this->returnValue($targetPath));
     $this->categoryRegistry->expects($this->any())->method('getList')->will($this->returnValue([]));
     $this->urlRewrite->expects($this->any())->method('setStoreId')->with($storeId)->will($this->returnSelf());
     $this->urlRewrite->expects($this->any())->method('setEntityId')->with($productId)->will($this->returnSelf());
     $this->urlRewrite->expects($this->any())->method('setEntityType')->with(ProductUrlRewriteGenerator::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([$this->urlRewrite], $this->canonicalUrlRewriteGenerator->generate($storeId, $this->product));
 }
 public function testGenerateCategories()
 {
     $urlPathWithCategory = 'category/simple-product.html';
     $storeId = 10;
     $productId = 'product_id';
     $canonicalUrlPathWithCategory = 'canonical-path-with-category';
     $categoryId = 'category_id';
     $this->product->expects($this->any())->method('getId')->will($this->returnValue($productId));
     $this->productUrlPathGenerator->expects($this->any())->method('getUrlPathWithSuffix')->will($this->returnValue($urlPathWithCategory));
     $this->productUrlPathGenerator->expects($this->any())->method('getCanonicalUrlPath')->will($this->returnValue($canonicalUrlPathWithCategory));
     $category = $this->getMock('Magento\\Catalog\\Model\\Category', [], [], '', false);
     $category->expects($this->any())->method('getId')->will($this->returnValue($categoryId));
     $this->categoryRegistry->expects($this->any())->method('getList')->will($this->returnValue([$category]));
     $this->urlRewrite->expects($this->any())->method('setStoreId')->with($storeId)->will($this->returnSelf());
     $this->urlRewrite->expects($this->any())->method('setEntityId')->with($productId)->will($this->returnSelf());
     $this->urlRewrite->expects($this->any())->method('setEntityType')->with(ProductUrlRewriteGenerator::ENTITY_TYPE)->will($this->returnSelf());
     $this->urlRewrite->expects($this->any())->method('setRequestPath')->with($urlPathWithCategory)->will($this->returnSelf());
     $this->urlRewrite->expects($this->any())->method('setTargetPath')->with($canonicalUrlPathWithCategory)->will($this->returnSelf());
     $this->urlRewrite->expects($this->any())->method('setMetadata')->with(['category_id' => $categoryId])->will($this->returnSelf());
     $this->urlRewriteFactory->expects($this->any())->method('create')->will($this->returnValue($this->urlRewrite));
     $this->assertEquals([$this->urlRewrite], $this->categoriesUrlRewriteGenerator->generate($storeId, $this->product, $this->categoryRegistry));
 }