Exemple #1
0
 public function testRequestParameters()
 {
     $url = 'http://localhost:8080/foo/bar?foo=a&foo=b&wowee=oh+my';
     $url2 = 'http://localhost:8080/foo/bar?foo=a&foo=b&wowee=oh+my&hi=there';
     $request = new Postman_Google_Http_Request($url);
     $request->setExpectedClass("Postman_Google_Client");
     $this->assertEquals(2, count($request->getQueryParams()));
     $request->setQueryParam("hi", "there");
     $this->assertEquals($url2, $request->getUrl());
     $this->assertEquals("Postman_Google_Client", $request->getExpectedClass());
     $urlPath = "/foo/bar";
     $request = new Postman_Google_Http_Request($urlPath);
     $this->assertEquals($urlPath, $request->getUrl());
     $request->setBaseComponent("http://example.com");
     $this->assertEquals("http://example.com" . $urlPath, $request->getUrl());
     $url3a = 'http://localhost:8080/foo/bar';
     $url3b = 'foo=a&foo=b&wowee=oh+my';
     $url3c = 'foo=a&foo=b&wowee=oh+my&hi=there';
     $request = new Postman_Google_Http_Request($url3a . "?" . $url3b, "POST");
     $request->setQueryParam("hi", "there");
     $request->maybeMoveParametersToBody();
     $this->assertEquals($url3a, $request->getUrl());
     $this->assertEquals($url3c, $request->getPostBody());
     $url4 = 'http://localhost:8080/upload/foo/bar?foo=a&foo=b&wowee=oh+my&hi=there';
     $request = new Postman_Google_Http_Request($url);
     $this->assertEquals(2, count($request->getQueryParams()));
     $request->setQueryParam("hi", "there");
     $base = $request->getBaseComponent();
     $request->setBaseComponent($base . '/upload');
     $this->assertEquals($url4, $request->getUrl());
 }
 private function transformToUploadUrl()
 {
     $base = $this->request->getBaseComponent();
     $this->request->setBaseComponent($base . '/upload');
 }