public function testSetFilterQueries() { $fq1 = new FilterQuery(); $fq1->setKey('fq1')->setQuery('category:1'); $fq2 = new FilterQuery(); $fq2->setKey('fq2')->setQuery('category:2'); $filterQueries1 = array('fq1' => $fq1, 'fq2' => $fq2); $this->query->addFilterQueries($filterQueries1); $fq3 = new FilterQuery(); $fq3->setKey('fq3')->setQuery('category:3'); $fq4 = new FilterQuery(); $fq4->setKey('fq4')->setQuery('category:4'); $filterQueries2 = array('fq3' => $fq3, 'fq4' => $fq4); $this->query->setFilterQueries($filterQueries2); $this->assertEquals($filterQueries2, $this->query->getFilterQueries()); }
/** * Create a filterquery instance. * * If you supply a string as the first arguments ($options) it will be used as the key for the filterquery * and it will be added to this query. * If you supply an options array/object that contains a key the filterquery will also be added to the query. * * When no key is supplied the filterquery cannot be added, in that case you will need to add it manually * after setting the key, by using the addFilterQuery method. * * @param mixed $options * * @return FilterQuery */ public function createFilterQuery($options = null) { if (is_string($options)) { $fq = new FilterQuery(); $fq->setKey($options); } else { $fq = new FilterQuery($options); } if ($fq->getKey() !== null) { $this->addFilterQuery($fq); } return $fq; }