/** * Data provider for testGlobalAggregation. * * @return array */ public function getGlobalAggregationData() { $out = []; $results = ['agg_test_agg' => ['doc_count' => 3, 'agg_test_agg2' => ['buckets' => [['key' => '*-40.0', 'to' => 40, 'to_as_string' => '40.0', 'doc_count' => 3]]]]]; $aggregation = new GlobalAggregation('test_agg'); $aggregation2 = new RangeAggregation('test_agg2'); $aggregation2->setField('price'); $aggregation2->addRange(null, 40); $aggregation->addAggregation($aggregation2); // Case #0 global aggregation without query. $out[] = [$aggregation, null, $results, 3]; // Case #1 global aggregation with query. $query = new MatchQuery('title', 'bar'); $out[] = [$aggregation, $query, $results, 1]; return $out; }
/** * Test for setField method on global aggregation. * * @expectedException \LogicException */ public function testSetField() { $aggregation = new GlobalAggregation('test_agg'); $aggregation->setField('test_field'); }