/** * {@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); } }
public function testExecuteException() { $redirectPath = 'path/to/redirect'; $quoteMock = $this->getQuoteMock(); $quoteMock->expects(self::once())->method('getItemsCount')->willReturn(0); $this->requestMock->expects(self::exactly(1))->method('getParam')->willReturnMap([['isAjax', null, true]]); $this->checkoutSessionMock->expects(self::once())->method('getQuote')->willReturn($quoteMock); $this->shippingMethodUpdaterMock->expects(self::never())->method('execute'); $this->messageManagerMock->expects(self::once())->method('addExceptionMessage')->with(self::isInstanceOf('\\InvalidArgumentException'), 'We can\'t initialize checkout.'); $this->urlMock->expects(self::once())->method('getUrl')->with('*/*/review', ['_secure' => true])->willReturn($redirectPath); $this->responseMock->expects(self::once())->method('setBody')->with(sprintf('<script>window.location.href = "%s";</script>', $redirectPath)); $this->saveShippingMethod->execute(); }
public function testExecuteException() { $html = '<script>window.location.href = ' . self::REVIEW_URL . ';</script>'; $shippingMethod = 'flat_rate'; $this->requestMock->expects($this->at(0))->method('getParam')->with('isAjax')->willReturn(true); $this->requestMock->expects($this->at(1))->method('getParam')->with('shipping_method')->willReturn($shippingMethod); $this->setupCart(); $exceptionMsg = new \Magento\Framework\Phrase('error'); $exception = new \Magento\Framework\Exception\LocalizedException($exceptionMsg); $this->checkoutMock->expects($this->once())->method('updateShippingMethod')->with($shippingMethod)->willThrowException($exception); $this->messageManager->expects($this->once())->method('addExceptionMessage')->with($exception, $exceptionMsg); $this->responseMock->expects($this->once())->method('setBody')->with($html); $this->controller->execute(); }