Code Duplication    Length = 19-22 lines in 4 locations

tests/Aggregation/ExtendedStatsBucketTest.php 1 location

@@ 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
    {

tests/Aggregation/SerialDiffTest.php 1 location

@@ 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

tests/Aggregation/DateHistogramTest.php 2 locations

@@ 134-152 (lines=19) @@
131
    /**
132
     * @group unit
133
     */
134
    public function testSetOffset(): void
135
    {
136
        $agg = new DateHistogram('hist', 'created');
137
        $agg->setFixedInterval('1h');
138
139
        $agg->setOffset('3m');
140
141
        $expected = [
142
            'date_histogram' => [
143
                'field' => 'created',
144
                'offset' => '3m',
145
                'fixed_interval' => '1h',
146
            ],
147
        ];
148
149
        $this->assertEquals($expected, $agg->toArray());
150
151
        $this->assertInstanceOf(DateHistogram::class, $agg->setOffset('3m'));
152
    }
153
154
    /**
155
     * @group functional
@@ 180-198 (lines=19) @@
177
    /**
178
     * @group unit
179
     */
180
    public function testSetTimezone(): void
181
    {
182
        $agg = new DateHistogram('hist', 'created');
183
        $agg->setFixedInterval('1h');
184
185
        $agg->setTimezone('-02:30');
186
187
        $expected = [
188
            'date_histogram' => [
189
                'field' => 'created',
190
                'time_zone' => '-02:30',
191
                'fixed_interval' => '1h',
192
            ],
193
        ];
194
195
        $this->assertEquals($expected, $agg->toArray());
196
197
        $this->assertInstanceOf(DateHistogram::class, $agg->setTimezone('-02:30'));
198
    }
199
200
    protected function _getIndexForTest(): Index
201
    {