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 {
24
function update( $text, $title = 'Test', $id = 1 ) {
25
$u = new SearchUpdate( $id, $title, $text );
27
return array( MockSearch::$title, MockSearch::$text );
30
function updateText( $text ) {
31
list( , $resultText ) = $this->update( $text );
32
$resultText = trim( $resultText ); // abstract from some implementation details
39
self::$searchType = $wgSearchType;
40
$wgSearchType = 'MockSearch';
46
$wgSearchType = self::$searchType;
49
function testUpdateText() {
52
$this->updateText( '<div>TeSt</div>' ),
53
'HTML stripped, text lowercased'
58
$this->updateText( <<<EOT
59
<table style="color:red; font-size:100px">
60
<tr class="scary"><td><div>foo</div></td><tr>bar</td></tr>
61
<tr><td>boz</td><tr>quux</td></tr>
64
), 'Stripping HTML tables' );
68
$this->updateText( 'a > b' ),
69
'Handle unclosed tags'
72
$text = str_pad( "foo <barbarbar \n", 10000, 'x' );
74
$this->assertNotEquals(
76
$this->updateText( $text ),
81
function testBug32712() {
82
$text = "text „http://example.com“ text";
83
$result = $this->updateText( $text );
84
$processed = preg_replace( '/Q/u', 'Q', $result );
87
'Link surrounded by unicode quotes should not fail UTF-8 validation'