Exemple #1
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'), $request->getParams());
     $this->assertEquals(Solarium_Client_Request::METHOD_GET, $request->getMethod());
 }
Exemple #2
0
 public function testParse()
 {
     $data = array('responseHeader' => array('status' => 1, 'QTime' => 13), 'terms' => array('fieldA' => array('term1', 5, 'term2', 3), 'fieldB' => array('term3', 6, 'term4', 2)));
     $query = new Solarium_Query_Terms();
     $query->setFields('fieldA, fieldB');
     $resultStub = $this->getMock('Solarium_Result_Terms', 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_Terms();
     $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']));
 }
Exemple #3
0
 public function testSetAndGetFields()
 {
     $this->_query->setFields('fieldA,fieldB');
     $this->assertEquals('fieldA,fieldB', $this->_query->getFields());
 }