<?php
-$IP = '..';
-require_once( 'PHPUnit.php' );
-require_once( '../includes/Defines.php' );
-require_once( '../includes/DefaultSettings.php' );
-#require_once( '../includes/Profiling.php' );
-require_once( '../includes/Hooks.php' );
-require_once( '../includes/MagicWord.php' );
-require_once( '../languages/Language.php' );
-
-require_once( '../includes/SearchEngine.php' );
-require_once( '../includes/SearchMySQL.php' );
-require_once( '../includes/SearchMySQL4.php' );
+require_once 'MediaWiki_TestCase.php';
/** @todo document */
-class SearchEngine_TestCase extends PHPUnit_TestCase {
+class SearchEngineTest extends MediaWiki_TestCase {
var $db, $search;
function insertSearchData() {
function fetchIds( &$results ) {
$matches = array();
- while( $row = $results->fetchObject() ) {
- $matches[] = intval( $row->page_id );
+ while( $row = $results->next() ) {
+ $matches[] = $row->getTitle()->getPrefixedText();
}
$results->free();
# Search is not guaranteed to return results in a certain order;
$this->assertFalse( is_null( $this->db ), "Can't find a database to test with." );
if( !is_null( $this->db ) ) {
$this->assertEquals(
- array( 3 ),
+ array( 'Smithee' ),
$this->fetchIds( $this->search->searchText( 'smithee' ) ),
"Plain search failed" );
}
if( !is_null( $this->db ) ) {
$this->search->setNamespaces( array( 0, 1, 4 ) );
$this->assertEquals(
- array( 2, 3 ),
+ array(
+ 'Smithee',
+ 'Talk:Main Page',
+ ),
$this->fetchIds( $this->search->searchText( 'smithee' ) ),
"Power search failed" );
}
$this->assertFalse( is_null( $this->db ), "Can't find a database to test with." );
if( !is_null( $this->db ) ) {
$this->assertEquals(
- array( 3, 9 ),
+ array(
+ 'Alan Smithee',
+ 'Smithee',
+ ),
$this->fetchIds( $this->search->searchTitle( 'smithee' ) ),
"Title search failed" );
}
if( !is_null( $this->db ) ) {
$this->search->setNamespaces( array( 0, 1, 4 ) );
$this->assertEquals(
- array( 3, 4, 9 ),
+ array(
+ 'Alan Smithee',
+ 'Smithee',
+ 'Talk:Smithee',
+ ),
$this->fetchIds( $this->search->searchTitle( 'smithee' ) ),
"Title power search failed" );
}
}
-?>
+