Code Duplication    Length = 12-17 lines in 2 locations

tests/Aggregation/GeoDistanceTest.php 1 location

@@ 19-30 (lines=12) @@
16
    /**
17
     * @group functional
18
     */
19
    public function testGeoDistanceAggregation(): void
20
    {
21
        $agg = new GeoDistance('geo', 'location', ['lat' => 32.804654, 'lon' => -117.242594]);
22
        $agg->addRange(null, 100);
23
        $agg->setUnit('mi');
24
25
        $query = new Query();
26
        $query->addAggregation($agg);
27
        $results = $this->_getIndexForTest()->search($query)->getAggregation('geo');
28
29
        $this->assertEquals(2, $results['buckets'][0]['doc_count']);
30
    }
31
32
    /**
33
     * @group functional

tests/Aggregation/ScriptedMetricTest.php 1 location

@@ 19-35 (lines=17) @@
16
    /**
17
     * @group functional
18
     */
19
    public function testScriptedMetricAggregation(): void
20
    {
21
        $agg = new ScriptedMetric(
22
            'scripted',
23
            'state.durations = []',
24
            'state.durations.add(doc.end.value - doc.start.value)',
25
            'return state.durations',
26
            'return states'
27
        );
28
29
        $query = new Query();
30
        $query->setSize(0);
31
        $query->addAggregation($agg);
32
        $results = $this->_getIndexForTest()->search($query)->getAggregation('scripted');
33
34
        $this->assertEquals([100, 50, 150], $results['value'][0]);
35
    }
36
37
    protected function _getIndexForTest(): Index
38
    {