3 class MockSearch
extends SearchEngine
{
8 public function __construct( $db ) {
11 public function update( $id, $title, $text ) {
13 self
::$title = $title;
21 class SearchUpdateTest
extends MediaWikiTestCase
{
23 protected function setUp() {
25 $this->setMwGlobals( 'wgSearchType', 'MockSearch' );
28 public function updateText( $text ) {
29 return trim( SearchUpdate
::updateText( $text ) );
33 * @covers SearchUpdate::updateText
35 public function testUpdateText() {
38 $this->updateText( '<div>TeSt</div>' ),
39 'HTML stripped, text lowercased'
44 $this->updateText( <<<EOT
45 <table style="color:red; font-size:100px">
46 <tr class="scary"><td><div>foo</div></td><tr>bar</td></tr>
47 <tr><td>boz</td><tr>quux</td></tr>
50 ), 'Stripping HTML tables' );
54 $this->updateText( 'a > b' ),
55 'Handle unclosed tags'
58 $text = str_pad( "foo <barbarbar \n", 10000, 'x' );
60 $this->assertNotEquals(
62 $this->updateText( $text ),
68 * @covers SearchUpdate::updateText
70 * Test if unicode quotes in article links make its search index empty
72 public function testUnicodeLinkSearchIndexError() {
73 $text = "text „http://example.com“ text";
74 $result = $this->updateText( $text );
75 $processed = preg_replace( '/Q/u', 'Q', $result );
78 'Link surrounded by unicode quotes should not fail UTF-8 validation'