X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/45a15b479294349638bbe334f8701f077aa899c4..refs/pull/5591/head:/tests/Search/SearchIndexingTest.php diff --git a/tests/Search/SearchIndexingTest.php b/tests/Search/SearchIndexingTest.php index 43219a4ed..64779dec6 100644 --- a/tests/Search/SearchIndexingTest.php +++ b/tests/Search/SearchIndexingTest.php @@ -1,6 +1,6 @@ assertEquals(3, $scoreByTerm->get('Animal')); $this->assertEquals(3, $scoreByTerm->get('SuperImportant')); } + + public function test_terms_containing_guillemets_handled() + { + $page = $this->entities->newPage(['html' => '
«Hello there» and « there »
']); + + $scoreByTerm = $page->searchTerms()->pluck('score', 'term'); + $expected = ['Hello', 'there', 'and']; + foreach ($expected as $term) { + $this->assertNotNull($scoreByTerm->get($term), "Failed asserting that \"$term\" is indexed"); + } + + $nonExpected = ['«', '»']; + foreach ($nonExpected as $term) { + $this->assertNull($scoreByTerm->get($term), "Failed asserting that \"$term\" is not indexed"); + } + } + + public function test_terms_containing_punctuation_within_retain_original_form_and_split_form_in_index() + { + $page = $this->entities->newPage(['html' => 'super.duper awesome-beans big- barry cheese.
biscuits
a-bs
']); + + $scoreByTerm = $page->searchTerms()->pluck('score', 'term'); + $expected = ['super', 'duper', 'super.duper', 'awesome-beans', 'awesome', 'beans', 'big', 'barry', 'cheese', 'biscuits', 'a-bs', 'a', 'bs']; + foreach ($expected as $term) { + $this->assertNotNull($scoreByTerm->get($term), "Failed asserting that \"$term\" is indexed"); + } + + $nonExpected = ['big-', 'big-barry', 'cheese.', 'cheese.biscuits']; + foreach ($nonExpected as $term) { + $this->assertNull($scoreByTerm->get($term), "Failed asserting that \"$term\" is not indexed"); + } + } }