Ejemplo n.º 1
0
 /**
  * Makes a request, and returns a response object.
  *
  * You can either pass an instance of Sabre\HTTP\Request, or an array,
  * which will then be used as the _SERVER array.
  *
  * @param array|\Sabre\HTTP\Request $request
  * @return \Sabre\HTTP\Response
  */
 function request($request)
 {
     if (is_array($request)) {
         $request = HTTP\Request::createFromServerArray($request);
     }
     $this->server->httpRequest = $request;
     $this->server->httpResponse = new HTTP\ResponseMock();
     $this->server->exec();
     return $this->server->httpResponse;
 }
Ejemplo n.º 2
0
 /**
  * Makes a request, and returns a response object.
  *
  * You can either pass an instance of Sabre\HTTP\Request, or an array,
  * which will then be used as the _SERVER array.
  *
  * If $expectedStatus is set, we'll compare it with the HTTP status of
  * the returned response. If it doesn't match, we'll immediately fail
  * the test.
  *
  * @param array|\Sabre\HTTP\Request $request
  * @param int $expectedStatus
  * @return \Sabre\HTTP\Response
  */
 function request($request, $expectedStatus = null)
 {
     if (is_array($request)) {
         $request = HTTP\Request::createFromServerArray($request);
     }
     $response = new HTTP\ResponseMock();
     $this->server->httpRequest = $request;
     $this->server->httpResponse = $response;
     $this->server->exec();
     if ($expectedStatus) {
         $responseBody = $expectedStatus !== $response->getStatus() ? $response->getBodyAsString() : '';
         $this->assertEquals($expectedStatus, $response->getStatus(), 'Incorrect HTTP status received for request. Response body: ' . $responseBody);
     }
     return $this->server->httpResponse;
 }