| @@ 62-74 (lines=13) @@ | ||
| 59 | /** |
|
| 60 | * @group functional |
|
| 61 | */ |
|
| 62 | public function testFilterNoSubAggregation(): void |
|
| 63 | { |
|
| 64 | $agg = new Avg('price'); |
|
| 65 | $agg->setField('price'); |
|
| 66 | ||
| 67 | $query = new Query(); |
|
| 68 | $query->addAggregation($agg); |
|
| 69 | ||
| 70 | $results = $this->_getIndexForTest()->search($query)->getAggregation('price'); |
|
| 71 | $results = $results['value']; |
|
| 72 | ||
| 73 | $this->assertEquals((5 + 8 + 1 + 3) / 4.0, $results); |
|
| 74 | } |
|
| 75 | ||
| 76 | /** |
|
| 77 | * @group unit |
|
| @@ 18-28 (lines=11) @@ | ||
| 15 | /** |
|
| 16 | * @group functional |
|
| 17 | */ |
|
| 18 | public function testSumAggregation(): void |
|
| 19 | { |
|
| 20 | $agg = new Sum('sum'); |
|
| 21 | $agg->setField('price'); |
|
| 22 | ||
| 23 | $query = new Query(); |
|
| 24 | $query->addAggregation($agg); |
|
| 25 | $results = $this->_getIndexForTest()->search($query)->getAggregation('sum'); |
|
| 26 | ||
| 27 | $this->assertEquals(5 + 8 + 1 + 3, $results['value']); |
|
| 28 | } |
|
| 29 | ||
| 30 | /** |
|
| 31 | * @group functional |
|
| @@ 33-44 (lines=12) @@ | ||
| 30 | /** |
|
| 31 | * @group functional |
|
| 32 | */ |
|
| 33 | public function testSumAggregationWithMissing(): void |
|
| 34 | { |
|
| 35 | $agg = new Sum('sum'); |
|
| 36 | $agg->setField('price'); |
|
| 37 | $agg->setMissing(10); |
|
| 38 | ||
| 39 | $query = new Query(); |
|
| 40 | $query->addAggregation($agg); |
|
| 41 | $results = $this->_getIndexForTest()->search($query)->getAggregation('sum'); |
|
| 42 | ||
| 43 | $this->assertEquals(5 + 8 + 1 + 3 + 10, $results['value']); |
|
| 44 | } |
|
| 45 | ||
| 46 | protected function _getIndexForTest(): Index |
|
| 47 | { |
|