/** * Run test notify method */ public function testNotify() { $id = 123; $returnValue = 'return-value'; $modelMock = $this->getMockForAbstractClass('Magento\\Sales\\Model\\AbstractModel', [], '', false); $this->creditmemoRepositoryMock->expects($this->once())->method('get')->with($id)->will($this->returnValue($modelMock)); $this->creditmemoNotifierMock->expects($this->once())->method('notify')->with($modelMock)->will($this->returnValue($returnValue)); $this->assertEquals($returnValue, $this->creditmemoService->notify($id)); }
/** * @expectedExceptionMessage We cannot register an existing credit memo. * @expectedException \Magento\Framework\Exception\LocalizedException */ public function testRefundDoNotExpectsId() { $creditMemoMock = $this->getMockBuilder(CreditmemoInterface::class)->setMethods(['getId'])->getMockForAbstractClass(); $creditMemoMock->expects($this->once())->method('getId')->willReturn(444); $this->creditmemoService->refund($creditMemoMock, true); }