/** * {@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() { $result = '{}'; $quoteMock = $this->getQuoteMock(); $resultRedirectMock = $this->getResultRedirectMock(); $quoteMock->expects(self::once())->method('getItemsCount')->willReturn(1); $this->requestMock->expects(self::once())->method('getPostValue')->with('result', '{}')->willReturn($result); $this->checkoutSessionMock->expects(self::once())->method('getQuote')->willReturn($quoteMock); $this->quoteUpdaterMock->expects(self::never())->method('execute'); $this->messageManagerMock->expects(self::once())->method('addExceptionMessage')->with(self::isInstanceOf('\\InvalidArgumentException'), 'Data of request cannot be empty.'); $this->resultFactoryMock->expects(self::once())->method('create')->with(ResultFactory::TYPE_REDIRECT)->willReturn($resultRedirectMock); $resultRedirectMock->expects(self::once())->method('setPath')->with('checkout/cart')->willReturnSelf(); self::assertEquals($this->review->execute(), $resultRedirectMock); }
public function testExecuteExceptionPaymentWithoutNonce() { $result = '{}'; $quoteMock = $this->getQuoteMock(); $resultRedirectMock = $this->getResultRedirectMock(); $quoteMock->expects(self::once())->method('getItemsCount')->willReturn(1); $paymentMock = $this->getMockBuilder(\Magento\Quote\Model\Quote\Payment::class)->disableOriginalConstructor()->getMock(); $quoteMock->expects(self::once())->method('getPayment')->willReturn($paymentMock); $this->requestMock->expects(self::once())->method('getPostValue')->with('result', '{}')->willReturn($result); $this->checkoutSessionMock->expects(self::once())->method('getQuote')->willReturn($quoteMock); $this->messageManagerMock->expects(self::once())->method('addExceptionMessage')->with(self::isInstanceOf(\Magento\Framework\Exception\LocalizedException::class), 'We can\'t initialize checkout.'); $this->resultFactoryMock->expects(self::once())->method('create')->with(ResultFactory::TYPE_REDIRECT)->willReturn($resultRedirectMock); $resultRedirectMock->expects(self::once())->method('setPath')->with('checkout/cart')->willReturnSelf(); self::assertEquals($this->review->execute(), $resultRedirectMock); }
public function testExecuteException() { $paymentMethodNonce = 'nonce'; $email = '*****@*****.**'; $billingAddress = ['someAddress']; $details = ['email' => $email, 'billingAddress' => $billingAddress]; $detailsEncoded = json_encode($details); $this->requestMock->expects($this->at(0))->method('getParam')->with('payment_method_nonce')->willReturn($paymentMethodNonce); $this->requestMock->expects($this->at(1))->method('getParam')->with('details')->willReturn($detailsEncoded); $this->setupCart(); $errorMsg = new \Magento\Framework\Phrase('error'); $exception = new \Magento\Framework\Exception\LocalizedException($errorMsg); $this->messageManagerMock->expects($this->once())->method('addExceptionMessage')->with($exception, $errorMsg); $this->checkoutMock->expects($this->once())->method('initializeQuoteForReview')->with($paymentMethodNonce, ['email' => $email])->willThrowException($exception); $resultRedirect = $this->getMockBuilder('\\Magento\\Framework\\Controller\\Result\\Redirect')->disableOriginalConstructor()->getMock(); $resultRedirect->expects($this->once())->method('setPath')->with('checkout/cart')->willReturnSelf(); $this->resultFactoryMock->expects($this->once())->method('create')->with(\Magento\Framework\Controller\ResultFactory::TYPE_REDIRECT)->willReturn($resultRedirect); $this->assertEquals($resultRedirect, $this->controller->execute()); }