/**
  * @inheritdoc
  */
 public function execute()
 {
     $isAjax = $this->getRequest()->getParam('isAjax');
     $quote = $this->checkoutSession->getQuote();
     try {
         $this->validateQuote($quote);
         $this->shippingMethodUpdater->execute($this->getRequest()->getParam('shipping_method'), $quote);
         if ($isAjax) {
             /** @var Page $response */
             $response = $this->resultFactory->create(ResultFactory::TYPE_PAGE);
             $layout = $response->addHandle('paypal_express_review_details')->getLayout();
             $response = $layout->getBlock('page.block')->toHtml();
             $this->getResponse()->setBody($response);
             return;
         }
     } catch (\Exception $e) {
         $this->messageManager->addExceptionMessage($e, $e->getMessage());
     }
     $path = $this->_url->getUrl('*/*/review', ['_secure' => true]);
     if ($isAjax) {
         $this->getResponse()->setBody(sprintf('<script>window.location.href = "%s";</script>', $path));
         return;
     }
     $this->_redirect($path);
 }
 public function testExecute()
 {
     $quoteMock = $this->getQuoteMock();
     $quoteMock->expects(self::exactly(2))->method('getIsVirtual')->willReturn(false);
     $quoteMock->expects(self::exactly(2))->method('getShippingAddress')->willReturn($this->shippingAddressMock);
     $this->shippingAddressMock->expects(self::once())->method('getShippingMethod')->willReturn(self::TEST_SHIPPING_METHOD . '-bad');
     $this->disabledQuoteAddressValidationStep($quoteMock);
     $this->shippingAddressMock->expects(self::once())->method('setShippingMethod')->willReturn(self::TEST_SHIPPING_METHOD);
     $this->shippingAddressMock->expects(self::once())->method('setCollectShippingRates')->willReturn(true);
     $quoteMock->expects(self::once())->method('collectTotals');
     $this->quoteRepositoryMock->expects(self::once())->method('save')->with($quoteMock);
     $this->shippingMethodUpdater->execute(self::TEST_SHIPPING_METHOD, $quoteMock);
 }