Code Duplication    Length = 14-18 lines in 8 locations

tests/Aggregation/ValueCountTest.php 1 location

@@ 29-44 (lines=16) @@
26
        $this->assertEquals(5, $results['value']);
27
    }
28
29
    protected function _getIndexForTest(): Index
30
    {
31
        $index = $this->_createIndex();
32
33
        $index->addDocuments([
34
            new Document(1, ['price' => 5]),
35
            new Document(2, ['price' => 8]),
36
            new Document(3, ['price' => 1]),
37
            new Document(4, ['price' => 3]),
38
            new Document(5, ['price' => 3]),
39
        ]);
40
41
        $index->refresh();
42
43
        return $index;
44
    }
45
}
46

tests/Suggest/PhraseTest.php 1 location

@@ 71-84 (lines=14) @@
68
    /**
69
     * @return Index
70
     */
71
    protected function _getIndexForTest()
72
    {
73
        $index = $this->_createIndex();
74
        $index->addDocuments([
75
            new Document(1, ['text' => 'Github is pretty cool']),
76
            new Document(2, ['text' => 'Elasticsearch is bonsai cool']),
77
            new Document(3, ['text' => 'This is a test phrase']),
78
            new Document(4, ['text' => 'Another sentence for testing']),
79
            new Document(5, ['text' => 'Some more words here']),
80
        ]);
81
        $index->refresh();
82
83
        return $index;
84
    }
85
}
86

tests/Aggregation/AvgTest.php 1 location

@@ 52-67 (lines=16) @@
49
        $this->assertEquals((5 + 8 + 1 + 3 + 72) / 5.0, $results['avg']['value']);
50
    }
51
52
    protected function _getIndexForTest(): Index
53
    {
54
        $index = $this->_createIndex();
55
56
        $index->addDocuments([
57
            new Document(1, ['price' => 5]),
58
            new Document(2, ['price' => 8]),
59
            new Document(3, ['price' => 1]),
60
            new Document(4, ['price' => 3]),
61
            new Document(5, ['anything' => 'anything']),
62
        ]);
63
64
        $index->refresh();
65
66
        return $index;
67
    }
68
}
69

tests/Aggregation/DateHistogramTest.php 1 location

@@ 130-147 (lines=18) @@
127
        $this->assertInstanceOf(DateHistogram::class, $agg->setTimezone('-02:30'));
128
    }
129
130
    protected function _getIndexForTest(): Index
131
    {
132
        $index = $this->_createIndex();
133
        $index->setMapping(new Mapping([
134
            'created' => ['type' => 'date'],
135
        ]));
136
137
        $index->addDocuments([
138
            new Document(1, ['created' => '2014-01-29T00:20:00']),
139
            new Document(2, ['created' => '2014-01-29T02:20:00']),
140
            new Document(3, ['created' => '2014-01-29T03:20:00']),
141
            new Document(4, ['anything' => 'anything']),
142
        ]);
143
144
        $index->refresh();
145
146
        return $index;
147
    }
148
}
149

tests/Aggregation/DateRangeTest.php 1 location

@@ 123-140 (lines=18) @@
120
        }
121
    }
122
123
    protected function _getIndexForTest(): Index
124
    {
125
        $index = $this->_createIndex();
126
        $index->setMapping(new Mapping([
127
            'created' => ['type' => 'date', 'format' => 'epoch_millis'],
128
        ]));
129
130
        $index->addDocuments([
131
            new Document(1, ['created' => 1390962135000]),
132
            new Document(2, ['created' => 1390965735000]),
133
            new Document(3, ['created' => 1390954935000]),
134
            new Document(4, ['anything' => 'anything']),
135
        ]);
136
137
        $index->refresh();
138
139
        return $index;
140
    }
141
}
142

tests/Aggregation/ExtendedStatsTest.php 1 location

@@ 56-71 (lines=16) @@
53
        $this->assertArrayHasKey('sum_of_squares', $results);
54
    }
55
56
    protected function _getIndexForTest(): Index
57
    {
58
        $index = $this->_createIndex();
59
60
        $index->addDocuments([
61
            new Document(1, ['price' => 5]),
62
            new Document(2, ['price' => 8]),
63
            new Document(3, ['price' => 1]),
64
            new Document(4, ['price' => 3]),
65
            new Document(5, ['anything' => 'anything']),
66
        ]);
67
68
        $index->refresh();
69
70
        return $index;
71
    }
72
}
73

tests/Aggregation/StatsTest.php 1 location

@@ 54-69 (lines=16) @@
51
        $this->assertEquals((5 + 8 + 1 + 3 + 10), $results['sum']);
52
    }
53
54
    protected function _getIndexForTest(): Index
55
    {
56
        $index = $this->_createIndex();
57
58
        $index->addDocuments([
59
            new Document(1, ['price' => 5]),
60
            new Document(2, ['price' => 8]),
61
            new Document(3, ['price' => 1]),
62
            new Document(4, ['price' => 3]),
63
            new Document(5, ['anything' => 'anything']),
64
        ]);
65
66
        $index->refresh();
67
68
        return $index;
69
    }
70
}
71

tests/Aggregation/SumTest.php 1 location

@@ 46-61 (lines=16) @@
43
        $this->assertEquals(5 + 8 + 1 + 3 + 10, $results['value']);
44
    }
45
46
    protected function _getIndexForTest(): Index
47
    {
48
        $index = $this->_createIndex();
49
50
        $index->addDocuments([
51
            new Document(1, ['price' => 5]),
52
            new Document(2, ['price' => 8]),
53
            new Document(3, ['price' => 1]),
54
            new Document(4, ['price' => 3]),
55
            new Document(5, ['anything' => 'anything']),
56
        ]);
57
58
        $index->refresh();
59
60
        return $index;
61
    }
62
}
63