+#!/usr/bin/env php\r
+<?php\r
+\r
+require 't/Test.php';\r
+\r
+plan( 4 );\r
+\r
+define( 'MEDIAWIKI', 1 );\r
+require 'includes/Defines.php';\r
+require 'includes/ProfilerStub.php';\r
+require 'includes/AutoLoader.php';\r
+require 'LocalSettings.php';\r
+\r
+require 't/DatabaseMock.inc';\r
+\r
+$wgSearchType = 'MockSearch';\r
+\r
+require 'includes/Setup.php';\r
+\r
+\r
+class MockSearch extends SearchEngine {\r
+ public static $id;\r
+ public static $title;\r
+ public static $text;\r
+\r
+ public function __construct( $db ) {\r
+ }\r
+\r
+ public function update( $id, $title, $text ) {\r
+ self::$id = $id;\r
+ self::$title = $title;\r
+ self::$text = $text;\r
+ }\r
+}\r
+\r
+function update( $text, $title = 'Test', $id = 1 ) {\r
+ $u = new SearchUpdate( $id, $title, $text );\r
+ $u->doUpdate();\r
+ return array( MockSearch::$title, MockSearch::$text );\r
+}\r
+\r
+function updateText( $text ) {\r
+ list( $title, $resultText ) = update( $text );\r
+ $resultText = trim( $resultText ); // abstract from some implementation details\r
+ return $resultText;\r
+}\r
+\r
+is( updateText( '<div>TeSt</div>' ), 'test', 'HTML stripped, text lowercased' );\r
+\r
+is( updateText( <<<EOT\r
+<table style="color:red; font-size:100px">\r
+ <tr class="scary"><td><div>foo</div></td><tr>bar</td></tr>\r
+ <tr><td>boz</td><tr>quux</td></tr>\r
+</table>\r
+EOT\r
+), 'foo bar boz quux', 'Stripping HTML tables' );\r
+\r
+is( updateText( 'a > b' ), 'a b', 'Handle unclosed tags' );\r
+\r
+$text = str_pad( "foo <barbarbar \n", 10000, 'x' );\r
+ok( updateText( $text ) != '', 'Bug 18609' );
\ No newline at end of file