public function testGetMatchException() { $query = new Solarium_Query_MoreLikeThis(); $query->setMatchInclude(false); $mock = $this->getMock('Solarium_Result_MoreLikeThis', array('getQuery'), array(), '', false); $mock->expects($this->once())->method('getQuery')->will($this->returnValue($query)); $this->setExpectedException('Solarium_Exception'); $mock->getMatch(); }
public function testBuildWithQueryStream() { $content = 'test content'; $this->_query->setQuery($content); $this->_query->setQueryStream(true); $request = $this->_builder->build($this->_query); $this->assertEquals(Solarium_Client_Request::METHOD_POST, $request->getMethod()); $this->assertEquals(null, $request->getParam('q')); $this->assertEquals($content, $request->getRawData()); $this->assertTrue(in_array('Content-Type: text/plain; charset=utf-8', $request->getHeaders())); }
public function testParse() { $data = array('response' => array('docs' => array(array('fieldA' => 1, 'fieldB' => 'Test'), array('fieldA' => 2, 'fieldB' => 'Test2')), 'numFound' => 503), 'responseHeader' => array('status' => 1, 'QTime' => 13), 'interestingTerms' => array('key1', 'value1', 'key2', 'value2'), 'match' => array('docs' => array(array('fieldA' => 5, 'fieldB' => 'Test5')))); $query = new Solarium_Query_MoreLikeThis(); $query->setInterestingTerms('details'); $query->setMatchInclude(true); $resultStub = $this->getMock('Solarium_Result_MoreLikeThis', array(), array(), '', false); $resultStub->expects($this->any())->method('getData')->will($this->returnValue($data)); $resultStub->expects($this->any())->method('getQuery')->will($this->returnValue($query)); $parser = new Solarium_Client_ResponseParser_MoreLikeThis(); $result = $parser->parse($resultStub); $this->assertEquals(array('key1' => 'value1', 'key2' => 'value2'), $result['interestingTerms']); $this->assertEquals(5, $result['match']->fieldA); }