Ejemplo n.º 1
0
 public function testGetMatchException()
 {
     $query = new Query();
     $query->setMatchInclude(false);
     $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->getMatch();
 }
Ejemplo n.º 2
0
 public function testBuildWithQueryStream()
 {
     $content = 'test content';
     $this->query->setQuery($content);
     $this->query->setQueryStream(true);
     $request = $this->builder->build($this->query);
     $this->assertEquals(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()));
 }
Ejemplo n.º 3
0
 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);
 }
Ejemplo n.º 4
0
 public function testConfigMode()
 {
     $config = array('query' => 'text:mykeyword', 'sort' => array('score' => 'asc'), 'fields' => array('id', 'title', 'category'), 'rows' => 100, 'start' => 200, 'filterquery' => array(array('key' => 'pub', 'tag' => array('pub'), 'query' => 'published:true'), 'online' => array('tag' => 'onl', 'query' => 'online:true')), 'component' => array('facetset' => array('facet' => array(array('type' => 'field', 'key' => 'categories', 'field' => 'category'), 'category13' => array('type' => 'query', 'query' => 'category:13')))), 'resultclass' => 'MyResultClass', 'documentclass' => 'MyDocumentClass');
     $query = new Query($config);
     $this->assertEquals($config['query'], $query->getQuery());
     $this->assertEquals($config['sort'], $query->getSorts());
     $this->assertEquals($config['fields'], $query->getFields());
     $this->assertEquals($config['rows'], $query->getRows());
     $this->assertEquals($config['start'], $query->getStart());
     $this->assertEquals($config['documentclass'], $query->getDocumentClass());
     $this->assertEquals($config['resultclass'], $query->getResultClass());
     $this->assertEquals('published:true', $query->getFilterQuery('pub')->getQuery());
     $this->assertEquals('online:true', $query->getFilterQuery('online')->getQuery());
     $facets = $query->getFacetSet()->getFacets();
     $this->assertEquals('category', $facets['categories']->getField());
     $this->assertEquals('category:13', $facets['category13']->getQuery());
     $components = $query->getComponents();
     $this->assertEquals(1, count($components));
     $this->assertThat(array_pop($components), $this->isInstanceOf('Solarium\\QueryType\\Select\\Query\\Component\\FacetSet'));
 }