Example #1
0
 public function setUp()
 {
     $this->entryText = file_get_contents('ZendGData/App/_files/EntrySample1.xml', true);
     $this->httpEntrySample = file_get_contents('ZendGData/App/_files/EntrySampleHttp1.txt', true);
     $this->entry = new App\Entry();
     $this->adapter = new \ZendGDataTest\TestAsset\MockHttpClient();
     $this->client = new HttpClient();
     $this->client->setAdapter($this->adapter);
     $this->service = new App($this->client);
 }
Example #2
0
 public function setUp()
 {
     $this->fileName = __DIR__ . '/App/_files/FeedSample1.xml';
     $this->expectedEtagValue = 'W/"CkcHQH8_fCp7ImA9WxRTGEw."';
     $this->expectedMajorProtocolVersion = 1;
     $this->expectedMinorProtocolVersion = 2;
     $this->httpEntrySample = file_get_contents(__DIR__ . '/_files/AppSample1.txt', true);
     $this->httpEntrySampleWithoutVersion = file_get_contents(__DIR__ . '/_files/AppSample2.txt', true);
     $this->httpFeedSample = file_get_contents(__DIR__ . '/_files/AppSample3.txt', true);
     $this->httpFeedSampleWithoutVersion = file_get_contents(__DIR__ . '/_files/AppSample4.txt', true);
     $this->adapter = new TestAsset\MockHttpClient();
     $this->client = new HttpClient();
     $this->client->setAdapter($this->adapter);
     $this->service = new App($this->client);
 }
Example #3
0
 /**
  * Performs a HTTP request using the specified method.
  *
  * Overrides the definition in the parent (ZendGData\App)
  * and uses the ZendGData\HttpClient functionality
  * to filter the HTTP requests and responses.
  *
  * @param string $method The HTTP method for the request -
  *                       'GET', 'POST', 'PUT', 'DELETE'
  * @param string $url The URL to which this request is being performed,
  *                    or null if found in $data
  * @param array $headers An associative array of HTTP headers
  *                       for this request
  * @param string $body The body of the HTTP request
  * @param string $contentType The value for the content type of the
  *                            request body
  * @param int $remainingRedirects Number of redirects to follow
  *                                if requests results in one
  * @return \Zend\Http\Response The response object
  */
 public function performHttpRequest($method, $url, $headers = array(), $body = null, $contentType = null, $remainingRedirects = null)
 {
     if ($this->_httpClient instanceof HttpClient) {
         $filterResult = $this->_httpClient->filterHttpRequest($method, $url, $headers, $body, $contentType);
         $method = $filterResult['method'];
         $url = $filterResult['url'];
         $body = $filterResult['body'];
         $headers = $filterResult['headers'];
         $contentType = $filterResult['contentType'];
         return $this->_httpClient->filterHttpResponse(parent::performHttpRequest($method, $url, $headers, $body, $contentType, $remainingRedirects));
     } else {
         return parent::performHttpRequest($method, $url, $headers, $body, $contentType, $remainingRedirects);
     }
 }
Example #4
0
 /**
  * @expectedException ZendGData\App\HttpException
  */
 public function testGetAuthSubTokenInfoCatchesHttpClientException()
 {
     $adapter = new AdapterTest();
     $adapter->setNextRequestWillFail(true);
     $client = new HttpClient();
     $client->setUri('http://example.com/AuthSub');
     $client->setAdapter($adapter);
     $revoked = AuthSub::getAuthSubTokenInfo($this->token, $client);
 }
Example #5
0
 /**
  * Retrieve a HTTP client object with AuthSub credentials attached
  * as the Authorization header
  *
  * @param string $token The token to retrieve information about
  * @param HttpClient $client (optional) HTTP client to use to make the request
  * @return HttpClient
  */
 public static function getHttpClient($token, HttpClient $client = null)
 {
     if ($client == null) {
         $client = new HttpClient();
     }
     $useragent = App::getUserAgentString();
     $client->setOptions(array('strictredirects' => true, 'useragent' => $useragent));
     $client->setAuthSubToken($token);
     return $client;
 }