Code Duplication    Length = 25-25 lines in 2 locations

tests/Aggregation/DateHistogramTest.php 2 locations

@@ 19-43 (lines=25) @@
16
    /**
17
     * @group functional
18
     */
19
    public function testDateHistogramAggregation(): void
20
    {
21
        $this->_checkVersion('7.2');
22
23
        $agg = new DateHistogram('hist', 'created');
24
        $agg->setFixedInterval('1h');
25
26
        $query = new Query();
27
        $query->addAggregation($agg);
28
        $results = $this->_getIndexForTest()->search($query)->getAggregation('hist');
29
30
        $docCount = 0;
31
        $nonDocCount = 0;
32
        foreach ($results['buckets'] as $bucket) {
33
            if (1 == $bucket['doc_count']) {
34
                ++$docCount;
35
            } else {
36
                ++$nonDocCount;
37
            }
38
        }
39
        // 3 Documents that were added
40
        $this->assertEquals(3, $docCount);
41
        // 1 document that was generated in between for the missing hour
42
        $this->assertEquals(1, $nonDocCount);
43
    }
44
45
    /**
46
     * @group unit
@@ 71-95 (lines=25) @@
68
    /**
69
     * @group functional
70
     */
71
    public function testDateHistogramCalendarAggregation(): void
72
    {
73
        $this->_checkVersion('7.2');
74
75
        $agg = new DateHistogram('hist', 'created');
76
        $agg->setCalendarInterval('1h');
77
78
        $query = new Query();
79
        $query->addAggregation($agg);
80
        $results = $this->_getIndexForTest()->search($query)->getAggregation('hist');
81
82
        $docCount = 0;
83
        $nonDocCount = 0;
84
        foreach ($results['buckets'] as $bucket) {
85
            if (1 == $bucket['doc_count']) {
86
                ++$docCount;
87
            } else {
88
                ++$nonDocCount;
89
            }
90
        }
91
        // 3 Documents that were added
92
        $this->assertEquals(3, $docCount);
93
        // 1 document that was generated in between for the missing hour
94
        $this->assertEquals(1, $nonDocCount);
95
    }
96
97
    /**
98
     * @group unit