_client = new Solarium_Client(); $this->_query = new Solarium_Query_Select(); $this->_headers = array('HTTP/1.0 304 Not Modified'); $data = '{"responseHeader":{"status":0,"QTime":1,"params":{"wt":"json","q":"xyz"}},"response":{"numFound":0,"start":0,"docs":[]}}'; $this->_response = new Solarium_Client_Response($data, $this->_headers); $this->_result = new Solarium_Result($this->_client, $this->_query, $this->_response); } public function testResultWithErrorResponse() { $headers = array('HTTP/1.0 404 Not Found'); $response = new Solarium_Client_Response('', $headers); $this->setExpectedException('Solarium_Exception'); new Solarium_Result($this->_client, $this->_query, $response); } public function testGetResponse() { $this->assertEquals($this->_response, $this->_result->getResponse()); } public function testGetQuery() { $this->assertEquals($this->_query, $this->_result->getQuery()); } public function testGetData() { $data = array( 'responseHeader' => array('status' => 0, 'QTime' => 1, 'params' => array('wt' => 'json', 'q' => 'xyz')), 'response' => array('numFound' => 0, 'start' => 0, 'docs' => array()) ); $this->assertEquals($data, $this->_result->getData()); } public function testGetInvalidData() { $data = 'invalid'; $this->_response = new Solarium_Client_Response($data, $this->_headers); $this->_result = new Solarium_Result($this->_client, $this->_query, $this->_response); $this->setExpectedException('Solarium_Exception'); $this->_result->getData(); } }