function test_createResponse()
 {
     $target = new MessageFactory();
     $response = $target->createResponse(200, ['Content-type' => 'text/html;charset=UTF-8'], 'OK');
     $this->assertInstanceOf('FunctionalTester\\Message\\Response', $response);
     $this->assertEquals(200, $response->getStatusCode());
 }
Exemplo n.º 2
0
 /**
  * @param string $method
  * @param string $scriptFile
  * @param null|array $parameters
  * @param null|array $options
  * @param null $files
  * @return Response
  */
 public function request($method, $scriptFile, $parameters = null, $options = null, $files = null)
 {
     $execFile = $this->generateExecFile($scriptFile);
     $defaultOptions = ['SCRIPT_FILENAME' => $execFile, 'CONTENT_TYPE' => 'application/x-www-form-urlencoded', 'REQUEST_METHOD' => $method, 'REDIRECT_STATUS' => 'CGI'];
     if ($files) {
         $reqBody = $this->generateStringForMultiPart($parameters, $files);
         $defaultOptions['CONTENT_TYPE'] = 'multipart/form-data; boundary=' . $this->boundary;
     } else {
         $reqBody = $parameters ? http_build_query($parameters) : "";
     }
     $defaultOptions['CONTENT_LENGTH'] = strlen($reqBody);
     $this->setEnv($defaultOptions);
     if ($options) {
         $this->setEnv($options);
     }
     $envStr = $this->makeEnvString();
     $phpOptionsStr = $this->makePhpOptionsString();
     $responseMessage = $this->send($reqBody, $envStr, $phpOptionsStr);
     unlink($execFile);
     return $this->messageFactory->fromMessage($responseMessage);
 }