Exemple #1
0
 function it_returns_a_processed_resource(ResponseInterface $response, HttpClient $httpClient, Processor $processor)
 {
     $response->getHeader('content-type')->willReturn(['application/hal+json']);
     $resource = new Resource([], []);
     $httpClient->get('http://api.test.com/')->willReturn($response);
     $processor->process($response, $this)->willReturn($resource);
     $this->get('http://api.test.com/')->shouldReturn($resource);
 }
Exemple #2
0
 public function get($url)
 {
     $response = $this->httpClient->get($url);
     $contentTypes = $response->getHeader('content-type');
     $contentType = array_shift($contentTypes);
     if (!array_key_exists($contentType, $this->processors)) {
         throw new UnknownContentTypeException($contentType);
     }
     $processor = $this->processors[$contentType];
     return $processor->process($response, $this);
 }
Exemple #3
0
 /**
  * @Given a :method endpoint :url which returns content type :contentType and body:
  */
 public function aEndpointWhichReturnsContentTypeAndBody($method, $url, $contentType, PyStringNode $body)
 {
     $this->httpClient->createEndpoint($method, $url, $contentType, (string) $body);
 }