public function testPrepareExecute()
 {
     $client = $this->getClient();
     $headers = array('User-Agent' => 'Twitter API Consumer (https://github.com/nixilla/twitter-api-consumer)', 'Authorization' => sprintf('Basic %s', 'YWFhYTpiYmJi'));
     $client->expects($this->at(0))->method('post')->with(sprintf('%s/oauth2/token', Consumer::API_ENDPOINT), $headers, 'grant_type=client_credentials')->will($this->returnValue($this->getResponse(200, array('token_type' => 'bearer', 'access_token' => 'abc1234'))));
     $query = new Query();
     $query->setHttpMethod('GET');
     $query->setApiMethod('1.1/search/tweets.json');
     $query->setHeaders(array('User-Agent' => 'Twitter API Consumer (https://github.com/nixilla/twitter-api-consumer)', 'Authorization' => sprintf('Bearer %s', 'abc1234')));
     $query->setQueryString(array('q' => urlencode('@nixilla')));
     $client->expects($this->at(1))->method('call')->with(sprintf('%s/1.1/search/tweets.json?%s', Consumer::API_ENDPOINT, http_build_query(array('q' => urlencode('@nixilla')))), 'GET', array('User-Agent' => 'Twitter API Consumer (https://github.com/nixilla/twitter-api-consumer)', 'Authorization' => sprintf('Bearer %s', 'abc1234')), '')->will($this->returnValue($this->getResponse(200, array('some value'))));
     $consumer = new Consumer($client, 'aaaa', 'bbbb');
     $q = $consumer->prepare('/1.1/search/tweets.json', RequestInterface::METHOD_GET, array('q' => urlencode('@nixilla')));
     $this->assertEquals($query, $q, 'These 2 objects are not the same');
     $result = $consumer->execute($q);
     $this->assertTrue($result instanceof Result, '$result is not instance of Twitter\\Result');
 }
 /**
  * @param $api_method
  * @param string $http_method
  * @param array $query_string
  * @param array $headers
  * @param string $content
  * @return QueryInterface
  */
 public function prepare($api_method, $http_method = 'GET', array $query_string = array(), $headers = array(), $content = '')
 {
     if (!$this->access_token) {
         $this->obtainBearerToken();
     }
     $query = new Query();
     $query->setApiMethod($this->normalizeApiMethod($api_method));
     $query->setHttpMethod($http_method);
     $query->setHeaders($this->getHeaders($headers));
     $query->setContent($content);
     $query->setQueryString($query_string);
     return $query;
 }