Merge "DatabaseMssql: Don't duplicate body of makeList()"
[mediawiki.git] / tests / phpunit / includes / deferred / SearchUpdateTest.php
blobb70880e80f69615567ee00b7ca3e7c3b721d4e7e
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
20 * @group Database
22 class SearchUpdateTest extends MediaWikiTestCase {
24 protected function setUp() {
25 parent::setUp();
26 $this->setMwGlobals( 'wgSearchType', 'MockSearch' );
29 public function updateText( $text ) {
30 return trim( SearchUpdate::updateText( $text ) );
33 /**
34 * @covers SearchUpdate::updateText
36 public function testUpdateText() {
37 $this->assertEquals(
38 'test',
39 $this->updateText( '<div>TeSt</div>' ),
40 'HTML stripped, text lowercased'
43 $this->assertEquals(
44 'foo bar boz quux',
45 $this->updateText( <<<EOT
46 <table style="color:red; font-size:100px">
47 <tr class="scary"><td><div>foo</div></td><tr>bar</td></tr>
48 <tr><td>boz</td><tr>quux</td></tr>
49 </table>
50 EOT
51 ), 'Stripping HTML tables' );
53 $this->assertEquals(
54 'a b',
55 $this->updateText( 'a > b' ),
56 'Handle unclosed tags'
59 $text = str_pad( "foo <barbarbar \n", 10000, 'x' );
61 $this->assertNotEquals(
62 '',
63 $this->updateText( $text ),
64 'Bug 18609'
68 /**
69 * @covers SearchUpdate::updateText
70 * Test bug 32712
71 * Test if unicode quotes in article links make its search index empty
73 public function testUnicodeLinkSearchIndexError() {
74 $text = "text „http://example.com“ text";
75 $result = $this->updateText( $text );
76 $processed = preg_replace( '/Q/u', 'Q', $result );
77 $this->assertTrue(
78 $processed != '',
79 'Link surrounded by unicode quotes should not fail UTF-8 validation'