| @@ 100-118 (lines=19) @@ | ||
| 97 | /** |
|
| 98 | * @group unit |
|
| 99 | */ |
|
| 100 | public function testSetOffset(): void |
|
| 101 | { |
|
| 102 | $agg = new DateHistogram('hist', 'created'); |
|
| 103 | $agg->setFixedInterval('1h'); |
|
| 104 | ||
| 105 | $agg->setOffset('3m'); |
|
| 106 | ||
| 107 | $expected = [ |
|
| 108 | 'date_histogram' => [ |
|
| 109 | 'field' => 'created', |
|
| 110 | 'offset' => '3m', |
|
| 111 | 'fixed_interval' => '1h', |
|
| 112 | ], |
|
| 113 | ]; |
|
| 114 | ||
| 115 | $this->assertEquals($expected, $agg->toArray()); |
|
| 116 | ||
| 117 | $this->assertInstanceOf(DateHistogram::class, $agg->setOffset('3m')); |
|
| 118 | } |
|
| 119 | ||
| 120 | /** |
|
| 121 | * @group functional |
|
| @@ 141-159 (lines=19) @@ | ||
| 138 | /** |
|
| 139 | * @group unit |
|
| 140 | */ |
|
| 141 | public function testSetTimezone(): void |
|
| 142 | { |
|
| 143 | $agg = new DateHistogram('hist', 'created'); |
|
| 144 | $agg->setFixedInterval('1h'); |
|
| 145 | ||
| 146 | $agg->setTimezone('-02:30'); |
|
| 147 | ||
| 148 | $expected = [ |
|
| 149 | 'date_histogram' => [ |
|
| 150 | 'field' => 'created', |
|
| 151 | 'time_zone' => '-02:30', |
|
| 152 | 'fixed_interval' => '1h', |
|
| 153 | ], |
|
| 154 | ]; |
|
| 155 | ||
| 156 | $this->assertEquals($expected, $agg->toArray()); |
|
| 157 | ||
| 158 | $this->assertInstanceOf(DateHistogram::class, $agg->setTimezone('-02:30')); |
|
| 159 | } |
|
| 160 | ||
| 161 | protected function _getIndexForTest(): Index |
|
| 162 | { |
|
| @@ 52-71 (lines=20) @@ | ||
| 49 | /** |
|
| 50 | * @group unit |
|
| 51 | */ |
|
| 52 | public function testOverrideBucketsPathThroughSetters(): void |
|
| 53 | { |
|
| 54 | $serialDiffAgg = new ExtendedStatsBucket('bucket_part', 'foobar'); |
|
| 55 | ||
| 56 | $serialDiffAgg |
|
| 57 | ->setBucketsPath('age_groups>max_weight') |
|
| 58 | ->setFormat('test_format') |
|
| 59 | ->setGapPolicy(10) |
|
| 60 | ; |
|
| 61 | ||
| 62 | $expected = [ |
|
| 63 | 'extended_stats_bucket' => [ |
|
| 64 | 'buckets_path' => 'age_groups>max_weight', |
|
| 65 | 'format' => 'test_format', |
|
| 66 | 'gap_policy' => 10, |
|
| 67 | ], |
|
| 68 | ]; |
|
| 69 | ||
| 70 | $this->assertEquals($expected, $serialDiffAgg->toArray()); |
|
| 71 | } |
|
| 72 | ||
| 73 | private function _getIndexForTest(): Index |
|
| 74 | { |
|
| @@ 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 |
|