/** * @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); }
/** * test invoice create */ public function testCreate() { $invoiceDataObject = $this->getMock('Magento\\Sales\\Service\\V1\\Data\\Invoice', [], [], '', false); $this->invoiceCreateMock->expects($this->once())->method('invoke')->with($invoiceDataObject)->will($this->returnValue(true)); $this->assertTrue($this->invoiceWrite->create($invoiceDataObject)); }