コード例 #1
0
 public function testProcessRelations()
 {
     $this->shipmentMock->expects($this->once())->method('getId')->willReturn('shipment-id-value');
     $this->shipmentMock->expects($this->exactly(2))->method('getItems')->willReturn([$this->itemMock]);
     $this->shipmentMock->expects($this->exactly(2))->method('getComments')->willReturn([$this->commentMock]);
     $this->shipmentMock->expects($this->exactly(2))->method('getTracks')->willReturn([$this->trackMock]);
     $this->itemMock->expects($this->once())->method('setParentId')->with('shipment-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->trackResourceMock->expects($this->once())->method('save')->with($this->trackMock)->willReturnSelf();
     $this->relationProcessor->processRelation($this->shipmentMock);
 }
コード例 #2
0
ファイル: Relation.php プロジェクト: pradeep-wagento/magento2
 /**
  * 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);
         }
     }
 }