public function testEmailNoInvoice() { $invoiceId = 10000031; $this->request->expects($this->once()) ->method('getParam') ->with('invoice_id') ->willReturn($invoiceId); $invoiceRepository = $this->getMockBuilder('Magento\Sales\Api\InvoiceRepositoryInterface') ->disableOriginalConstructor() ->getMock(); $invoiceRepository->expects($this->any()) ->method('get') ->willReturn(null); $this->objectManager->expects($this->at(0)) ->method('create') ->with('Magento\Sales\Api\InvoiceRepositoryInterface') ->willReturn($invoiceRepository); $this->resultForwardFactory->expects($this->any()) ->method('create') ->willReturn($this->resultForward); $this->resultForward->expects($this->once()) ->method('forward') ->with('noroute') ->willReturnSelf(); $this->assertInstanceOf('Magento\Backend\Model\View\Result\Forward', $this->invoiceEmail->executeInternal()); }
public function testEmailNoInvoice() { $invoiceId = 10000031; $invoiceClassName = 'Magento\\Sales\\Model\\Order\\Invoice'; $invoice = $this->getMock($invoiceClassName, [], [], '', false); $this->request->expects($this->once())->method('getParam')->with('invoice_id')->willReturn($invoiceId); $this->objectManager->expects($this->at(0))->method('create')->with($invoiceClassName)->willReturn($invoice); $invoice->expects($this->once())->method('load')->with($invoiceId)->willReturn(null); $this->resultForwardFactory->expects($this->any())->method('create')->willReturn($this->resultForward); $this->resultForward->expects($this->once())->method('forward')->with('noroute')->willReturnSelf(); $this->assertInstanceOf('Magento\\Backend\\Model\\View\\Result\\Forward', $this->invoiceEmail->execute()); }