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