Beispiel #1
0
 /**
  * @expectedException \Magento\Framework\Exception\InputException
  */
 public function testAddWithOptionId()
 {
     $optionData = $this->getMock('Magento\\Catalog\\Service\\V1\\Product\\CustomOptions\\Data\\Option', [], [], '', false);
     $optionData->expects($this->once())->method('getOptionId')->will($this->returnValue(10));
     $this->optionConverterMock->expects($this->never())->method('convert');
     $this->writeService->add(self::PRODUCT_SKU, $optionData);
 }
 /**
  * @expectedException \Magento\Framework\Exception\CouldNotSaveException
  */
 public function testAddWithExceptionDuringSave()
 {
     $optionData = $this->getMock('Magento\\Catalog\\Service\\V1\\Product\\CustomOptions\\Data\\Option', [], [], '', false);
     $convertedOptions = [Data\Option::OPTION_ID => 10, Data\Option::TITLE => 'Some title', Data\Option::TYPE => 'text', Data\Option::IS_REQUIRE => true, Data\Option::SORT_ORDER => 10, 'price_type' => 'fixed', 'sku' => 'sku1', 'max_characters' => 10];
     $this->optionConverterMock->expects($this->once())->method('convert')->with($optionData)->will($this->returnValue($convertedOptions));
     $this->productMock->expects($this->once())->method('setCanSaveCustomOptions')->with(true);
     $this->productMock->expects($this->once())->method('setProductOptions')->with([$convertedOptions]);
     $this->productMock->expects($this->once())->method('save')->will($this->throwException(new \Exception()));
     $this->writeService->add(self::PRODUCT_SKU, $optionData);
 }