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 functional
@@ 46-68 (lines=23) @@
43
    /**
44
     * @group functional
45
     */
46
    public function testDateHistogramCalendarAggregation(): void
47
    {
48
        $agg = new DateHistogram('hist', 'created');
49
        $agg->setCalendarInterval('1h');
50
51
        $query = new Query();
52
        $query->addAggregation($agg);
53
        $results = $this->_getIndexForTest()->search($query)->getAggregation('hist');
54
55
        $docCount = 0;
56
        $nonDocCount = 0;
57
        foreach ($results['buckets'] as $bucket) {
58
            if (1 == $bucket['doc_count']) {
59
                ++$docCount;
60
            } else {
61
                ++$nonDocCount;
62
            }
63
        }
64
        // 3 Documents that were added
65
        $this->assertEquals(3, $docCount);
66
        // 1 document that was generated in between for the missing hour
67
        $this->assertEquals(1, $nonDocCount);
68
    }
69
70
    /**
71
     * @group unit