Code Duplication    Length = 19-19 lines in 2 locations

tests/Suggest/PhraseTest.php 2 locations

@@ 48-66 (lines=19) @@
45
    /**
46
     * @group functional
47
     */
48
    public function testPhraseSuggest(): void
49
    {
50
        $suggest = new Suggest();
51
        $phraseSuggest = new Phrase('suggest1', 'text');
52
        $phraseSuggest->setText('elasticsearch is bansai coor');
53
        $phraseSuggest->setAnalyzer('simple')->setHighlight('<suggest>', '</suggest>')->setStupidBackoffSmoothing(0.4);
54
        $phraseSuggest->addDirectGenerator(new DirectGenerator('text'));
55
        $suggest->addSuggestion($phraseSuggest);
56
57
        $index = $this->_getIndexForTest();
58
        $result = $index->search($suggest);
59
        $suggests = $result->getSuggests();
60
61
        // 3 suggestions should be returned: One in which both misspellings are corrected, and two in which only one misspelling is corrected.
62
        $this->assertCount(3, $suggests['suggest1'][0]['options']);
63
64
        $this->assertEquals('elasticsearch is <suggest>bonsai cool</suggest>', $suggests['suggest1'][0]['options'][0]['highlighted']);
65
        $this->assertEquals('elasticsearch is bonsai cool', $suggests['suggest1'][0]['options'][0]['text']);
66
    }
67
68
    /**
69
     * @group functional
@@ 71-89 (lines=19) @@
68
    /**
69
     * @group functional
70
     */
71
    public function testPhraseSuggestWithBackwardsCompatibility(): void
72
    {
73
        $suggest = new Suggest();
74
        $phraseSuggest = new Phrase('suggest1', 'text');
75
        $phraseSuggest->setText('elasticsearch is bansai coor');
76
        $phraseSuggest->setAnalyzer('simple')->setHighlight('<suggest>', '</suggest>')->setStupidBackoffSmoothing(0.4);
77
        $phraseSuggest->addCandidateGenerator(new DirectGenerator('text'));
78
        $suggest->addSuggestion($phraseSuggest);
79
80
        $index = $this->_getIndexForTest();
81
        $result = $index->search($suggest);
82
        $suggests = $result->getSuggests();
83
84
        // 3 suggestions should be returned: One in which both misspellings are corrected, and two in which only one misspelling is corrected.
85
        $this->assertCount(3, $suggests['suggest1'][0]['options']);
86
87
        $this->assertEquals('elasticsearch is <suggest>bonsai cool</suggest>', $suggests['suggest1'][0]['options'][0]['highlighted']);
88
        $this->assertEquals('elasticsearch is bonsai cool', $suggests['suggest1'][0]['options'][0]['text']);
89
    }
90
91
    protected function _getIndexForTest(): Index
92
    {