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 function update( $text, $title = 'Test', $id = 1 ) {
29 $u = new SearchUpdate( $id, $title, $text );
31 return array( MockSearch
::$title, MockSearch
::$text );
34 function updateText( $text ) {
35 list( , $resultText ) = $this->update( $text );
36 $resultText = trim( $resultText ); // abstract from some implementation details
40 function testUpdateText() {
43 $this->updateText( '<div>TeSt</div>' ),
44 'HTML stripped, text lowercased'
49 $this->updateText( <<<EOT
50 <table style="color:red; font-size:100px">
51 <tr class="scary"><td><div>foo</div></td><tr>bar</td></tr>
52 <tr><td>boz</td><tr>quux</td></tr>
55 ), 'Stripping HTML tables' );
59 $this->updateText( 'a > b' ),
60 'Handle unclosed tags'
63 $text = str_pad( "foo <barbarbar \n", 10000, 'x' );
65 $this->assertNotEquals(
67 $this->updateText( $text ),
72 function testBug32712() {
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'