Exemple #1
0
 /**
  * Test _beforeSaveMethod via save() with failed validation
  *
  * @expectedException \Magento\Framework\Exception\LocalizedException
  * @expectedExceptionMessage Cannot save comment:
  */
 public function testSaveValidationFailed()
 {
     $this->entitySnapshotMock->expects($this->once())->method('isModified')->with($this->commentModelMock)->willReturn(true);
     $this->validatorMock->expects($this->once())->method('validate')->with($this->equalTo($this->commentModelMock))->will($this->returnValue(['warning message']));
     $this->commentResource->save($this->commentModelMock);
     $this->assertTrue(true);
 }
Exemple #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);
         }
     }
 }