Пример #1
0
 /**
  * @Given /^the response should be "([^"]*)"$/
  * @param string $string
  * @return void
  * @throws \Exception
  */
 public function theResponseShouldBe($string)
 {
     $data = $this->response->getBody(true);
     if ($string != $data) {
         throw new \Exception(sprintf("Unexpected response.\nExpected response:%s\nActual response:\n%s" . $string, $data));
     }
 }
 /**
  * {@inheritDoc}
  *
  * @internal The current user endpoint gives a redirection, so we need to
  *     override the HTTP call to avoid redirections.
  */
 protected function fetchUserDetails(TokenCredentials $tokenCredentials, $force = true)
 {
     if (!$this->cachedUserDetailsResponse || $force) {
         try {
             $this->request($this->urlUserDetails(), $tokenCredentials, array('options' => array('allow_redirects' => false)));
         } catch (BadResponseException $e) {
             throw new \Exception($e->getMessage());
         }
         switch ($this->responseType) {
             case 'json':
                 $this->cachedUserDetailsResponse = $this->response->json();
                 break;
             case 'xml':
                 $this->cachedUserDetailsResponse = $this->response->xml();
                 break;
             case 'string':
                 parse_str($this->response->getBody(), $this->cachedUserDetailsResponse);
                 break;
             default:
                 throw new \InvalidArgumentException("Invalid response type [{$this->responseType}].");
         }
     }
     return $this->cachedUserDetailsResponse;
 }