RequestTest

Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.

Defined (1)

The class is defined in the following location(s).

/vendor/google/apiclient/tests/general/RequestTest.php  
  1. class RequestTest extends BaseTest 
  2. public function testRequestParameters() 
  3. $url = 'http://localhost:8080/foo/bar?foo=a&foo=b&wowee=oh+my'; 
  4. $url2 = 'http://localhost:8080/foo/bar?foo=a&foo=b&wowee=oh+my&hi=there'; 
  5. $request = new Google_Http_Request($url); 
  6. $request->setExpectedClass("Google_Client"); 
  7. $this->assertEquals(2, count($request->getQueryParams())); 
  8. $request->setQueryParam("hi", "there"); 
  9. $this->assertEquals($url2, $request->getUrl()); 
  10. $this->assertEquals("Google_Client", $request->getExpectedClass()); 
  11.  
  12. $urlPath = "/foo/bar"; 
  13. $request = new Google_Http_Request($urlPath); 
  14. $this->assertEquals($urlPath, $request->getUrl()); 
  15. $request->setBaseComponent("http://example.com"); 
  16. $this->assertEquals("http://example.com" . $urlPath, $request->getUrl()); 
  17.  
  18. $url3a = 'http://localhost:8080/foo/bar'; 
  19. $url3b = 'foo=a&foo=b&wowee=oh+my'; 
  20. $url3c = 'foo=a&foo=b&wowee=oh+my&hi=there'; 
  21. $request = new Google_Http_Request($url3a."?".$url3b, "POST"); 
  22. $request->setQueryParam("hi", "there"); 
  23. $request->maybeMoveParametersToBody(); 
  24. $this->assertEquals($url3a, $request->getUrl()); 
  25. $this->assertEquals($url3c, $request->getPostBody()); 
  26.  
  27. $url4 = 'http://localhost:8080/upload/foo/bar?foo=a&foo=b&wowee=oh+my&hi=there'; 
  28. $request = new Google_Http_Request($url); 
  29. $this->assertEquals(2, count($request->getQueryParams())); 
  30. $request->setQueryParam("hi", "there"); 
  31. $base = $request->getBaseComponent(); 
  32. $request->setBaseComponent($base . '/upload'); 
  33. $this->assertEquals($url4, $request->getUrl()); 
  34.  
  35. public function testGzipSupport() 
  36. $url = 'http://localhost:8080/foo/bar?foo=a&foo=b&wowee=oh+my'; 
  37. $request = new Google_Http_Request($url); 
  38. $request->enableGzip(); 
  39. $this->assertStringEndsWith(Google_Http_Request::GZIP_UA, $request->getUserAgent()); 
  40. $this->assertArrayHasKey('accept-encoding', $request->getRequestHeaders()); 
  41. $this->assertTrue($request->canGzip()); 
  42. $request->disableGzip(); 
  43. $this->assertStringEndsNotWith(Google_Http_Request::GZIP_UA, $request->getUserAgent()); 
  44. $this->assertArrayNotHasKey('accept-encoding', $request->getRequestHeaders()); 
  45. $this->assertFalse($request->canGzip());