public function testExecuteGuest()
 {
     $agreement = ['test', 'test'];
     $quoteMock = $this->getQuoteMock();
     $this->agreementsValidatorMock->expects(self::once())->method('isValid')->willReturn(true);
     $this->getCheckoutMethodStep($quoteMock);
     $this->prepareGuestQuoteStep($quoteMock);
     $this->disabledQuoteAddressValidationStep($quoteMock);
     $quoteMock->expects(self::once())->method('collectTotals');
     $quoteMock->expects(self::once())->method('getId')->willReturn(10);
     $this->cartManagementMock->expects(self::once())->method('placeOrder')->with(10);
     $this->orderPlace->execute($quoteMock, $agreement);
 }
Exemple #2
0
 /**
  * @inheritdoc
  * @throws LocalizedException
  */
 public function execute()
 {
     $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
     $agreement = array_keys($this->getRequest()->getPostValue('agreement', []));
     $quote = $this->checkoutSession->getQuote();
     try {
         $this->validateQuote($quote);
         $this->orderPlace->execute($quote, $agreement);
         /** @var \Magento\Framework\Controller\Result\Redirect $resultRedirect */
         return $resultRedirect->setPath('checkout/onepage/success', ['_secure' => true]);
     } catch (\Exception $e) {
         $this->messageManager->addExceptionMessage($e, $e->getMessage());
     }
     return $resultRedirect->setPath('checkout/cart', ['_secure' => true]);
 }
 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);
 }