Code Duplication    Length = 10-12 lines in 6 locations

tests/Aggregation/CardinalityTest.php 2 locations

@@ 19-29 (lines=11) @@
16
    /**
17
     * @group functional
18
     */
19
    public function testCardinalityAggregation(): void
20
    {
21
        $agg = new Cardinality('cardinality');
22
        $agg->setField('color');
23
24
        $query = new Query();
25
        $query->addAggregation($agg);
26
        $results = $this->_getIndexForTest()->search($query)->getAggregation('cardinality');
27
28
        $this->assertEquals(3, $results['value']);
29
    }
30
31
    /**
32
     * @group functional
@@ 34-45 (lines=12) @@
31
    /**
32
     * @group functional
33
     */
34
    public function testCardinalityAggregationWithMissing(): void
35
    {
36
        $agg = new Cardinality('cardinality');
37
        $agg->setField('color');
38
        $agg->setMissing('yellow');
39
40
        $query = new Query();
41
        $query->addAggregation($agg);
42
        $results = $this->_getIndexForTest()->search($query)->getAggregation('cardinality');
43
44
        $this->assertEquals(4, $results['value']);
45
    }
46
47
    public function validPrecisionThresholdProvider()
48
    {

tests/Aggregation/GeoCentroidTest.php 1 location

@@ 19-28 (lines=10) @@
16
    /**
17
     * @group functional
18
     */
19
    public function testGeohashGridAggregation(): void
20
    {
21
        $agg = new GeoCentroid('centroid', 'location');
22
23
        $query = new Query();
24
        $query->addAggregation($agg);
25
        $results = $this->_getIndexForTest()->search($query)->getAggregation('centroid');
26
27
        $this->assertEquals(3, $results['count']);
28
    }
29
30
    protected function _getIndexForTest(): Index
31
    {

tests/Aggregation/MissingTest.php 1 location

@@ 19-28 (lines=10) @@
16
    /**
17
     * @group functional
18
     */
19
    public function testMissingAggregation(): void
20
    {
21
        $agg = new Missing('missing', 'color');
22
23
        $query = new Query();
24
        $query->addAggregation($agg);
25
        $results = $this->_getIndexForTest()->search($query)->getAggregation('missing');
26
27
        $this->assertEquals(1, $results['doc_count']);
28
    }
29
30
    protected function _getIndexForTest(): Index
31
    {

tests/Aggregation/ValueCountTest.php 1 location

@@ 18-27 (lines=10) @@
15
    /**
16
     * @group functional
17
     */
18
    public function testValueCountAggregation(): void
19
    {
20
        $agg = new ValueCount('count', 'price');
21
22
        $query = new Query();
23
        $query->addAggregation($agg);
24
        $results = $this->_getIndexForTest()->search($query)->getAggregation('count');
25
26
        $this->assertEquals(5, $results['value']);
27
    }
28
29
    protected function _getIndexForTest(): Index
30
    {

tests/Aggregation/TopHitsTest.php 1 location

@@ 405-416 (lines=12) @@
402
        return $index;
403
    }
404
405
    protected function getOuterAggregationResult($innerAggr)
406
    {
407
        $outerAggr = new Terms('top_tags');
408
        $outerAggr->setField('tags');
409
        $outerAggr->setMinimumDocumentCount(2);
410
        $outerAggr->addAggregation($innerAggr);
411
412
        $query = new Query(new MatchAll());
413
        $query->addAggregation($outerAggr);
414
415
        return $this->_getIndexForTest()->search($query)->getAggregation('top_tags');
416
    }
417
}
418