/** * @expectedException \Exception * @expectedExceptionMessage An error has occurred during creating Creditmemo */ public function testInvokeException() { $message = 'Can not save Creditmemo'; $e = new \Exception($message); $creditmemoDataObjectMock = $this->getMockBuilder('Magento\\Sales\\Service\\V1\\Data\\Creditmemo')->disableOriginalConstructor()->setMethods([])->getMock(); $this->loggerMock->expects($this->once())->method('logException')->with($e); $this->creditmemoConverterMock->expects($this->once())->method('getModel')->with($creditmemoDataObjectMock)->will($this->throwException($e)); $this->creditmemoCreate->invoke($creditmemoDataObjectMock); }
/** * @param \Magento\Sales\Service\V1\Data\Creditmemo $creditmemoDataObject * @throws \Exception * @return bool */ public function create(Creditmemo $creditmemoDataObject) { return $this->creditmemoCreate->invoke($creditmemoDataObject); }
/** * test creditmemo create */ public function testCreate() { $creditmemo = $this->getMock('\\Magento\\Sales\\Service\\V1\\Data\\Creditmemo', [], [], '', false); $this->creditmemoCreateMock->expects($this->once())->method('invoke')->with($creditmemo)->will($this->returnValue(true)); $this->assertTrue($this->creditmemoWrite->create($creditmemo)); }