/** * {@inheritdoc} */ public function dispatch(\Magento\Framework\App\RequestInterface $request) { $pluginInfo = $this->pluginList->getNext($this->subjectType, 'dispatch'); if (!$pluginInfo) { return parent::dispatch($request); } else { return $this->___callPlugins('dispatch', func_get_args(), $pluginInfo); } }
/** * @return void */ public function testExecuteException() { $invoiceId = 2; $message = 'Invoice canceling error'; $e = new \Exception($message); $this->requestMock->expects($this->once()) ->method('getParam') ->with('invoice_id') ->will($this->returnValue($invoiceId)); $invoiceMock = $this->getMockBuilder('Magento\Sales\Model\Order\Invoice') ->disableOriginalConstructor() ->setMethods([]) ->getMock(); $invoiceMock->expects($this->once()) ->method('cancel') ->will($this->throwException($e)); $this->messageManagerMock->expects($this->once()) ->method('addError') ->with($message); $invoiceMock->expects($this->once()) ->method('getId') ->will($this->returnValue($invoiceId)); $invoiceRepository = $this->getMockBuilder('Magento\Sales\Api\InvoiceRepositoryInterface') ->disableOriginalConstructor() ->getMock(); $invoiceRepository->expects($this->any()) ->method('get') ->willReturn($invoiceMock); $this->objectManagerMock->expects($this->once()) ->method('create') ->with('Magento\Sales\Api\InvoiceRepositoryInterface') ->willReturn($invoiceRepository); $resultRedirect = $this->getMockBuilder('Magento\Backend\Model\View\Result\Redirect') ->disableOriginalConstructor() ->setMethods([]) ->getMock(); $resultRedirect->expects($this->once())->method('setPath')->with('sales/*/view', ['invoice_id' => $invoiceId]); $this->resultRedirectFactoryMock->expects($this->once()) ->method('create') ->will($this->returnValue($resultRedirect)); $this->assertSame($resultRedirect, $this->controller->executeInternal()); }
public function testExecuteException() { $orderId = 1; $invoiceId = 2; $invoiceData = []; $message = 'Invoice canceling error'; $e = new \Exception($message); $this->requestMock->expects($this->at(0))->method('getParam')->with('order_id')->will($this->returnValue($orderId)); $this->requestMock->expects($this->at(1))->method('getParam')->with('invoice_id')->will($this->returnValue($invoiceId)); $this->requestMock->expects($this->at(2))->method('getParam')->with('invoice')->will($this->returnValue($invoiceData)); $invoiceMock = $this->getMockBuilder('Magento\\Sales\\Model\\Order\\Invoice')->disableOriginalConstructor()->setMethods([])->getMock(); $invoiceMock->expects($this->once())->method('cancel')->will($this->throwException($e)); $this->messageManagerMock->expects($this->once())->method('addError')->with($message); $this->invoiceLoaderMock->expects($this->once())->method('load')->with($orderId, $invoiceId, $invoiceData)->will($this->returnValue($invoiceMock)); $this->assertNull($this->controller->execute()); }