]> scripts.mit.edu Git - autoinstallsdev/mediawiki.git/blobdiff - tests/SearchEngineTest.php
MediaWiki 1.11.0
[autoinstallsdev/mediawiki.git] / tests / SearchEngineTest.php
index cc3df09c86617363857de1dc48b65c9780c318df..0ae14bddbf85bc9997e83aa3ca9c5dbf88f239eb 100644 (file)
@@ -1,19 +1,11 @@
 <?php
 
-$IP = '..';
-require_once( 'PHPUnit.php' );
-require_once( '../includes/Defines.php' );
-require_once( '../includes/DefaultSettings.php' );
-require_once( '../includes/Profiling.php' );
-require_once( '../includes/MagicWord.php' );
-require_once( '../languages/Language.php' );
-require_once( '../languages/LanguageUtf8.php' );
+require_once 'MediaWiki_TestCase.php';
 
-require_once( '../includes/SearchEngine.php' );
-
-class SearchEngine_TestCase extends PHPUnit_TestCase {
+/** @todo document */
+class SearchEngineTest extends MediaWiki_TestCase {
        var $db, $search;
-       
+
        function insertSearchData() {
                $this->db->safeQuery( <<<END
                INSERT INTO ! (page_id,page_namespace,page_title,page_latest)
@@ -72,11 +64,11 @@ END
 END
                        , $this->db->tableName( 'searchindex' ) );
        }
-       
+
        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;
@@ -85,50 +77,60 @@ END
                sort( $matches );
                return $matches;
        }
-       
+
        function testTextSearch() {
                $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" );
                }
        }
-       
+
        function testTextPowerSearch() {
                $this->assertFalse( is_null( $this->db ), "Can't find a database to test with." );
                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" );
                }
        }
-       
+
        function testTitleSearch() {
                $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" );
                }
        }
-       
+
        function testTextTitlePowerSearch() {
                $this->assertFalse( is_null( $this->db ), "Can't find a database to test with." );
                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" );
                }
        }
-       
+
 }
 
 
-?>
\ No newline at end of file
+