MediaWiki REL1_33
SearchUpdateTest.php
Go to the documentation of this file.
1<?php
2
7
11 private $su;
12
13 protected function setUp() {
14 parent::setUp();
15 $this->setMwGlobals( 'wgSearchType', 'MockSearch' );
16 $this->su = new SearchUpdate( 0, "" );
17 }
18
19 public function updateText( $text ) {
20 return trim( $this->su->updateText( $text ) );
21 }
22
26 public function testUpdateText() {
27 $this->assertEquals(
28 'test',
29 $this->updateText( '<div>TeSt</div>' ),
30 'HTML stripped, text lowercased'
31 );
32
33 $this->assertEquals(
34 'foo bar boz quux',
35 $this->updateText( <<<EOT
36<table style="color:red; font-size:100px">
37 <tr class="scary"><td><div>foo</div></td><tr>bar</td></tr>
38 <tr><td>boz</td><tr>quux</td></tr>
39</table>
40EOT
41 ), 'Stripping HTML tables' );
42
43 $this->assertEquals(
44 'a b',
45 $this->updateText( 'a > b' ),
46 'Handle unclosed tags'
47 );
48
49 $text = str_pad( "foo <barbarbar \n", 10000, 'x' );
50
51 $this->assertNotEquals(
52 '',
53 $this->updateText( $text ),
54 'T20609'
55 );
56 }
57
64 $text = "text „http://example.com“ text";
65 $result = $this->updateText( $text );
66 $processed = preg_replace( '/Q/u', 'Q', $result );
67 $this->assertTrue(
68 $processed != '',
69 'Link surrounded by unicode quotes should not fail UTF-8 validation'
70 );
71 }
72}
73
74class MockSearch extends SearchEngine {
75 public static $id;
76 public static $title;
77 public static $text;
78
79 public function __construct( $db ) {
80 }
81
82 public function update( $id, $title, $text ) {
83 self::$id = $id;
84 self::$title = $title;
85 self::$text = $text;
86 }
87}
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
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