Exemple #1
0
 public function testAfterGetIdentities()
 {
     $baseIdentities = ['SomeCacheId', 'AnotherCacheId'];
     $id = 12345;
     $parentIds = [1, 2, 5, 100500];
     $expectedIdentities = ['SomeCacheId', 'AnotherCacheId', Product::CACHE_TAG . '_' . 1, Product::CACHE_TAG . '_' . 2, Product::CACHE_TAG . '_' . 5, Product::CACHE_TAG . '_' . 100500];
     $this->product->expects($this->once())->method('getId')->will($this->returnValue($id));
     $this->type->expects($this->once())->method('getParentIdsByChild')->with($id)->will($this->returnValue($parentIds));
     $identities = $this->plugin->afterGetIdentities($this->product, $baseIdentities);
     $this->assertEquals($expectedIdentities, $identities);
 }
Exemple #2
0
 public function testGetList()
 {
     $productSku = 'oneSku';
     $this->productRepository->expects($this->once())->method('get')->with($this->equalTo($productSku))->will($this->returnValue($this->product));
     $this->product->expects($this->once())->method('getTypeId')->will($this->returnValue(\Magento\Catalog\Model\Product\Type::TYPE_BUNDLE));
     $this->productType->expects($this->once())->method('getOptionsCollection')->with($this->equalTo($this->product))->will($this->returnValue([$this->optionModel]));
     $this->optionConverter->expects($this->once())->method('createDataFromModel')->with($this->equalTo($this->optionModel), $this->equalTo($this->product))->will($this->returnValue($this->option));
     $this->assertEquals([$this->option], $this->model->getList($productSku));
 }
Exemple #3
0
 /**
  * @expectedException \Magento\Framework\Exception\NoSuchEntityException
  */
 public function testRemoveNoSuchEntityException()
 {
     $productSku = 'oneSku';
     $optionId = 3;
     $this->productRepository->expects($this->once())->method('get')->with($this->equalTo($productSku))->will($this->returnValue($this->product));
     $this->product->expects($this->once())->method('getTypeId')->will($this->returnValue(\Magento\Catalog\Model\Product\Type::TYPE_BUNDLE));
     $this->productType->expects($this->once())->method('getOptionsCollection')->with($this->equalTo($this->product))->will($this->returnValue($this->optionCollection));
     $this->optionCollection->expects($this->once())->method('setIdFilter')->with($this->equalTo($optionId));
     $this->optionCollection->expects($this->once())->method('getFirstItem')->will($this->returnValue($this->optionModel));
     $this->optionModel->expects($this->once())->method('getId');
     $this->model->remove($productSku, $optionId);
 }