public function testConfigModeWithSingleValueTag() { $fq = new 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. * * @throws InvalidArgumentException * * @param FilterQuery|array $filterQuery * * @return self Provides fluent interface */ public function addFilterQuery($filterQuery) { if (is_array($filterQuery)) { $filterQuery = new FilterQuery($filterQuery); } $key = $filterQuery->getKey(); if (0 === strlen($key)) { throw new InvalidArgumentException('A filterquery must have a key value'); } //double add calls for the same FQ are ignored, but non-unique keys cause an exception if (array_key_exists($key, $this->filterQueries) && $this->filterQueries[$key] !== $filterQuery) { throw new InvalidArgumentException('A filterquery must have a unique key value within a query'); } else { $this->filterQueries[$key] = $filterQuery; } return $this; }