3 use MediaWiki\Page\PageIdentityValue
;
4 use MediaWiki\Search\SearchUpdate
;
8 * @covers \MediaWiki\Search\SearchUpdate
10 class SearchUpdateTest
extends MediaWikiIntegrationTestCase
{
12 private SearchUpdate
$su;
14 protected function setUp(): void
{
16 $pageIdentity = new PageIdentityValue( 42, NS_MAIN
, 'Main_Page', PageIdentityValue
::LOCAL
);
17 $this->su
= new SearchUpdate( 0, $pageIdentity );
20 public function updateText( $text ) {
21 return trim( $this->su
->updateText( $text ) );
24 public function testUpdateText() {
27 $this->updateText( '<div>TeSt</div>' ),
28 'HTML stripped, text lowercased'
33 $this->updateText( <<<EOT
34 <table style="color:red; font-size:100px">
35 <tr class="scary"><td><div>foo</div></td><tr>bar</td></tr>
36 <tr><td>boz</td><tr>quux</td></tr>
39 ), 'Stripping HTML tables' );
43 $this->updateText( 'a > b' ),
44 'Handle unclosed tags'
47 $text = str_pad( "foo <barbarbar \n", 10000, 'x' );
49 $this->assertNotEquals(
51 $this->updateText( $text ),
57 * T34712: Test if unicode quotes in article links make its search index empty
59 public function testUnicodeLinkSearchIndexError() {
60 $text = "text „http://example.com“ text";
61 $result = $this->updateText( $text );
62 $processed = preg_replace( '/Q/u', 'Q', $result );
65 'Link surrounded by unicode quotes should not fail UTF-8 validation'