MediaWiki
REL1_24
|
00001 <?php 00002 00003 class MockSearch extends SearchEngine { 00004 public static $id; 00005 public static $title; 00006 public static $text; 00007 00008 public function __construct( $db ) { 00009 } 00010 00011 public function update( $id, $title, $text ) { 00012 self::$id = $id; 00013 self::$title = $title; 00014 self::$text = $text; 00015 } 00016 } 00017 00022 class SearchUpdateTest extends MediaWikiTestCase { 00023 00024 protected function setUp() { 00025 parent::setUp(); 00026 $this->setMwGlobals( 'wgSearchType', 'MockSearch' ); 00027 } 00028 00029 public function updateText( $text ) { 00030 return trim( SearchUpdate::updateText( $text ) ); 00031 } 00032 00036 public function testUpdateText() { 00037 $this->assertEquals( 00038 'test', 00039 $this->updateText( '<div>TeSt</div>' ), 00040 'HTML stripped, text lowercased' 00041 ); 00042 00043 $this->assertEquals( 00044 'foo bar boz quux', 00045 $this->updateText( <<<EOT 00046 <table style="color:red; font-size:100px"> 00047 <tr class="scary"><td><div>foo</div></td><tr>bar</td></tr> 00048 <tr><td>boz</td><tr>quux</td></tr> 00049 </table> 00050 EOT 00051 ), 'Stripping HTML tables' ); 00052 00053 $this->assertEquals( 00054 'a b', 00055 $this->updateText( 'a > b' ), 00056 'Handle unclosed tags' 00057 ); 00058 00059 $text = str_pad( "foo <barbarbar \n", 10000, 'x' ); 00060 00061 $this->assertNotEquals( 00062 '', 00063 $this->updateText( $text ), 00064 'Bug 18609' 00065 ); 00066 } 00067 00072 public function testBug32712() { 00073 $text = "text „http://example.com“ text"; 00074 $result = $this->updateText( $text ); 00075 $processed = preg_replace( '/Q/u', 'Q', $result ); 00076 $this->assertTrue( 00077 $processed != '', 00078 'Link surrounded by unicode quotes should not fail UTF-8 validation' 00079 ); 00080 } 00081 }