Ejemplo n.º 1
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'));
 }