public function testConfigModeWithSingleValueTag() { $fq = new Solarium_Query_Select_FilterQuery(array('tag' => 't1', 'key' => 'k1', 'query' => 'id:[10 TO 20]')); $this->assertEquals(array('t1'), $fq->getTags()); $this->assertEquals('k1', $fq->getKey()); $this->assertEquals('id:[10 TO 20]', $fq->getQuery()); }
/** * Add a filter query * * Supports a filterquery instance or a config array, in that case a new * filterquery instance wil be created based on the options. * * @param Solarium_Query_Select_FilterQuery|array $filterQuery * @return Solarium_Query_Select Provides fluent interface */ public function addFilterQuery($filterQuery) { if (is_array($filterQuery)) { $filterQuery = new Solarium_Query_Select_FilterQuery($filterQuery); } $key = $filterQuery->getKey(); if (0 === strlen($key)) { throw new Solarium_Exception('A filterquery must have a key value'); } //double add calls for the same FQ are ignored, but non-unique keys cause an exception //@todo add trigger_error with a notice for double add calls? if (array_key_exists($key, $this->_filterQueries) && $this->_filterQueries[$key] !== $filterQuery) { throw new Solarium_Exception('A filterquery must have a unique key value within a query'); } else { $this->_filterQueries[$key] = $filterQuery; } return $this; }
/** * Add a filter query * * Supports a filterquery instance or a config array, in that case a new * filterquery instance wil be created based on the options. * * @param Solarium_Query_Select_FilterQuery|array $filterQuery * @return Solarium_Query_Select Provides fluent interface */ public function addFilterQuery($filterQuery) { if (is_array($filterQuery)) { $filterQuery = new Solarium_Query_Select_FilterQuery($filterQuery); } $key = $filterQuery->getKey(); if (0 === strlen($key)) { throw new Solarium_Exception('A filterquery must have a key value'); } if (array_key_exists($key, $this->_filterQueries)) { throw new Solarium_Exception('A filterquery must have a unique key' . ' value within a query'); } $this->_filterQueries[$key] = $filterQuery; return $this; }