Code Duplication    Length = 23-23 lines in 2 locations

tests/Aggregation/DateHistogramTest.php 2 locations

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