Exemple #1
0
 public function testInvoke()
 {
     $invoiceId = 1;
     $invoice = $this->getMock('\\Magento\\Sales\\Model\\Order\\Invoice', ['__wakeup', 'getEmailSent'], [], '', false);
     $this->invoiceRepository->expects($this->once())->method('get')->with($invoiceId)->will($this->returnValue($invoice));
     $this->notifier->expects($this->any())->method('notify')->with($invoice)->will($this->returnValue(true));
     $this->assertTrue($this->service->invoke($invoiceId));
 }
Exemple #2
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();
 }
Exemple #3
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));
 }
 public function testSave()
 {
     $entity = $this->getMockBuilder('Magento\\Sales\\Model\\Order\\Invoice')->disableOriginalConstructor()->getMock();
     $entity->expects($this->any())->method('getEntityId')->willReturn(1);
     $mapper = $this->getMockBuilder('Magento\\Sales\\Model\\ResourceModel\\Order\\Invoice')->disableOriginalConstructor()->getMock();
     $mapper->expects($this->once())->method('save')->with($entity);
     $this->invoiceMetadata->expects($this->any())->method('getMapper')->willReturn($mapper);
     $this->assertEquals($entity, $this->invoice->save($entity));
 }
Exemple #5
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));
 }
Exemple #6
0
 /**
  * test invoice capture service
  */
 public function testInvoke()
 {
     $this->invoiceRepositoryMock->expects($this->once())->method('get')->with($this->equalTo(1))->will($this->returnValue($this->invoiceMock));
     $this->invoiceMock->expects($this->once())->method('capture')->will($this->returnSelf());
     $this->assertTrue($this->invoiceCapture->invoke(1));
 }
Exemple #7
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));
 }
Exemple #8
0
 /**
  * Invoke InvoiceCapture service
  *
  * @param int $id
  * @return bool
  * @throws \Magento\Framework\Exception\NoSuchEntityException
  */
 public function invoke($id)
 {
     return (bool) $this->invoiceRepository->get($id)->capture();
 }
Exemple #9
0
 /**
  * Invoke notifyUser service
  *
  * @param int $id
  * @return bool
  */
 public function invoke($id)
 {
     /** @var \Magento\Sales\Model\Order\Invoice $invoice */
     $invoice = $this->invoiceRepository->get($id);
     return $this->invoiceNotifier->notify($invoice);
 }