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

@@ 103-121 (lines=19) @@
100
    /**
101
     * @group unit
102
     */
103
    public function testSetOffset(): void
104
    {
105
        $agg = new DateHistogram('hist', 'created');
106
        $agg->setFixedInterval('1h');
107
108
        $agg->setOffset('3m');
109
110
        $expected = [
111
            'date_histogram' => [
112
                'field' => 'created',
113
                'offset' => '3m',
114
                'fixed_interval' => '1h',
115
            ],
116
        ];
117
118
        $this->assertEquals($expected, $agg->toArray());
119
120
        $this->assertInstanceOf(DateHistogram::class, $agg->setOffset('3m'));
121
    }
122
123
    /**
124
     * @group functional
@@ 144-162 (lines=19) @@
141
    /**
142
     * @group unit
143
     */
144
    public function testSetTimezone(): void
145
    {
146
        $agg = new DateHistogram('hist', 'created');
147
        $agg->setFixedInterval('1h');
148
149
        $agg->setTimezone('-02:30');
150
151
        $expected = [
152
            'date_histogram' => [
153
                'field' => 'created',
154
                'time_zone' => '-02:30',
155
                'fixed_interval' => '1h',
156
            ],
157
        ];
158
159
        $this->assertEquals($expected, $agg->toArray());
160
161
        $this->assertInstanceOf(DateHistogram::class, $agg->setTimezone('-02:30'));
162
    }
163
164
    protected function _getIndexForTest(): Index
165
    {