예제 #1
0
 /**
  * @expectedException \Magento\Framework\Exception\InputException
  * @expectedExceptionMessage Only implemented for configurable product: configurable
  */
 public function testGetListNotConfigurableProduct()
 {
     $productSku = "configurable";
     $this->productRepositoryMock->expects($this->once())->method('get')->with($productSku)->willReturn($this->productMock);
     $this->productMock->expects($this->once())->method('getTypeId')->willReturn('simple');
     $this->model->getList($productSku);
 }
 /**
  * Mock for options save
  *
  * @param MockObject $attribute
  * @param MockObject $product
  * @param $attributeId
  * @param $sku
  * @param $id
  * @return void
  */
 private function processSaveOptions(MockObject $attribute, MockObject $product, $attributeId, $sku, $id)
 {
     $attribute->expects(static::once())->method('getAttributeId')->willReturn($attributeId);
     $eavAttribute = $this->getMock(ProductAttributeInterface::class);
     $this->productAttributeRepository->expects(static::once())->method('get')->with($attributeId)->willReturn($eavAttribute);
     $attribute->expects(static::once())->method('loadByProductAndAttribute')->with($product, $eavAttribute)->willReturnSelf();
     $this->optionRepository->expects(static::once())->method('save')->with($sku, $attribute)->willReturn($id);
 }
 /**
  * @param int $attributeId
  * @param string $label
  * @param array $optionValues
  * @param string $msg
  * @dataProvider validateOptionDataProvider
  * @throws \Magento\Framework\Exception\InputException
  */
 public function testValidateNewOptionData($attributeId, $label, $optionValues, $msg)
 {
     $this->setExpectedException('Magento\\Framework\\Exception\\InputException', $msg);
     $optionValueMock = $this->getMock('\\Magento\\ConfigurableProduct\\Api\\Data\\OptionValueInterface');
     $optionValuesMock = [];
     if (!empty($optionValues)) {
         $optionValueMock->expects($this->any())->method('getValueIndex')->willReturn($optionValues['v']);
         $optionValueMock->expects($this->any())->method('getPricingValue')->willReturn($optionValues['p']);
         $optionValueMock->expects($this->any())->method('getIsPercent')->willReturn($optionValues['r']);
         $optionValuesMock = [$optionValueMock];
     }
     $optionMock = $this->getMock('\\Magento\\ConfigurableProduct\\Api\\Data\\OptionInterface');
     $optionMock->expects($this->any())->method('getAttributeId')->willReturn($attributeId);
     $optionMock->expects($this->any())->method('getLabel')->willReturn($label);
     $optionMock->expects($this->any())->method('getValues')->willReturn($optionValuesMock);
     $this->model->validateNewOptionData($optionMock);
 }
예제 #4
0
 /**
  * Mock for options save
  *
  * @param MockObject $attribute
  * @param $sku
  * @param $id
  * @return void
  */
 private function processSaveOptions(MockObject $attribute, $sku, $id)
 {
     $attribute->expects(static::once())->method('setId')->with(null)->willReturnSelf();
     $this->optionRepository->expects(static::once())->method('save')->with($sku, $attribute)->willReturn($id);
 }