public function testClearHeaders() { $headers = array('User-Agent: My Agent', 'Cache-Control: no-cache'); $this->_request->setHeaders($headers); $this->assertEquals($headers, $this->_request->getHeaders()); $this->_request->clearHeaders(); $this->assertEquals(array(), $this->_request->getHeaders()); }
public function testExecute() { $method = Solarium_Client_Request::METHOD_GET; $rawData = 'xyz'; $responseData = 'abc'; $handler = 'myhandler'; $headers = array('Content-Type: application/x-www-form-urlencoded'); $request = new Solarium_Client_Request(); $request->setMethod($method); $request->setHandler($handler); $request->setHeaders($headers); $request->setRawData($rawData); $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($headers)); $mock->expects($this->once())->method('setRawData')->with($this->equalTo($rawData)); $mock->expects($this->once())->method('request')->will($this->returnValue($response)); $this->_adapter->setZendHttp($mock); $adapterResponse = $this->_adapter->execute($request); $this->assertEquals($responseData, $adapterResponse->getBody()); }