Beispiel #1
0
 /**
  * Invoke ShipmentList service
  *
  * @param SearchCriteria $searchCriteria
  * @return \Magento\Framework\Service\V1\Data\SearchResults
  */
 public function invoke(SearchCriteria $searchCriteria)
 {
     $shipments = [];
     foreach ($this->shipmentRepository->find($searchCriteria) as $shipment) {
         $shipments[] = $this->shipmentMapper->extractDto($shipment);
     }
     return $this->searchResultsBuilder->setItems($shipments)->setTotalCount(count($shipments))->setSearchCriteria($searchCriteria)->create();
 }
Beispiel #2
0
 /**
  * test shipment list service
  */
 public function testInvoke()
 {
     $this->shipmentRepositoryMock->expects($this->once())->method('find')->with($this->equalTo($this->searchCriteriaMock))->will($this->returnValue([$this->shipmentMock]));
     $this->shipmentMapperMock->expects($this->once())->method('extractDto')->with($this->equalTo($this->shipmentMock))->will($this->returnValue($this->dataObjectMock));
     $this->searchResultsBuilderMock->expects($this->once())->method('setItems')->with($this->equalTo([$this->dataObjectMock]))->will($this->returnSelf());
     $this->searchResultsBuilderMock->expects($this->once())->method('setTotalCount')->with($this->equalTo(count($this->shipmentMock)))->will($this->returnSelf());
     $this->searchResultsBuilderMock->expects($this->once())->method('setSearchCriteria')->with($this->equalTo($this->searchCriteriaMock))->will($this->returnSelf());
     $this->searchResultsBuilderMock->expects($this->once())->method('create')->will($this->returnValue('expected-result'));
     $this->assertEquals('expected-result', $this->shipmentList->invoke($this->searchCriteriaMock));
 }
Beispiel #3
0
 /**
  * test shipment get service
  */
 public function testInvoke()
 {
     $this->shipmentRepositoryMock->expects($this->once())->method('get')->with($this->equalTo(1))->will($this->returnValue($this->shipmentMock));
     $this->shipmentMapperMock->expects($this->once())->method('extractDto')->with($this->equalTo($this->shipmentMock))->will($this->returnValue($this->dataObjectMock));
     $this->assertEquals($this->dataObjectMock, $this->shipmentGet->invoke(1));
 }
Beispiel #4
0
 /**
  * Invoke getShipment service
  *
  * @param int $id
  * @return \Magento\Sales\Service\V1\Data\Shipment
  * @throws \Magento\Framework\Exception\NoSuchEntityException
  */
 public function invoke($id)
 {
     return $this->shipmentMapper->extractDto($this->shipmentRepository->get($id));
 }