コード例 #1
0
 public function testFindOneByDataIfFound()
 {
     $data = [['field1' => 'value1']];
     $row = ['row1'];
     $urlRewrite = ['urlRewrite1'];
     $this->storage->expects($this->once())->method('doFindOneByData')->with($data)->will($this->returnValue($row));
     $this->urlRewriteBuilder->expects($this->once())->method('populateWithArray')->with($row)->will($this->returnSelf());
     $this->urlRewriteBuilder->expects($this->any())->method('create')->will($this->returnValue($urlRewrite));
     $this->assertEquals($urlRewrite, $this->storage->findOneByData($data));
 }
コード例 #2
0
 public function testFindOneByData()
 {
     $data = ['col1' => 'val1', 'col2' => 'val2'];
     $this->select->expects($this->at(1))->method('where')->with('col1 IN (?)', 'val1');
     $this->select->expects($this->at(2))->method('where')->with('col2 IN (?)', 'val2');
     $this->adapter->expects($this->any())->method('quoteIdentifier')->will($this->returnArgument(0));
     $this->adapter->expects($this->once())->method('fetchRow')->with($this->select)->will($this->returnValue(['row1']));
     $this->urlRewriteBuilder->expects($this->at(0))->method('populateWithArray')->with(['row1'])->will($this->returnSelf());
     $this->urlRewriteBuilder->expects($this->at(1))->method('create')->will($this->returnValue(['urlRewrite1']));
     $this->assertEquals(['urlRewrite1'], $this->storage->findOneByData($data));
 }
コード例 #3
0
 /**
  * @param mixed $storeId
  * @param mixed $categoryId
  * @param mixed $requestPath
  * @param mixed $targetPath
  * @param mixed $redirectType
  */
 protected function prepareUrlRewriteMock($storeId, $categoryId, $requestPath, $targetPath, $redirectType)
 {
     $this->urlRewriteBuilder->expects($this->any())->method('setStoreId')->with($storeId)->will($this->returnSelf());
     $this->urlRewriteBuilder->expects($this->any())->method('setEntityId')->with($categoryId)->will($this->returnSelf());
     $this->urlRewriteBuilder->expects($this->any())->method('setEntityType')->with(CategoryUrlRewriteGenerator::ENTITY_TYPE)->will($this->returnSelf());
     $this->urlRewriteBuilder->expects($this->any())->method('setRequestPath')->with($requestPath)->will($this->returnSelf());
     $this->urlRewriteBuilder->expects($this->any())->method('setTargetPath')->with($targetPath)->will($this->returnSelf());
     $this->urlRewriteBuilder->expects($this->any())->method('setIsAutogenerated')->with(0)->will($this->returnSelf());
     $this->urlRewriteBuilder->expects($this->any())->method('setRedirectType')->with($redirectType)->will($this->returnSelf());
     $this->urlRewriteBuilder->expects($this->any())->method('setMetadata')->with([])->will($this->returnSelf());
     $this->urlRewriteBuilder->expects($this->any())->method('create')->will($this->returnValue($this->urlRewrite));
 }
コード例 #4
0
 /**
  * @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->urlRewriteBuilder->expects($this->any())->method('setStoreId')->with($storeId)->will($this->returnSelf());
     $this->urlRewriteBuilder->expects($this->any())->method('setEntityId')->with($productId)->will($this->returnSelf());
     $this->urlRewriteBuilder->expects($this->any())->method('setEntityType')->with(ProductUrlRewriteGenerator::ENTITY_TYPE)->will($this->returnSelf());
     $this->urlRewriteBuilder->expects($this->any())->method('setRequestPath')->with($requestPath)->will($this->returnSelf());
     $this->urlRewriteBuilder->expects($this->any())->method('setTargetPath')->with($targetPath)->will($this->returnSelf());
     $this->urlRewriteBuilder->expects($this->any())->method('setIsAutogenerated')->with(0)->will($this->returnSelf());
     $this->urlRewriteBuilder->expects($this->any())->method('setRedirectType')->with($redirectType)->will($this->returnSelf());
     $this->urlRewriteBuilder->expects($this->any())->method('setMetadata')->with($metadata)->will($this->returnSelf());
     $this->urlRewriteBuilder->expects($this->any())->method('create')->will($this->returnValue($this->urlRewrite));
     $this->urlRewriteBuilder->expects($this->once())->method('setDescription')->with($description)->will($this->returnSelf());
 }
コード例 #5
0
 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->urlRewriteBuilder->expects($this->any())->method('setStoreId')->with($storeId)->will($this->returnSelf());
     $this->urlRewriteBuilder->expects($this->any())->method('setEntityId')->with($categoryId)->will($this->returnSelf());
     $this->urlRewriteBuilder->expects($this->any())->method('setEntityType')->with(CategoryUrlRewriteGenerator::ENTITY_TYPE)->will($this->returnSelf());
     $this->urlRewriteBuilder->expects($this->any())->method('setRequestPath')->with($requestPath)->will($this->returnSelf());
     $this->urlRewriteBuilder->expects($this->any())->method('setTargetPath')->with($targetPath)->will($this->returnSelf());
     $this->urlRewriteBuilder->expects($this->any())->method('create')->will($this->returnValue($this->urlRewrite));
     $this->assertEquals([$this->urlRewrite], $this->canonicalUrlRewriteGenerator->generate($storeId, $this->category));
 }
コード例 #6
0
 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->urlRewriteBuilder->expects($this->any())->method('setStoreId')->with($storeId)->will($this->returnSelf());
     $this->urlRewriteBuilder->expects($this->any())->method('setEntityId')->with($productId)->will($this->returnSelf());
     $this->urlRewriteBuilder->expects($this->any())->method('setEntityType')->with(ProductUrlRewriteGenerator::ENTITY_TYPE)->will($this->returnSelf());
     $this->urlRewriteBuilder->expects($this->any())->method('setRequestPath')->with($requestPath)->will($this->returnSelf());
     $this->urlRewriteBuilder->expects($this->any())->method('setTargetPath')->with($targetPath)->will($this->returnSelf());
     $this->urlRewriteBuilder->expects($this->any())->method('create')->will($this->returnValue($this->urlRewrite));
     $this->assertEquals([$this->urlRewrite], $this->canonicalUrlRewriteGenerator->generate($storeId, $this->product));
 }
コード例 #7
0
 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->urlRewriteBuilder->expects($this->any())->method('setStoreId')->with($storeId)->will($this->returnSelf());
     $this->urlRewriteBuilder->expects($this->any())->method('setEntityId')->with($productId)->will($this->returnSelf());
     $this->urlRewriteBuilder->expects($this->any())->method('setEntityType')->with(ProductUrlRewriteGenerator::ENTITY_TYPE)->will($this->returnSelf());
     $this->urlRewriteBuilder->expects($this->any())->method('setRequestPath')->with($urlPathWithCategory)->will($this->returnSelf());
     $this->urlRewriteBuilder->expects($this->any())->method('setTargetPath')->with($canonicalUrlPathWithCategory)->will($this->returnSelf());
     $this->urlRewriteBuilder->expects($this->any())->method('setMetadata')->with(['category_id' => $categoryId])->will($this->returnSelf());
     $this->urlRewriteBuilder->expects($this->any())->method('create')->will($this->returnValue($this->urlRewrite));
     $this->assertEquals([$this->urlRewrite], $this->categoriesUrlRewriteGenerator->generate($storeId, $this->product, $this->categoryRegistry));
 }