Ejemplo n.º 1
0
 public function testProcessRelations()
 {
     $this->creditmemoMock->expects($this->once())->method('getId')->willReturn('creditmemo-id-value');
     $this->creditmemoMock->expects($this->exactly(2))->method('getItems')->willReturn([$this->itemMock]);
     $this->creditmemoMock->expects($this->exactly(2))->method('getComments')->willReturn([$this->commentMock]);
     $this->itemMock->expects($this->once())->method('setParentId')->with('creditmemo-id-value')->willReturnSelf();
     $this->itemResourceMock->expects($this->once())->method('save')->with($this->itemMock)->willReturnSelf();
     $this->commentResourceMock->expects($this->once())->method('save')->with($this->commentMock)->willReturnSelf();
     $this->relationProcessor->processRelation($this->creditmemoMock);
 }
Ejemplo n.º 2
0
 /**
  * Process relations for CreditMemo
  *
  * @param \Magento\Framework\Model\AbstractModel $object
  * @throws \Exception
  * @return void
  */
 public function processRelation(\Magento\Framework\Model\AbstractModel $object)
 {
     /** @var \Magento\Sales\Model\Order\Creditmemo $object */
     if (null !== $object->getItems()) {
         foreach ($object->getItems() as $item) {
             $item->setParentId($object->getId());
             $this->creditmemoItemResource->save($item);
         }
     }
     if (null !== $object->getComments()) {
         foreach ($object->getComments() as $comment) {
             $this->creditmemoCommentResource->save($comment);
         }
     }
 }