Code Duplication    Length = 12-14 lines in 4 locations

tests/Aggregation/NestedTest.php 1 location

@@ 20-33 (lines=14) @@
17
    /**
18
     * @group functional
19
     */
20
    public function testNestedAggregation(): void
21
    {
22
        $agg = new Nested('resellers', 'resellers');
23
        $min = new Min('min_price');
24
        $min->setField('resellers.price');
25
        $agg->addAggregation($min);
26
27
        $query = new Query();
28
        $query->addAggregation($agg);
29
30
        $results = $this->_getIndexForTest()->search($query)->getAggregation('resellers');
31
32
        $this->assertEquals(4.98, $results['min_price']['value']);
33
    }
34
35
    protected function _getIndexForTest(): Index
36
    {

tests/Aggregation/RangeTest.php 1 location

@@ 18-29 (lines=12) @@
15
    /**
16
     * @group functional
17
     */
18
    public function testRangeAggregation(): void
19
    {
20
        $agg = new Range('range');
21
        $agg->setField('price');
22
        $agg->addRange(1.5, 5);
23
24
        $query = new Query();
25
        $query->addAggregation($agg);
26
        $results = $this->_getIndexForTest()->search($query)->getAggregation('range');
27
28
        $this->assertEquals(2, $results['buckets'][0]['doc_count']);
29
    }
30
31
    /**
32
     * @group unit

tests/Aggregation/TermsTest.php 1 location

@@ 89-100 (lines=12) @@
86
        $this->assertEquals('blue', $results['buckets'][0]['key']);
87
    }
88
89
    public function testTermsSetOrder(): void
90
    {
91
        $agg = new Terms('terms');
92
        $agg->setField('color');
93
        $agg->setOrder('_count', 'asc');
94
95
        $query = new Query();
96
        $query->addAggregation($agg);
97
        $results = $this->getIndex()->search($query)->getAggregation('terms');
98
99
        $this->assertEquals('blue', $results['buckets'][2]['key']);
100
    }
101
102
    public function testTermsSetOrders(): void
103
    {

tests/Aggregation/DateHistogramTest.php 1 location

@@ 126-139 (lines=14) @@
123
    /**
124
     * @group functional
125
     */
126
    public function testSetOffsetWorks(): void
127
    {
128
        $this->_checkVersion('7.2');
129
130
        $agg = new DateHistogram('hist', 'created');
131
        $agg->setFixedInterval('1m');
132
        $agg->setOffset('+40s');
133
134
        $query = new Query();
135
        $query->addAggregation($agg);
136
        $results = $this->_getIndexForTest()->search($query)->getAggregation('hist');
137
138
        $this->assertEquals('2014-01-29T00:19:40.000Z', $results['buckets'][0]['key_as_string']);
139
    }
140
141
    /**
142
     * @group unit