]> BookStack Code Mirror - bookstack/blobdiff - tests/Search/SearchIndexingTest.php
Perms: Fixed some issues made when adding transactions
[bookstack] / tests / Search / SearchIndexingTest.php
index 6933813b608a0f6c8559e3dc6d49bc1d087ad5a0..d2bbb2905b457bfbb09ee1730e16d6a804ae6186 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 
-namespace Search;
+namespace Tests\Search;
 
 use Tests\TestCase;
 
@@ -75,6 +75,22 @@ class SearchIndexingTest extends TestCase
         $this->assertEquals(3, $scoreByTerm->get('SuperImportant'));
     }
 
+    public function test_terms_containing_guillemets_handled()
+    {
+        $page = $this->entities->newPage(['html' => '<p>«Hello there» and « there »</p>']);
+
+        $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' => '<p>super.duper awesome-beans big- barry cheese.</p><p>biscuits</p><p>a-bs</p>']);
@@ -90,4 +106,14 @@ class SearchIndexingTest extends TestCase
             $this->assertNull($scoreByTerm->get($term), "Failed asserting that \"$term\" is not indexed");
         }
     }
+
+    public function test_non_breaking_spaces_handled_as_spaces()
+    {
+        $page = $this->entities->newPage(['html' => '<p>a&nbsp;tigerbadger is a dangerous&nbsp;animal</p>']);
+
+        $scoreByTerm = $page->searchTerms()->pluck('score', 'term');
+        $this->assertNotNull($scoreByTerm->get('tigerbadger'));
+        $this->assertNotNull($scoreByTerm->get('dangerous'));
+        $this->assertNotNull($scoreByTerm->get('animal'));
+    }
 }