コード例 #1
0
 /**
  * creates instance to test
  *
  * @param   string  $queryString
  * @return  HttpRequest
  */
 private function createHttpRequest(string $queryString = null) : HttpRequest
 {
     $socket = NewInstance::stub(Stream::class)->mapCalls(['write' => function (string $line) {
         $this->memory .= $line;
         return strlen($line);
     }]);
     $uriCalls = ['openSocket' => $socket, 'path' => '/foo/resource', 'hostname' => 'example.com'];
     if (null !== $queryString) {
         $uriCalls['hasQueryString'] = true;
         $uriCalls['queryString'] = $queryString;
     } else {
         $uriCalls['hasQueryString'] = false;
     }
     return HttpRequest::create(NewInstance::stub(HttpUri::class)->mapCalls($uriCalls), new HeaderList(['X-Binford' => 6100]));
 }
コード例 #2
0
 /**
  * returns response object for given URI after DELETE request
  *
  * @api
  * @param   string  $version  optional  http version, defaults to HTTP/1.1
  * @return  \stubbles\peer\http\HttpResponse
  * @since   2.0.0
  */
 public function delete(string $version = HttpVersion::HTTP_1_1) : HttpResponse
 {
     return HttpRequest::create($this->httpUri, $this->headers)->delete($this->timeout, $version);
 }