Ejemplo n.º 1
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));
 }
Ejemplo n.º 2
0
 /**
  * @expectedException \Magento\Framework\Exception\NoSuchEntityException
  */
 public function testUpdateNoSuchEntityException()
 {
     $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->optionConverter->expects($this->once())->method('getModelFromData')->with($this->equalTo($this->option), $this->equalTo($this->optionModel))->will($this->returnValue($this->optionModel));
     $this->optionModel->expects($this->once())->method('getId');
     $this->model->update($productSku, $optionId, $this->option);
 }