/** * @expectedException \Exception * @expectedExceptionMessage An error has occurred during creating Invoice */ public function testInvokeException() { $message = 'Can not save Invoice'; $e = new \Exception($message); $invoiceDataObjectMock = $this->getMockBuilder('Magento\\Sales\\Service\\V1\\Data\\Invoice')->disableOriginalConstructor()->setMethods([])->getMock(); $this->loggerMock->expects($this->once())->method('logException')->with($e); $this->invoiceConverterMock->expects($this->once())->method('getModel')->with($invoiceDataObjectMock)->will($this->throwException($e)); $this->invoiceCreate->invoke($invoiceDataObjectMock); }
/** * @param \Magento\Sales\Service\V1\Data\Invoice $invoiceDataObject * @return bool * @throws \Exception */ public function create(\Magento\Sales\Service\V1\Data\Invoice $invoiceDataObject) { return $this->invoiceCreate->invoke($invoiceDataObject); }