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

@@ 113-131 (lines=19) @@
110
    /**
111
     * @group unit
112
     */
113
    public function testSetOffset(): void
114
    {
115
        $agg = new DateHistogram('hist', 'created');
116
        $agg->setFixedInterval('1h');
117
118
        $agg->setOffset('3m');
119
120
        $expected = [
121
            'date_histogram' => [
122
                'field' => 'created',
123
                'offset' => '3m',
124
                'fixed_interval' => '1h',
125
            ],
126
        ];
127
128
        $this->assertEquals($expected, $agg->toArray());
129
130
        $this->assertInstanceOf(DateHistogram::class, $agg->setOffset('3m'));
131
    }
132
133
    /**
134
     * @group functional
@@ 159-177 (lines=19) @@
156
    /**
157
     * @group unit
158
     */
159
    public function testSetTimezone(): void
160
    {
161
        $agg = new DateHistogram('hist', 'created');
162
        $agg->setFixedInterval('1h');
163
164
        $agg->setTimezone('-02:30');
165
166
        $expected = [
167
            'date_histogram' => [
168
                'field' => 'created',
169
                'time_zone' => '-02:30',
170
                'fixed_interval' => '1h',
171
            ],
172
        ];
173
174
        $this->assertEquals($expected, $agg->toArray());
175
176
        $this->assertInstanceOf(DateHistogram::class, $agg->setTimezone('-02:30'));
177
    }
178
179
    protected function _getIndexForTest(): Index
180
    {