コード例 #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
 /**
  * @param \Magento\Sales\Model\Order\Shipment\Item $item
  * @return $this
  */
 public function addItem(\Magento\Sales\Model\Order\Shipment\Item $item)
 {
     $item->setShipment($this)->setParentId($this->getId())->setStoreId($this->getStoreId());
     if (!$item->getId()) {
         $this->getItemsCollection()->addItem($item);
     }
     return $this;
 }