entities->newPage(['name' => 'Test page A', 'html' => '
TermA
' . $text . '
']); $termCount = $page->searchTerms()->count(); // Expect at least 90% unique rate $this->assertGreaterThan($count * 0.9, $termCount); } public function test_name_and_content_terms_are_merged_to_single_score() { $page = $this->entities->newPage(['name' => 'TermA', 'html' => 'TermA
']); $scoreByTerm = $page->searchTerms()->pluck('score', 'term'); // Scores 40 for being in the name then 1 for being in the content $this->assertEquals(41, $scoreByTerm->get('TermA')); } public function test_tag_names_and_values_are_indexed_for_search() { $page = $this->entities->newPage(['name' => 'PageA', 'html' => 'content
', 'tags' => [ ['name' => 'Animal', 'value' => 'MeowieCat'], ['name' => 'SuperImportant'], ]]); $scoreByTerm = $page->searchTerms()->pluck('score', 'term'); $this->assertEquals(5, $scoreByTerm->get('MeowieCat')); $this->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"); } } }