| @@ 49-68 (lines=20) @@ | ||
| 46 | /** |
|
| 47 | * @group unit |
|
| 48 | */ |
|
| 49 | public function testOverrideBucketsPathThroughSetters(): void |
|
| 50 | { |
|
| 51 | $serialDiffAgg = new ExtendedStatsBucket('bucket_part', 'foobar'); |
|
| 52 | ||
| 53 | $serialDiffAgg |
|
| 54 | ->setBucketsPath('age_groups>max_weight') |
|
| 55 | ->setFormat('test_format') |
|
| 56 | ->setGapPolicy(10) |
|
| 57 | ; |
|
| 58 | ||
| 59 | $expected = [ |
|
| 60 | 'extended_stats_bucket' => [ |
|
| 61 | 'buckets_path' => 'age_groups>max_weight', |
|
| 62 | 'format' => 'test_format', |
|
| 63 | 'gap_policy' => 10, |
|
| 64 | ], |
|
| 65 | ]; |
|
| 66 | ||
| 67 | $this->assertEquals($expected, $serialDiffAgg->toArray()); |
|
| 68 | } |
|
| 69 | ||
| 70 | private function _getIndexForTest(): Index |
|
| 71 | { |
|
| @@ 46-67 (lines=22) @@ | ||
| 43 | /** |
|
| 44 | * @group unit |
|
| 45 | */ |
|
| 46 | public function testConstructThroughSetters(): void |
|
| 47 | { |
|
| 48 | $serialDiffAgg = new SerialDiff('difference'); |
|
| 49 | ||
| 50 | $serialDiffAgg |
|
| 51 | ->setBucketsPath('nested_agg') |
|
| 52 | ->setFormat('test_format') |
|
| 53 | ->setGapPolicy(10) |
|
| 54 | ->setLag(5) |
|
| 55 | ; |
|
| 56 | ||
| 57 | $expected = [ |
|
| 58 | 'serial_diff' => [ |
|
| 59 | 'buckets_path' => 'nested_agg', |
|
| 60 | 'format' => 'test_format', |
|
| 61 | 'gap_policy' => 10, |
|
| 62 | 'lag' => 5, |
|
| 63 | ], |
|
| 64 | ]; |
|
| 65 | ||
| 66 | $this->assertEquals($expected, $serialDiffAgg->toArray()); |
|
| 67 | } |
|
| 68 | ||
| 69 | /** |
|
| 70 | * @group unit |
|
| @@ 179-197 (lines=19) @@ | ||
| 176 | /** |
|
| 177 | * @group unit |
|
| 178 | */ |
|
| 179 | public function testSetOffset(): void |
|
| 180 | { |
|
| 181 | $agg = new DateHistogram('hist', 'created'); |
|
| 182 | $agg->setFixedInterval('1h'); |
|
| 183 | ||
| 184 | $agg->setOffset('3m'); |
|
| 185 | ||
| 186 | $expected = [ |
|
| 187 | 'date_histogram' => [ |
|
| 188 | 'field' => 'created', |
|
| 189 | 'offset' => '3m', |
|
| 190 | 'fixed_interval' => '1h', |
|
| 191 | ], |
|
| 192 | ]; |
|
| 193 | ||
| 194 | $this->assertEquals($expected, $agg->toArray()); |
|
| 195 | ||
| 196 | $this->assertInstanceOf(DateHistogram::class, $agg->setOffset('3m')); |
|
| 197 | } |
|
| 198 | ||
| 199 | /** |
|
| 200 | * @group functional |
|
| @@ 225-243 (lines=19) @@ | ||
| 222 | /** |
|
| 223 | * @group unit |
|
| 224 | */ |
|
| 225 | public function testSetTimezone(): void |
|
| 226 | { |
|
| 227 | $agg = new DateHistogram('hist', 'created'); |
|
| 228 | $agg->setFixedInterval('1h'); |
|
| 229 | ||
| 230 | $agg->setTimezone('-02:30'); |
|
| 231 | ||
| 232 | $expected = [ |
|
| 233 | 'date_histogram' => [ |
|
| 234 | 'field' => 'created', |
|
| 235 | 'time_zone' => '-02:30', |
|
| 236 | 'fixed_interval' => '1h', |
|
| 237 | ], |
|
| 238 | ]; |
|
| 239 | ||
| 240 | $this->assertEquals($expected, $agg->toArray()); |
|
| 241 | ||
| 242 | $this->assertInstanceOf(DateHistogram::class, $agg->setTimezone('-02:30')); |
|
| 243 | } |
|
| 244 | ||
| 245 | protected function _getIndexForTest(): Index |
|
| 246 | { |
|