Code Duplication    Length = 22-23 lines in 2 locations

tests/Aggregation/DateHistogramTest.php 2 locations

@@ 19-40 (lines=22) @@
16
    /**
17
     * @group functional
18
     */
19
    public function testDateHistogramAggregation(): void
20
    {
21
        $agg = new DateHistogram('hist', 'created', '1h');
22
23
        $query = new Query();
24
        $query->addAggregation($agg);
25
        $results = $this->_getIndexForTest()->search($query)->getAggregation('hist');
26
27
        $docCount = 0;
28
        $nonDocCount = 0;
29
        foreach ($results['buckets'] as $bucket) {
30
            if (1 == $bucket['doc_count']) {
31
                ++$docCount;
32
            } else {
33
                ++$nonDocCount;
34
            }
35
        }
36
        // 3 Documents that were added
37
        $this->assertEquals(3, $docCount);
38
        // 1 document that was generated in between for the missing hour
39
        $this->assertEquals(1, $nonDocCount);
40
    }
41
42
    /**
43
     * @group functional
@@ 45-67 (lines=23) @@
42
    /**
43
     * @group functional
44
     */
45
    public function testDateHistogramAggregationWithMissing(): void
46
    {
47
        $agg = new DateHistogram('hist', 'created', '1h');
48
        $agg->setMissing('2014-01-29T04:20:00');
49
50
        $query = new Query();
51
        $query->addAggregation($agg);
52
        $results = $this->_getIndexForTest()->search($query)->getAggregation('hist');
53
54
        $docCount = 0;
55
        $nonDocCount = 0;
56
        foreach ($results['buckets'] as $bucket) {
57
            if (1 == $bucket['doc_count']) {
58
                ++$docCount;
59
            } else {
60
                ++$nonDocCount;
61
            }
62
        }
63
        // 3 Documents that were added
64
        $this->assertEquals(4, $docCount);
65
        // 1 document that was generated in between for the missing hour
66
        $this->assertEquals(1, $nonDocCount);
67
    }
68
69
    /**
70
     * @group unit