/**
  * @return \PHPUnit_Framework_MockObject_MockObject
  */
 protected function getProductOptionMock()
 {
     $productOption = $this->getMockBuilder('Magento\\Catalog\\Api\\Data\\ProductOptionInterface')->getMockForAbstractClass();
     $productOption->expects($this->any())->method('getExtensionAttributes')->willReturn(null);
     $this->productOptionFactory->expects($this->any())->method('create')->willReturn($productOption);
     return $productOption;
 }
Exemplo n.º 2
0
 /**
  * Set product options data
  *
  * @param OrderItemInterface $orderItem
  * @param array $data
  * @return $this
  */
 protected function setProductOption(OrderItemInterface $orderItem, array $data)
 {
     $productOption = $orderItem->getProductOption();
     if (!$productOption) {
         $productOption = $this->productOptionFactory->create();
         $orderItem->setProductOption($productOption);
     }
     $extensionAttributes = $productOption->getExtensionAttributes();
     if (!$extensionAttributes) {
         $extensionAttributes = $this->extensionFactory->create();
         $productOption->setExtensionAttributes($extensionAttributes);
     }
     $extensionAttributes->setData(key($data), current($data));
     return $this;
 }