Example #1
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;
 }
Example #2
0
 function testSendCookies()
 {
     $cookie = new Cookie("name", "value");
     $this->response->addCookie($cookie);
     $this->request->mock();
     $this->send();
     $expected = array("HTTP/1.1 200 OK", "Date: " . $this->response->getHeader("Date"), "Content-Length: 0", "Set-Cookie: " . $cookie);
     $this->assertEquals($expected, HeaderStack::stack());
 }
Example #3
0
 /**
  * Test parses query string
  *
  * Pre-conditions:
  * $_SERVER['QUERY_STRING'] does not exist;
  */
 public function testParsesQueryStringThatDoesNotExist()
 {
     $req = new Request();
     $req->mock();
     $this->assertEquals("", $req->getQueryString());
 }
Example #4
0
 function testMethodNotAllowedDispatch()
 {
     $this->request->mock(array("REQUEST_URI" => "/route-1", "REQUEST_METHOD" => "POST"));
     $this->assertEmpty($this->dispatch());
     $this->assertEquals(405, $this->response->getStatus());
 }