Пример #1
0
 /**
  * Test _beforeSaveMethod via save() with failed validation
  *
  * @expectedException \Magento\Framework\Exception\LocalizedException
  * @expectedExceptionMessage Cannot save track:
  */
 public function testSaveValidationFailed()
 {
     $this->entitySnapshotMock->expects($this->once())->method('isModified')->with($this->trackModelMock)->willReturn(true);
     $this->validatorMock->expects($this->once())->method('validate')->with($this->equalTo($this->trackModelMock))->will($this->returnValue(['warning message']));
     $this->trackModelMock->expects($this->any())->method('getData')->willReturn([]);
     $this->trackResource->save($this->trackModelMock);
     $this->assertTrue(true);
 }
Пример #2
0
 /**
  * Process relations for Shipment
  *
  * @param \Magento\Framework\Model\AbstractModel $object
  * @return void
  * @throws \Exception
  */
 public function processRelation(\Magento\Framework\Model\AbstractModel $object)
 {
     /** @var \Magento\Sales\Model\Order\Shipment $object */
     if (null !== $object->getItems()) {
         foreach ($object->getItems() as $item) {
             $item->setParentId($object->getId());
             $this->shipmentItemResource->save($item);
         }
     }
     if (null !== $object->getTracks()) {
         foreach ($object->getTracks() as $track) {
             $this->shipmentTrackResource->save($track);
         }
     }
     if (null !== $object->getComments()) {
         foreach ($object->getComments() as $comment) {
             $this->shipmentCommentResource->save($comment);
         }
     }
 }