8 define( 'MEDIAWIKI', 1 );
9 require 'includes/Defines.php';
10 require 'includes/ProfilerStub.php';
11 require 'includes/AutoLoader.php';
12 require 'LocalSettings.php';
14 require 't/DatabaseMock.inc';
16 $wgSearchType = 'MockSearch';
18 require 'includes/Setup.php';
21 class MockSearch
extends SearchEngine
{
26 public function __construct( $db ) {
29 public function update( $id, $title, $text ) {
31 self
::$title = $title;
36 function update( $text, $title = 'Test', $id = 1 ) {
37 $u = new SearchUpdate( $id, $title, $text );
39 return array( MockSearch
::$title, MockSearch
::$text );
42 function updateText( $text ) {
43 list( $title, $resultText ) = update( $text );
44 $resultText = trim( $resultText ); // abstract from some implementation details
48 is( updateText( '<div>TeSt</div>' ), 'test', 'HTML stripped, text lowercased' );
50 is( updateText( <<<EOT
51 <table style="color:red; font-size:100px">
52 <tr class="scary"><td><div>foo</div></td><tr>bar</td></tr>
53 <tr><td>boz</td><tr>quux</td></tr>
56 ), 'foo bar boz quux', 'Stripping HTML tables' );
58 is( updateText( 'a > b' ), 'a b', 'Handle unclosed tags' );
60 $text = str_pad( "foo <barbarbar \n", 10000, 'x' );
61 ok( updateText( $text ) != '', 'Bug 18609' );