public function testExecute()
 {
     $_FILES['test_key'] = [];
     $result = ['file' => '', 'url' => ''];
     $resultJson = '{"file": "", "url": ""}';
     $this->imageProcessor->expects($this->once())->method('saveToTmp')->with('test_key')->willReturn($result);
     $this->resultFactory->expects($this->once())->method('create')->with(ResultFactory::TYPE_JSON)->willReturn($this->resultPage);
     $this->resultPage->expects($this->once())->method('setData')->with($result)->willReturn($resultJson);
     $this->assertEquals($resultJson, $this->controller->execute());
 }
 /**
  * @covers \Magento\BraintreeTwo\Controller\Payment\GetNonce::execute
  */
 public function testExecute()
 {
     $customerId = 1;
     $publicHash = '65b7bae0dcb690d93';
     $nonce = 'f1hc45';
     $this->request->expects(static::once())->method('getParam')->with('public_hash')->willReturn($publicHash);
     $this->session->expects(static::once())->method('getCustomerId')->willReturn($customerId);
     $this->commandResult->expects(static::once())->method('get')->willReturn(['paymentMethodNonce' => $nonce]);
     $this->command->expects(static::once())->method('execute')->willReturn($this->commandResult);
     $this->result->expects(static::once())->method('setData')->with(['paymentMethodNonce' => $nonce]);
     $this->logger->expects(static::never())->method('critical');
     $this->result->expects(static::never())->method('setHttpResponseCode');
     $this->action->execute();
 }
 /**
  * Return response for bad request
  * @param ResultInterface $response
  * @return ResultInterface
  */
 private function processBadRequest(ResultInterface $response)
 {
     $response->setHttpResponseCode(Exception::HTTP_BAD_REQUEST);
     $response->setData(['message' => __('Sorry, but something went wrong')]);
     return $response;
 }
Exemple #4
0
 public function testExecuteToBeRedirect()
 {
     $this->requestMock->expects($this->once())->method('getParam')->willReturn(false);
     $this->resultMock->expects($this->once())->method('forward')->with('noroute')->willReturn(true);
     $this->assertSame(true, $this->model->execute());
 }
 /**
  * @param ResultInterface $controllerResult
  * @return ResultInterface
  */
 private function getErrorResponse(ResultInterface $controllerResult)
 {
     $controllerResult->setHttpResponseCode(Exception::HTTP_BAD_REQUEST);
     $controllerResult->setData(['message' => __('Sorry, but something went wrong')]);
     return $controllerResult;
 }