コード例 #1
0
 public function testParseSolr14Format()
 {
     $data = array('responseHeader' => array('status' => 1, 'QTime' => 13), 'terms' => array('fieldA', array('term1', 5, 'term2', 3), 'fieldB', array('term3', 6, 'term4', 2)));
     $query = new Query();
     $query->setFields('fieldA,fieldB');
     $resultStub = $this->getMock('Solarium\\QueryType\\Terms\\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);
     $expected = array('fieldA' => array('term1' => 5, 'term2' => 3), 'fieldB' => array('term3' => 6, 'term4' => 2));
     $this->assertEquals($expected, $result['results']);
     $this->assertEquals(2, count($result['results']));
 }
コード例 #2
0
 public function testSetAndGetSort()
 {
     $this->query->setSort('index');
     $this->assertEquals('index', $this->query->getSort());
 }
コード例 #3
0
 public function testBuildParams()
 {
     $this->query->setFields('fieldA,fieldB');
     $this->query->setLowerbound('d');
     $this->query->setLowerboundInclude(true);
     $this->query->setMinCount(3);
     $this->query->setMaxCount(100);
     $this->query->setPrefix('de');
     $this->query->setRegex('det.*');
     $this->query->setRegexFlags('case_insensitive,comments');
     $this->query->setLimit(50);
     $this->query->setUpperbound('x');
     $this->query->setUpperboundInclude(false);
     $this->query->setRaw(false);
     $this->query->setSort('index');
     $request = $this->builder->build($this->query);
     $this->assertEquals(array('terms' => 'true', 'terms.fl' => array('fieldA', 'fieldB'), 'terms.limit' => 50, 'terms.lower' => 'd', 'terms.lower.incl' => 'true', 'terms.maxcount' => 100, 'terms.mincount' => 3, 'terms.prefix' => 'de', 'terms.raw' => 'false', 'terms.regex' => 'det.*', 'terms.regex.flag' => array('case_insensitive', 'comments'), 'terms.sort' => 'index', 'terms.upper' => 'x', 'terms.upper.incl' => 'false', 'wt' => 'json', 'json.nl' => 'flat', 'omitHeader' => 'true'), $request->getParams());
     $this->assertEquals(Request::METHOD_GET, $request->getMethod());
 }