Esempio n. 1
0
 public function testToHttpRequestWithDefaultContentType()
 {
     $request = new Request();
     $request->setMethod(Request::METHOD_POST);
     $endpoint = new Endpoint();
     $endpoint->setTimeout(10);
     $httpRequest = $this->adapter->toHttpRequest($request, $endpoint);
     $this->assertEquals(array('timeout' => 10, 'connecttimeout' => 10, 'dns_cache_timeout' => 10, 'headers' => array('Content-Type' => 'text/xml; charset=utf-8')), $httpRequest->getOptions());
 }
 public function testExecuteWithFileUpload()
 {
     $request = new Request();
     $request->setMethod(Request::METHOD_POST);
     $request->setFileUpload(__FILE__);
     $endpoint = new Endpoint();
     $response = new \Zend_Http_Response(200, array('status' => 'HTTP 1.1 200 OK'), 'dummy');
     $mock = $this->getMock('Zend_Http_Client');
     $mock->expects($this->once())->method('setFileUpload')->with($this->equalTo('content'), $this->equalTo('content'), $this->equalTo(file_get_contents(__FILE__)), $this->equalTo('application/octet-stream; charset=binary'));
     $mock->expects($this->once())->method('request')->will($this->returnValue($response));
     $this->adapter->setZendHttp($mock);
     $this->adapter->execute($request, $endpoint);
 }
Esempio n. 3
0
 public function testCreateContextWithAuthorization()
 {
     $timeout = 13;
     $method = Request::METHOD_HEAD;
     $request = new Request();
     $request->setMethod($method);
     $request->setAuthentication('someone', 'S0M3p455');
     $endpoint = new Endpoint();
     $endpoint->setTimeout($timeout);
     $context = $this->adapter->createContext($request, $endpoint);
     $this->assertEquals(array('http' => array('method' => $method, 'timeout' => $timeout, 'header' => 'Authorization: Basic c29tZW9uZTpTME0zcDQ1NQ==')), stream_context_get_options($context));
 }
Esempio n. 4
0
 public function testSetAndGetMethod()
 {
     $this->request->setMethod(Request::METHOD_POST);
     $this->assertEquals(Request::METHOD_POST, $this->request->getMethod());
 }