* upgrade patches for oracle 1.17->1.19
[mediawiki.git] / tests / phpunit / includes / search / SearchUpdateTest.php
blob935425a6769c26e4b2d56b1b2e0a4d27b62ee8a8
1 <?php
3 class MockSearch extends SearchEngine {
4 public static $id;
5 public static $title;
6 public static $text;
8 public function __construct( $db ) {
11 public function update( $id, $title, $text ) {
12 self::$id = $id;
13 self::$title = $title;
14 self::$text = $text;
18 /**
19 * @group Search
21 class SearchUpdateTest extends MediaWikiTestCase {
22 static $searchType;
24 function update( $text, $title = 'Test', $id = 1 ) {
25 $u = new SearchUpdate( $id, $title, $text );
26 $u->doUpdate();
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
33 return $resultText;
36 function setUp() {
37 global $wgSearchType;
39 self::$searchType = $wgSearchType;
40 $wgSearchType = 'MockSearch';
43 function tearDown() {
44 global $wgSearchType;
46 $wgSearchType = self::$searchType;
49 function testUpdateText() {
50 $this->assertEquals(
51 'test',
52 $this->updateText( '<div>TeSt</div>' ),
53 'HTML stripped, text lowercased'
56 $this->assertEquals(
57 'foo bar boz quux',
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>
62 </table>
63 EOT
64 ), 'Stripping HTML tables' );
66 $this->assertEquals(
67 'a b',
68 $this->updateText( 'a > b' ),
69 'Handle unclosed tags'
72 $text = str_pad( "foo <barbarbar \n", 10000, 'x' );
74 $this->assertNotEquals(
75 '',
76 $this->updateText( $text ),
77 'Bug 18609'