Example #1
0
 /**
  * Invoke InvoiceList service
  *
  * @param SearchCriteria $searchCriteria
  * @return \Magento\Framework\Service\V1\Data\SearchResults
  */
 public function invoke(SearchCriteria $searchCriteria)
 {
     $invoices = [];
     foreach ($this->invoiceRepository->find($searchCriteria) as $invoice) {
         $invoices[] = $this->invoiceMapper->extractDto($invoice);
     }
     return $this->searchResultsBuilder->setItems($invoices)->setTotalCount(count($invoices))->setSearchCriteria($searchCriteria)->create();
 }
Example #2
0
 /**
  * test invoice list service
  */
 public function testInvoke()
 {
     $this->invoiceRepositoryMock->expects($this->once())->method('find')->with($this->equalTo($this->searchCriteriaMock))->will($this->returnValue([$this->invoiceMock]));
     $this->invoiceMapperMock->expects($this->once())->method('extractDto')->with($this->equalTo($this->invoiceMock))->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->invoiceMock)))->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->invoiceList->invoke($this->searchCriteriaMock));
 }
Example #3
0
 /**
  * test invoice get service
  */
 public function testInvoke()
 {
     $this->invoiceRepositoryMock->expects($this->once())->method('get')->with($this->equalTo(1))->will($this->returnValue($this->invoiceMock));
     $this->invoiceMapperMock->expects($this->once())->method('extractDto')->with($this->equalTo($this->invoiceMock))->will($this->returnValue($this->dataObjectMock));
     $this->assertEquals($this->dataObjectMock, $this->invoiceGet->invoke(1));
 }
Example #4
0
 /**
  * Invoke getInvoice service
  *
  * @param int $id
  * @return \Magento\Sales\Service\V1\Data\Invoice
  * @throws \Magento\Framework\Exception\NoSuchEntityException
  */
 public function invoke($id)
 {
     return $this->invoiceMapper->extractDto($this->invoiceRepository->get($id));
 }