public function testSavePaymentInQuote() { $quoteId = 1; $response = new DataObject(); $payment = $this->getMockBuilder('Magento\\Quote\\Model\\Quote\\Payment')->disableOriginalConstructor()->getMock(); $payment->expects($this->once())->method('setAdditionalInformation')->with('pnref'); $this->errorHandlerMock->expects($this->once())->method('handle')->with($payment, $response); $quote = $this->getMock('Magento\\Quote\\Api\\Data\\CartInterface', [], [], '', false); $quote->expects($this->exactly(2))->method('getId')->willReturn($quoteId); $this->sessionTransparent->expects($this->once())->method('getQuoteId')->willReturn($quoteId); $this->quoteRepository->expects($this->once())->method('get')->willReturn($quote); $this->paymentMethodManagementInterface->expects($this->once())->method('get')->willReturn($payment); $this->paymentMethodManagementInterface->expects($this->once())->method('set'); $this->model->savePaymentInQuote($response); }
/** * @return ResultInterface */ public function execute() { $parameters = []; try { $response = $this->transaction->getResponseObject($this->getRequest()->getPostValue()); $this->responseValidator->validate($response, $this->transparent); $this->transaction->savePaymentInQuote($response); } catch (LocalizedException $exception) { $parameters['error'] = true; $parameters['error_msg'] = $exception->getMessage(); } $this->coreRegistry->register(Iframe::REGISTRY_KEY, $parameters); $resultLayout = $this->resultLayoutFactory->create(); $resultLayout->addDefaultHandle(); $resultLayout->getLayout()->getUpdate()->load(['transparent_payment_response']); return $resultLayout; }