6 class SearchHighlighterTest
extends \MediaWikiIntegrationTestCase
{
8 * @dataProvider provideHighlightSimple
9 * @covers \SearchHighlighter::highlightSimple
11 public function testHighlightSimple( string $wikiText, string $searchTerm, string $expectedOutput, int $contextChars ) {
12 $highlighter = new \
SearchHighlighter( false );
13 $actual = $highlighter->highlightSimple( $wikiText, [ $searchTerm ], 1, $contextChars );
14 $this->assertEquals( $expectedOutput, $actual );
17 public static function provideHighlightSimple() {
20 'this is a very simple text.',
25 'match a single word at the end of the string' => [
26 'this is a very simple text.',
28 "this is a very simple <span class=\"searchmatch\">text</span>.\n",
31 'utf-8 sequences should not be broken' => [
32 "text with long trailing UTF-8 sequences: " . str_repeat( "\u{1780}", 6 ) . ".",
34 "<span class=\"searchmatch\">text</span> with long trailing UTF-8 sequences: " . str_repeat( "\u{1780}", 5 ) . "\n",