/** * Data provider for testToArray(). * * @return array */ public function getToArrayData() { $out = []; // Case #0 global aggregation. $aggregation = new GlobalAggregation('test_agg'); $result = ['agg_test_agg' => ['global' => new \stdClass()]]; $out[] = [$aggregation, $result]; // Case #1 nested global aggregation. $aggregation = new GlobalAggregation('test_agg'); $aggregation2 = new GlobalAggregation('test_agg_2'); $aggregation->addAggregation($aggregation2); $result = ['agg_test_agg' => ['global' => new \stdClass(), 'aggregations' => ['agg_test_agg_2' => ['global' => new \stdClass()]]]]; $out[] = [$aggregation, $result]; return $out; }
/** * 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; }