summaryrefslogtreecommitdiff
path: root/tests/phpunit/includes/search
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2015-06-04 07:31:04 +0200
committerPierre Schmitz <pierre@archlinux.de>2015-06-04 07:58:39 +0200
commitf6d65e533c62f6deb21342d4901ece24497b433e (patch)
treef28adf0362d14bcd448f7b65a7aaf38650f923aa /tests/phpunit/includes/search
parentc27b2e832fe25651ef2410fae85b41072aae7519 (diff)
Update to MediaWiki 1.25.1
Diffstat (limited to 'tests/phpunit/includes/search')
-rw-r--r--tests/phpunit/includes/search/SearchEngineTest.php67
-rw-r--r--tests/phpunit/includes/search/SearchUpdateTest.php81
2 files changed, 18 insertions, 130 deletions
diff --git a/tests/phpunit/includes/search/SearchEngineTest.php b/tests/phpunit/includes/search/SearchEngineTest.php
index 3da13615..d0cbfa0a 100644
--- a/tests/phpunit/includes/search/SearchEngineTest.php
+++ b/tests/phpunit/includes/search/SearchEngineTest.php
@@ -14,8 +14,6 @@ class SearchEngineTest extends MediaWikiLangTestCase {
*/
protected $search;
- protected $pageList;
-
/**
* Checks for database type & version.
* Will skip current test if DB does not support search.
@@ -37,10 +35,6 @@ class SearchEngineTest extends MediaWikiLangTestCase {
'wgSearchType' => $searchType
) );
- if ( !isset( self::$pageList ) ) {
- $this->addPages();
- }
-
$this->search = new $searchType( $this->db );
}
@@ -50,33 +44,32 @@ class SearchEngineTest extends MediaWikiLangTestCase {
parent::tearDown();
}
- protected function addPages() {
+ public function addDBData() {
if ( !$this->isWikitextNS( NS_MAIN ) ) {
// @todo cover the case of non-wikitext content in the main namespace
return;
}
- $this->insertPage( "Not_Main_Page", "This is not a main page", 0 );
+ $this->insertPage( 'Not_Main_Page', 'This is not a main page' );
$this->insertPage(
'Talk:Not_Main_Page',
- 'This is not a talk page to the main page, see [[smithee]]',
- 1
+ 'This is not a talk page to the main page, see [[smithee]]'
);
- $this->insertPage( 'Smithee', 'A smithee is one who smiths. See also [[Alan Smithee]]', 0 );
- $this->insertPage( 'Talk:Smithee', 'This article sucks.', 1 );
- $this->insertPage( 'Unrelated_page', 'Nothing in this page is about the S word.', 0 );
- $this->insertPage( 'Another_page', 'This page also is unrelated.', 0 );
- $this->insertPage( 'Help:Help', 'Help me!', 4 );
- $this->insertPage( 'Thppt', 'Blah blah', 0 );
- $this->insertPage( 'Alan_Smithee', 'yum', 0 );
- $this->insertPage( 'Pages', 'are\'food', 0 );
- $this->insertPage( 'HalfOneUp', 'AZ', 0 );
- $this->insertPage( 'FullOneUp', 'AZ', 0 );
- $this->insertPage( 'HalfTwoLow', 'az', 0 );
- $this->insertPage( 'FullTwoLow', 'az', 0 );
- $this->insertPage( 'HalfNumbers', '1234567890', 0 );
- $this->insertPage( 'FullNumbers', '1234567890', 0 );
- $this->insertPage( 'DomainName', 'example.com', 0 );
+ $this->insertPage( 'Smithee', 'A smithee is one who smiths. See also [[Alan Smithee]]' );
+ $this->insertPage( 'Talk:Smithee', 'This article sucks.' );
+ $this->insertPage( 'Unrelated_page', 'Nothing in this page is about the S word.' );
+ $this->insertPage( 'Another_page', 'This page also is unrelated.' );
+ $this->insertPage( 'Help:Help', 'Help me!' );
+ $this->insertPage( 'Thppt', 'Blah blah' );
+ $this->insertPage( 'Alan_Smithee', 'yum' );
+ $this->insertPage( 'Pages', 'are\'food' );
+ $this->insertPage( 'HalfOneUp', 'AZ' );
+ $this->insertPage( 'FullOneUp', 'AZ' );
+ $this->insertPage( 'HalfTwoLow', 'az' );
+ $this->insertPage( 'FullTwoLow', 'az' );
+ $this->insertPage( 'HalfNumbers', '1234567890' );
+ $this->insertPage( 'FullNumbers', '1234567890' );
+ $this->insertPage( 'DomainName', 'example.com' );
}
protected function fetchIds( $results ) {
@@ -101,30 +94,6 @@ class SearchEngineTest extends MediaWikiLangTestCase {
return $matches;
}
- /**
- * Insert a new page
- *
- * @param string $pageName Page name
- * @param string $text Page's content
- * @param int $ns Unused
- */
- protected function insertPage( $pageName, $text, $ns ) {
- $title = Title::newFromText( $pageName, $ns );
-
- $user = User::newFromName( 'WikiSysop' );
- $comment = 'Search Test';
-
- // avoid memory leak...?
- LinkCache::singleton()->clear();
-
- $page = WikiPage::factory( $title );
- $page->doEditContent( ContentHandler::makeContent( $text, $title ), $comment, 0, false, $user );
-
- $this->pageList[] = array( $title, $page->getId() );
-
- return true;
- }
-
public function testFullWidth() {
$this->assertEquals(
array( 'FullOneUp', 'FullTwoLow', 'HalfOneUp', 'HalfTwoLow' ),
diff --git a/tests/phpunit/includes/search/SearchUpdateTest.php b/tests/phpunit/includes/search/SearchUpdateTest.php
deleted file mode 100644
index c6275371..00000000
--- a/tests/phpunit/includes/search/SearchUpdateTest.php
+++ /dev/null
@@ -1,81 +0,0 @@
-<?php
-
-class MockSearch extends SearchEngine {
- public static $id;
- public static $title;
- public static $text;
-
- public function __construct( $db ) {
- }
-
- public function update( $id, $title, $text ) {
- self::$id = $id;
- self::$title = $title;
- self::$text = $text;
- }
-}
-
-/**
- * @group Search
- * @group Database
- */
-class SearchUpdateTest extends MediaWikiTestCase {
-
- protected function setUp() {
- parent::setUp();
- $this->setMwGlobals( 'wgSearchType', 'MockSearch' );
- }
-
- public function updateText( $text ) {
- return trim( SearchUpdate::updateText( $text ) );
- }
-
- /**
- * @covers SearchUpdate::updateText
- */
- public function testUpdateText() {
- $this->assertEquals(
- 'test',
- $this->updateText( '<div>TeSt</div>' ),
- 'HTML stripped, text lowercased'
- );
-
- $this->assertEquals(
- 'foo bar boz quux',
- $this->updateText( <<<EOT
-<table style="color:red; font-size:100px">
- <tr class="scary"><td><div>foo</div></td><tr>bar</td></tr>
- <tr><td>boz</td><tr>quux</td></tr>
-</table>
-EOT
- ), 'Stripping HTML tables' );
-
- $this->assertEquals(
- 'a b',
- $this->updateText( 'a > b' ),
- 'Handle unclosed tags'
- );
-
- $text = str_pad( "foo <barbarbar \n", 10000, 'x' );
-
- $this->assertNotEquals(
- '',
- $this->updateText( $text ),
- 'Bug 18609'
- );
- }
-
- /**
- * @covers SearchUpdate::updateText
- * @todo give this test a real name explaining what is being tested here
- */
- public function testBug32712() {
- $text = "text „http://example.com“ text";
- $result = $this->updateText( $text );
- $processed = preg_replace( '/Q/u', 'Q', $result );
- $this->assertTrue(
- $processed != '',
- 'Link surrounded by unicode quotes should not fail UTF-8 validation'
- );
- }
-}