public function testGetInterestingTermsException()
 {
     $query = new Query();
     $query->setInterestingTerms('none');
     $mock = $this->getMock('Solarium\\QueryType\\MoreLikeThis\\Result', array('getQuery'), array(), '', false);
     $mock->expects($this->once())->method('getQuery')->will($this->returnValue($query));
     $this->setExpectedException('Solarium\\Exception\\UnexpectedValueException');
     $mock->getInterestingTerms();
 }
Example #2
0
 public function testBuildParams()
 {
     $this->query->setInterestingTerms('test');
     $this->query->setMatchInclude(true);
     $this->query->setStart(12);
     $this->query->setMltFields('description,name');
     $this->query->setMinimumTermFrequency(1);
     $this->query->setMinimumDocumentFrequency(3);
     $this->query->setMinimumWordLength(2);
     $this->query->setMaximumWordLength(15);
     $this->query->setMaximumQueryTerms(4);
     $this->query->setMaximumNumberOfTokens(5);
     $this->query->setBoost(true);
     $this->query->setQueryFields('description');
     $request = $this->builder->build($this->query);
     $this->assertEquals(array('mlt.interestingTerms' => 'test', 'mlt.match.include' => 'true', 'mlt.match.offset' => 12, 'mlt.fl' => 'description,name', 'mlt.mintf' => 1, 'mlt.mindf' => 3, 'mlt.minwl' => 2, 'mlt.maxwl' => 15, 'mlt.maxqt' => 4, 'mlt.maxntp' => 5, 'mlt.boost' => 'true', 'mlt.qf' => 'description', 'q' => '*:*', 'fl' => '*,score', 'rows' => 10, 'start' => 12, 'wt' => 'json', 'omitHeader' => 'true', 'json.nl' => 'flat'), $request->getParams());
     $this->assertEquals(Request::METHOD_GET, $request->getMethod());
 }
 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 Query();
     $query->setInterestingTerms('details');
     $query->setMatchInclude(true);
     $resultStub = $this->getMock('Solarium\\QueryType\\MoreLikeThis\\Result', 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 ResponseParser();
     $result = $parser->parse($resultStub);
     $this->assertEquals(array('key1' => 'value1', 'key2' => 'value2'), $result['interestingTerms']);
     $this->assertEquals(5, $result['match']->fieldA);
 }