Exemplo n.º 1
0
 public function testExecutePost()
 {
     $method = Request::METHOD_POST;
     $rawData = 'xyz';
     $responseData = 'abc';
     $handler = 'myhandler';
     $headers = array('X-test: 123');
     $params = array('a' => 1, 'b' => 2);
     $request = new Request();
     $request->setMethod($method);
     $request->setHandler($handler);
     $request->setHeaders($headers);
     $request->setRawData($rawData);
     $request->setParams($params);
     $endpoint = new Endpoint();
     $response = new \Zend_Http_Response(200, array('status' => 'HTTP 1.1 200 OK'), $responseData);
     $mock = $this->getMock('Zend_Http_Client');
     $mock->expects($this->once())->method('setMethod')->with($this->equalTo($method));
     $mock->expects($this->once())->method('setUri')->with($this->equalTo('http://127.0.0.1:8983/solr/myhandler'));
     $mock->expects($this->once())->method('setHeaders')->with($this->equalTo(array('X-test: 123', 'Content-Type: text/xml; charset=UTF-8')));
     $mock->expects($this->once())->method('setRawData')->with($this->equalTo($rawData));
     $mock->expects($this->once())->method('setParameterGet')->with($this->equalTo($params));
     $mock->expects($this->once())->method('request')->will($this->returnValue($response));
     $this->adapter->setZendHttp($mock);
     $adapterResponse = $this->adapter->execute($request, $endpoint);
     $this->assertEquals($responseData, $adapterResponse->getBody());
 }
Exemplo n.º 2
0
 public function testCreateContextPostRequest()
 {
     $timeout = 13;
     $method = Request::METHOD_POST;
     $data = 'test123';
     $request = new Request();
     $request->setMethod($method);
     $request->setRawData($data);
     $endpoint = new Endpoint();
     $endpoint->setTimeout($timeout);
     $context = $this->adapter->createContext($request, $endpoint);
     $this->assertEquals(array('http' => array('method' => $method, 'timeout' => $timeout, 'content' => $data, 'header' => 'Content-Type: text/xml; charset=UTF-8')), stream_context_get_options($context));
 }
Exemplo n.º 3
0
 public function testGetAndSetRawData()
 {
     $data = '1234567890';
     $this->request->setRawData($data);
     $this->assertEquals($data, $this->request->getRawData());
 }