| @@ 16-30 (lines=15) @@ | ||
| 13 | /** |
|
| 14 | * @group unit |
|
| 15 | */ |
|
| 16 | public function testToArray(): void |
|
| 17 | { |
|
| 18 | $expected = [ |
|
| 19 | 'global' => new \stdClass(), |
|
| 20 | 'aggs' => [ |
|
| 21 | 'avg_price' => ['avg' => ['field' => 'price']], |
|
| 22 | ], |
|
| 23 | ]; |
|
| 24 | ||
| 25 | $agg = new GlobalAggregation('all_products'); |
|
| 26 | $avg = new Avg('avg_price'); |
|
| 27 | $avg->setField('price'); |
|
| 28 | $agg->addAggregation($avg); |
|
| 29 | $this->assertEquals($expected, $agg->toArray()); |
|
| 30 | } |
|
| 31 | } |
|
| 32 | ||
| @@ 20-40 (lines=21) @@ | ||
| 17 | /** |
|
| 18 | * @group unit |
|
| 19 | */ |
|
| 20 | public function testForeachProcessorDefault(): void |
|
| 21 | { |
|
| 22 | $processor = new ForeachProcessor(); |
|
| 23 | $processor->setField('field1'); |
|
| 24 | ||
| 25 | $subprocessor = new Uppercase('field2'); |
|
| 26 | $processor->setProcessor($subprocessor); |
|
| 27 | ||
| 28 | $expected = [ |
|
| 29 | 'foreach' => [ |
|
| 30 | 'field' => 'field1', |
|
| 31 | 'processor' => [ |
|
| 32 | 'uppercase' => [ |
|
| 33 | 'field' => 'field2', |
|
| 34 | ], |
|
| 35 | ], |
|
| 36 | ], |
|
| 37 | ]; |
|
| 38 | ||
| 39 | $this->assertEquals($expected, $processor->toArray()); |
|
| 40 | } |
|
| 41 | ||
| 42 | /** |
|
| 43 | * @group unit |
|