+ // Modified version of WikiRevision::importOldRevision()
+ function insertPage( $pageName, $text, $ns ) {
+ $dbw = $this->db;
+ $title = Title::newFromText( $pageName );
+
+ $userId = 0;
+ $userText = 'WikiSysop';
+ $comment = 'Search Test';
+
+ // avoid memory leak...?
+ $linkCache = LinkCache::singleton();
+ $linkCache->clear();
+
+ $article = new Article( $title );
+ $pageId = $article->getId();
+ $created = false;
+ if( $pageId == 0 ) {
+ # must create the page...
+ $pageId = $article->insertOn( $dbw );
+ $created = true;
+ }
+
+ # FIXME: Use original rev_id optionally (better for backups)
+ # Insert the row
+ $revision = new Revision( array(
+ 'page' => $pageId,
+ 'text' => $text,
+ 'comment' => $comment,
+ 'user' => $userId,
+ 'user_text' => $userText,
+ 'timestamp' => 0,
+ 'minor_edit' => false,
+ ) );
+ $revId = $revision->insertOn( $dbw );
+ $changed = $article->updateIfNewerOn( $dbw, $revision );
+
+ $GLOBALS['wgTitle'] = $title;
+ if( $created ) {
+ Article::onArticleCreate( $title );
+ $article->createUpdates( $revision );
+ } elseif( $changed ) {
+ Article::onArticleEdit( $title );
+ $article->editUpdates(
+ $text, $comment, false, 0, $revId );
+ }
+
+ $su = new SearchUpdate($article->getId(), $pageName, $text);
+ $su->doUpdate();
+
+ $this->pageList[] = array( $title, $article->getId() );
+
+ return true;
+ }
+
+ function testFullWidth() {
+ $this->assertEquals(
+ array( 'FullOneUp', 'FullTwoLow', 'HalfOneUp', 'HalfTwoLow' ),
+ $this->fetchIds( $this->search->searchText( 'AZ' ) ),
+ "Search for normalized from Half-width Upper" );
+ $this->assertEquals(
+ array( 'FullOneUp', 'FullTwoLow', 'HalfOneUp', 'HalfTwoLow' ),
+ $this->fetchIds( $this->search->searchText( 'az' ) ),
+ "Search for normalized from Half-width Lower" );
+ $this->assertEquals(
+ array( 'FullOneUp', 'FullTwoLow', 'HalfOneUp', 'HalfTwoLow' ),
+ $this->fetchIds( $this->search->searchText( 'AZ' ) ),
+ "Search for normalized from Full-width Upper" );
+ $this->assertEquals(
+ array( 'FullOneUp', 'FullTwoLow', 'HalfOneUp', 'HalfTwoLow' ),
+ $this->fetchIds( $this->search->searchText( 'az' ) ),
+ "Search for normalized from Full-width Lower" );
+ }
+
+ function testTextSearch() {
+ $this->assertEquals(
+ array( 'Smithee' ),
+ $this->fetchIds( $this->search->searchText( 'smithee' ) ),
+ "Plain search failed" );