diff --git a/module/VuFind/tests/fixtures/spell/query2 b/module/VuFind/tests/fixtures/spell/query2 new file mode 100644 index 0000000000000000000000000000000000000000..39c655f3dfe01685bd2e33f35e715e6c1efe348a Binary files /dev/null and b/module/VuFind/tests/fixtures/spell/query2 differ diff --git a/module/VuFind/tests/fixtures/spell/spell2 b/module/VuFind/tests/fixtures/spell/spell2 new file mode 100644 index 0000000000000000000000000000000000000000..3e64b98e42573bd357225fdfc4658d9719bc8163 Binary files /dev/null and b/module/VuFind/tests/fixtures/spell/spell2 differ diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Search/Solr/SpellingProcessorTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Search/Solr/SpellingProcessorTest.php index 709e8d84a8ae36a968729b9c51c161a6ded212f1..7b0437516a5cf39474a2db86feec02117b7e6ecc 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/Search/Solr/SpellingProcessorTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Search/Solr/SpellingProcessorTest.php @@ -241,6 +241,39 @@ class SpellingProcessorTest extends TestCase ); } + /** + * Test a shingle suggestion. + * + * @return void + */ + public function testShingleSuggestion() + { + $spelling = $this->getFixture('spell2'); + $query = $this->getFixture('query2'); + $params = $this->getServiceManager()->get('VuFind\SearchParamsPluginManager') + ->get('Solr'); + $params->setBasicSearch($query->getString(), $query->getHandler()); + $sp = new SpellingProcessor(); + $suggestions = $sp->getSuggestions($spelling, $query); + $this->assertEquals( + array( + 'preamble gribble' => array( + 'freq' => 0, + 'suggestions' => array( + 'preamble article' => array( + 'freq' => 1, + 'new_term' => 'preamble article', + 'expand_term' => '((preamble gribble) OR (preamble article))', + ), + ), + ), + ), + $sp->processSuggestions( + $suggestions, $spelling->getQuery(), $params + ) + ); + } + /** * Test that spelling tokenization works correctly. *