Esempio n. 1
0
 /**
  * {@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);
     }
 }
Esempio n. 2
0
 public function testExecuteException()
 {
     $this->setupCart();
     $exceptionMsg = new \Magento\Framework\Phrase('error');
     $exception = new \Magento\Framework\Exception\LocalizedException($exceptionMsg);
     $this->checkoutMock->expects($this->once())->method('place')->with(null)->willThrowException($exception);
     $this->messageManager->expects($this->once())->method('addError')->with($exceptionMsg);
     $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());
 }
Esempio n. 3
0
 public function testExecuteException()
 {
     $agreement = ['test-data'];
     $quote = $this->getQuoteMock();
     $quote->expects(self::once())->method('getItemsCount')->willReturn(0);
     $resultMock = $this->getResultMock();
     $resultMock->expects(self::once())->method('setPath')->with('checkout/cart')->willReturnSelf();
     $this->resultFactoryMock->expects(self::once())->method('create')->with(ResultFactory::TYPE_REDIRECT)->willReturn($resultMock);
     $this->requestMock->expects(self::once())->method('getPostValue')->with('agreement', [])->willReturn($agreement);
     $this->checkoutSessionMock->expects(self::once())->method('getQuote')->willReturn($quote);
     $this->orderPlaceMock->expects(self::never())->method('execute');
     $this->messageManagerMock->expects(self::once())->method('addExceptionMessage')->with(self::isInstanceOf('\\InvalidArgumentException'), 'We can\'t initialize checkout.');
     self::assertEquals($this->placeOrder->execute(), $resultMock);
 }