| @@ 72-88 (lines=17) @@ | ||
| 69 | /** |
|
| 70 | * @group functional |
|
| 71 | */ |
|
| 72 | public function testDateHistogramKeyedAggregation(): void |
|
| 73 | { |
|
| 74 | $agg = new DateHistogram('hist', 'created', '1h'); |
|
| 75 | $agg->setKeyed(); |
|
| 76 | ||
| 77 | $query = new Query(); |
|
| 78 | $query->addAggregation($agg); |
|
| 79 | $results = $this->_getIndexForTest()->search($query)->getAggregation('hist'); |
|
| 80 | ||
| 81 | $expected = [ |
|
| 82 | '2014-01-29T00:00:00.000Z', |
|
| 83 | '2014-01-29T01:00:00.000Z', |
|
| 84 | '2014-01-29T02:00:00.000Z', |
|
| 85 | '2014-01-29T03:00:00.000Z', |
|
| 86 | ]; |
|
| 87 | $this->assertSame($expected, \array_keys($results['buckets'])); |
|
| 88 | } |
|
| 89 | ||
| 90 | /** |
|
| 91 | * @group unit |
|
| @@ 55-73 (lines=19) @@ | ||
| 52 | /** |
|
| 53 | * @group functional |
|
| 54 | */ |
|
| 55 | public function testHistogramKeyedAggregation(): void |
|
| 56 | { |
|
| 57 | $agg = new Histogram('hist', 'price', 10); |
|
| 58 | $agg->setMinimumDocumentCount(0); // should return empty buckets |
|
| 59 | $agg->setKeyed(); |
|
| 60 | ||
| 61 | $query = new Query(); |
|
| 62 | $query->addAggregation($agg); |
|
| 63 | $results = $this->_getIndexForTest()->search($query)->getAggregation('hist'); |
|
| 64 | ||
| 65 | $expected = [ |
|
| 66 | '0.0', |
|
| 67 | '10.0', |
|
| 68 | '20.0', |
|
| 69 | '30.0', |
|
| 70 | '40.0', |
|
| 71 | ]; |
|
| 72 | $this->assertSame($expected, \array_keys($results['buckets'])); |
|
| 73 | } |
|
| 74 | ||
| 75 | protected function _getIndexForTest(): Index |
|
| 76 | { |
|