Example #1
0
 /**
  * Method returns the response for the requested resource.
  *
  * @param string $pURL
  * @param array  $pOptions
  *
  * @return mixed
  */
 protected function requestResource($pURL, array $pOptions)
 {
     $options = array_replace_recursive($this->settings['defaults'], $pOptions);
     $format = $options['format'];
     $method = $options['method'];
     $this->setHeaders($options);
     $parameters['headers'] = $this->headers;
     if (isset($options['body'])) {
         $parameters['body'] = $this->formatBody($options);
     }
     try {
         $response = $this->client->request($method, $pURL, $parameters);
         $this->event->fire('forrest.response', [$response]);
         return $this->responseFormat($response, $format);
     } catch (RequestException $e) {
         $this->assignExceptions($e);
     }
     return '';
 }
Example #2
0
 function it_should_fire_a_response_event(ClientInterface $mockedClient, EventInterface $mockedEvent, RequestInterface $mockedRequest, ResponseInterface $mockedResponse)
 {
     $mockedClient->createRequest(Argument::any(), Argument::any(), Argument::any())->willReturn($mockedRequest);
     $mockedClient->send(Argument::any(), Argument::any(), Argument::any())->willReturn($mockedResponse);
     $mockedEvent->fire('forrest.response', Argument::any())->shouldBeCalled();
     $this->versions();
 }