MediaWiki REL1_30
SearchUpdateTest.php
Go to the documentation of this file.
1<?php
2
3class MockSearch extends SearchEngine {
4 public static $id;
5 public static $title;
6 public static $text;
7
8 public function __construct( $db ) {
9 }
10
11 public function update( $id, $title, $text ) {
12 self::$id = $id;
13 self::$title = $title;
14 self::$text = $text;
15 }
16}
17
22
26 private $su;
27
28 protected function setUp() {
29 parent::setUp();
30 $this->setMwGlobals( 'wgSearchType', 'MockSearch' );
31 $this->su = new SearchUpdate( 0, "" );
32 }
33
34 public function updateText( $text ) {
35 return trim( $this->su->updateText( $text ) );
36 }
37
41 public function testUpdateText() {
42 $this->assertEquals(
43 'test',
44 $this->updateText( '<div>TeSt</div>' ),
45 'HTML stripped, text lowercased'
46 );
47
48 $this->assertEquals(
49 'foo bar boz quux',
50 $this->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>
54</table>
55EOT
56 ), 'Stripping HTML tables' );
57
58 $this->assertEquals(
59 'a b',
60 $this->updateText( 'a > b' ),
61 'Handle unclosed tags'
62 );
63
64 $text = str_pad( "foo <barbarbar \n", 10000, 'x' );
65
66 $this->assertNotEquals(
67 '',
68 $this->updateText( $text ),
69 'T20609'
70 );
71 }
72
79 $text = "text „http://example.com“ text";
80 $result = $this->updateText( $text );
81 $processed = preg_replace( '/Q/u', 'Q', $result );
82 $this->assertTrue(
83 $processed != '',
84 'Link surrounded by unicode quotes should not fail UTF-8 validation'
85 );
86 }
87}
setMwGlobals( $pairs, $value=null)
Sets a global, maintaining a stashed version of the previous global to be restored in tearDown.
update( $id, $title, $text)
Create or update the search index record for the given page.
Contain a class for special pages.
testUnicodeLinkSearchIndexError()
SearchUpdate::updateText Test T34712 Test if unicode quotes in article links make its search index em...
testUpdateText()
SearchUpdate::updateText.
Database independant search index updater.
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global then executing the whole list after the page is displayed We don t do anything smart like collating updates to the same table or such because the list is almost always going to have just one item on if so it s not worth the trouble Since there is a job queue in the jobs table
Definition deferred.txt:16
Bar style