Page MenuHomeWickedGov Phorge

SearchHighlighterTest.php
No OneTemporary

Size
1 KB
Referenced Files
None
Subscribers
None

SearchHighlighterTest.php

<?php
/**
* @group Search
*/
class SearchHighlighterTest extends \MediaWikiIntegrationTestCase {
/**
* @dataProvider provideHighlightSimple
* @covers \SearchHighlighter::highlightSimple
*/
public function testHighlightSimple( string $wikiText, string $searchTerm, string $expectedOutput, int $contextChars ) {
$highlighter = new \SearchHighlighter( false );
$actual = $highlighter->highlightSimple( $wikiText, [ $searchTerm ], 1, $contextChars );
$this->assertEquals( $expectedOutput, $actual );
}
public static function provideHighlightSimple() {
return [
'no match' => [
'this is a very simple text.',
'cannotmatch',
'',
10
],
'match a single word at the end of the string' => [
'this is a very simple text.',
'text',
"this is a very simple <span class=\"searchmatch\">text</span>.\n",
40
],
'utf-8 sequences should not be broken' => [
"text with long trailing UTF-8 sequences: " . str_repeat( "\u{1780}", 6 ) . ".",
'text',
"<span class=\"searchmatch\">text</span> with long trailing UTF-8 sequences: " . str_repeat( "\u{1780}", 5 ) . "\n",
41
],
];
}
}

File Metadata

Mime Type
text/x-php
Expires
Sat, Oct 3, 20:15 (3 d, 11 h ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
75/ce/a0f9ac2d09f9928855c207710d47
Default Alt Text
SearchHighlighterTest.php (1 KB)

Event Timeline