示例#1
0
 function testApiMakesRequestAndResponse()
 {
     $_SERVER = array_merge($_SERVER, array("REQUEST_METHOD" => "GET", "REQUEST_URI" => "/", "SCRIPT_NAME" => "/index.php", "PATH_INFO" => "", "QUERY_STRING" => "", "SERVER_NAME" => "localhost", "SERVER_PORT" => 80, "SERVER_PROTOCOL" => "HTTP/1.1", "ACCEPT" => "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", "ACCEPT_LANGUAGE" => "en-US,en;q=0.8", "ACCEPT_CHARSET" => "ISO-8859-1,utf-8;q=0.7,*;q=0.3", "USER_AGENT" => "Wilson Framework", "REMOTE_ADDR" => "127.0.0.1", "HTTPS" => "off"));
     $api = new Api();
     $api->testing = true;
     $api->dispatch();
 }
示例#2
0
 /**
  * Makes a request via the framework.
  *
  * @param string $method
  * @param string $uri
  * @param array $headers
  * @param array $get
  * @param array $post
  * @param string $content
  * @return \Wilson\Http\Response
  */
 protected function call($method, $uri, $headers = array(), $get = array(), $post = array(), $content = "")
 {
     $server = array_merge($headers, array("REQUEST_METHOD" => $method, "REQUEST_URI" => $uri));
     $response = new Response();
     $request = new Request();
     $request->mock($server, $get, $post, array(), array(), $content);
     $this->_api->dispatch($request, $response);
     return $response;
 }