MediaWiki  REL1_22
TestSites.php
Go to the documentation of this file.
00001 <?php
00002 
00032 class TestSites {
00033 
00039     public static function getSites() {
00040         $sites = array();
00041 
00042         $site = new Site();
00043         $site->setGlobalId( 'foobar' );
00044         $sites[] = $site;
00045 
00046         $site = new MediaWikiSite();
00047         $site->setGlobalId( 'enwiktionary' );
00048         $site->setGroup( 'wiktionary' );
00049         $site->setLanguageCode( 'en' );
00050         $site->addNavigationId( 'enwiktionary' );
00051         $site->setPath( MediaWikiSite::PATH_PAGE, "https://en.wiktionary.org/wiki/$1" );
00052         $site->setPath( MediaWikiSite::PATH_FILE, "https://en.wiktionary.org/w/$1" );
00053         $sites[] = $site;
00054 
00055         $site = new MediaWikiSite();
00056         $site->setGlobalId( 'dewiktionary' );
00057         $site->setGroup( 'wiktionary' );
00058         $site->setLanguageCode( 'de' );
00059         $site->addInterwikiId( 'dewiktionary' );
00060         $site->addInterwikiId( 'wiktionaryde' );
00061         $site->setPath( MediaWikiSite::PATH_PAGE, "https://de.wiktionary.org/wiki/$1" );
00062         $site->setPath( MediaWikiSite::PATH_FILE, "https://de.wiktionary.org/w/$1" );
00063         $sites[] = $site;
00064 
00065         $site = new Site();
00066         $site->setGlobalId( 'spam' );
00067         $site->setGroup( 'spam' );
00068         $site->setLanguageCode( 'en' );
00069         $site->addNavigationId( 'spam' );
00070         $site->addNavigationId( 'spamz' );
00071         $site->addInterwikiId( 'spamzz' );
00072         $site->setLinkPath( "http://spamzz.test/testing/" );
00073         $sites[] = $site;
00074 
00075         foreach ( array( 'en', 'de', 'nl', 'sv', 'sr', 'no', 'nn' ) as $langCode ) {
00076             $site = new MediaWikiSite();
00077             $site->setGlobalId( $langCode . 'wiki' );
00078             $site->setGroup( 'wikipedia' );
00079             $site->setLanguageCode( $langCode );
00080             $site->addInterwikiId( $langCode );
00081             $site->addNavigationId( $langCode );
00082             $site->setPath( MediaWikiSite::PATH_PAGE, "https://$langCode.wikipedia.org/wiki/$1" );
00083             $site->setPath( MediaWikiSite::PATH_FILE, "https://$langCode.wikipedia.org/w/$1" );
00084             $sites[] = $site;
00085         }
00086 
00087         return $sites;
00088     }
00089 
00095     public static function insertIntoDb() {
00096         $sitesTable = SiteSQLStore::newInstance();
00097         $sitesTable->clear();
00098         $sitesTable->saveSites( TestSites::getSites() );
00099     }
00100 }