Localisation updates from https://translatewiki.net.
[mediawiki.git] / tests / phpunit / includes / search / SearchHighlighterTest.php
blobb43e6cf2786f280c75a89db4b6f0b1619226a61d
1 <?php
3 /**
4 * @group Search
5 */
6 class SearchHighlighterTest extends \MediaWikiIntegrationTestCase {
7 /**
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() {
18 return [
19 'no match' => [
20 'this is a very simple text.',
21 'cannotmatch',
22 '',
25 'match a single word at the end of the string' => [
26 'this is a very simple text.',
27 '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 ) . ".",
33 'text',
34 "<span class=\"searchmatch\">text</span> with long trailing UTF-8 sequences: " . str_repeat( "\u{1780}", 5 ) . "\n",