/** * Test case when Mail Exception has been thrown */ public function testNotifyException() { $exception = new MailException(__('Email has not been sent')); $this->creditmemoSenderMock->expects($this->once())->method('send')->with($this->equalTo($this->creditmemo))->will($this->throwException($exception)); $this->loggerMock->expects($this->once())->method('critical')->with($this->equalTo($exception)); $this->assertFalse($this->notifier->notify($this->creditmemo)); }
public function testInvoke() { $creditmemoId = 1; $creditmemo = $this->getMock('\\Magento\\Sales\\Model\\Order\\Creditmemo', ['__wakeup', 'getEmailSent'], [], '', false); $this->creditmemoRepository->expects($this->once())->method('get')->with($creditmemoId)->will($this->returnValue($creditmemo)); $this->notifier->expects($this->any())->method('notify')->with($creditmemo)->will($this->returnValue(true)); $this->assertTrue($this->service->invoke($creditmemoId)); }
/** * 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)); }
/** * Notify user * * @param int $id * @return bool */ public function notify($id) { $creditmemo = $this->creditmemoRepository->get($id); return $this->creditmemoNotifier->notify($creditmemo); }
/** * Invoke notifyUser service * * @param int $id * @return bool */ public function invoke($id) { /** @var \Magento\Sales\Model\Order\Creditmemo $creditmemo */ $creditmemo = $this->creditmemoRepository->get($id); return $this->creditmemoNotifier->notify($creditmemo); }