6 class SearchUpdateTest
extends MediaWikiTestCase
{
13 protected function setUp() {
15 $this->setMwGlobals( 'wgSearchType', 'MockSearch' );
16 $this->su
= new SearchUpdate( 0, "" );
19 public function updateText( $text ) {
20 return trim( $this->su
->updateText( $text ) );
24 * @covers SearchUpdate::updateText
26 public function testUpdateText() {
29 $this->updateText( '<div>TeSt</div>' ),
30 'HTML stripped, text lowercased'
35 $this->updateText( <<<EOT
36 <table style="color:red; font-size:100px">
37 <tr class="scary"><td><div>foo</div></td><tr>bar</td></tr>
38 <tr><td>boz</td><tr>quux</td></tr>
41 ), 'Stripping HTML tables' );
45 $this->updateText( 'a > b' ),
46 'Handle unclosed tags'
49 $text = str_pad( "foo <barbarbar \n", 10000, 'x' );
51 $this->assertNotEquals(
53 $this->updateText( $text ),
59 * @covers SearchUpdate::updateText
61 * Test if unicode quotes in article links make its search index empty
63 public function testUnicodeLinkSearchIndexError() {
64 $text = "text „http://example.com“ text";
65 $result = $this->updateText( $text );
66 $processed = preg_replace( '/Q/u', 'Q', $result );
69 'Link surrounded by unicode quotes should not fail UTF-8 validation'
74 class MockSearch
extends SearchEngine
{
79 public function __construct( $db ) {
82 public function update( $id, $title, $text ) {
84 self
::$title = $title;