/** * Test case when Mail Exception has been thrown */ public function testNotifyException() { $exception = new Exception('Email has not been sent'); $this->invoiceSenderMock->expects($this->once())->method('send')->with($this->equalTo($this->invoice))->will($this->throwException($exception)); $this->loggerMock->expects($this->once())->method('critical')->with($this->equalTo($exception)); $this->assertFalse($this->notifier->notify($this->invoice)); }
public function testInvoke() { $invoiceId = 1; $invoice = $this->getMock('\\Magento\\Sales\\Model\\Order\\Invoice', ['__wakeup', 'getEmailSent'], [], '', false); $this->invoiceRepository->expects($this->once())->method('get')->with($invoiceId)->will($this->returnValue($invoice)); $this->notifier->expects($this->any())->method('notify')->with($invoice)->will($this->returnValue(true)); $this->assertTrue($this->service->invoke($invoiceId)); }
/** * Run test notify method */ public function testNotify() { $id = 123; $returnValue = 'return-value'; $modelMock = $this->getMockForAbstractClass('Magento\\Sales\\Model\\AbstractModel', [], '', false); $this->repositoryMock->expects($this->once())->method('get')->with($id)->will($this->returnValue($modelMock)); $this->invoiceNotifierMock->expects($this->once())->method('notify')->with($modelMock)->will($this->returnValue($returnValue)); $this->assertEquals($returnValue, $this->invoiceService->notify($id)); }
/** * @inheritdoc */ public function notify($id) { $invoice = $this->repository->get($id); return $this->invoiceNotifier->notify($invoice); }