コード例 #1
0
ファイル: ResponseTest.php プロジェクト: nblair/magescotch
 public function testExecuteWithException()
 {
     $objectMock = $this->getMockBuilder('Magento\\Framework\\DataObject')->disableOriginalConstructor()->getMock();
     $this->transactionMock->expects($this->once())->method('getResponseObject')->willReturn($objectMock);
     $this->responseValidatorMock->expects($this->once())->method('validate')->with($objectMock)->willThrowException(new \Magento\Framework\Exception\LocalizedException(__('Error')));
     $this->coreRegistryMock->expects($this->once())->method('register')->with('transparent_form_params', $this->arrayHasKey('error'));
     $this->resultLayoutMock->expects($this->once())->method('addDefaultHandle')->willReturnSelf();
     $this->resultLayoutMock->expects($this->once())->method('getLayout')->willReturn($this->getLayoutMock());
     $this->assertInstanceOf('\\Magento\\Framework\\Controller\\ResultInterface', $this->object->executeInternal());
 }
コード例 #2
0
 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);
 }
コード例 #3
0
ファイル: Response.php プロジェクト: Doability/magento2dev
 /**
  * @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;
 }