MediaWiki
REL1_24
|
00001 <?php 00002 00007 class SpecialMyLanguageTest extends MediaWikiTestCase { 00008 public function addDBData() { 00009 $titles = array( 00010 'Page/Another', 00011 'Page/Another/ru', 00012 ); 00013 foreach ( $titles as $title ) { 00014 $page = WikiPage::factory( Title::newFromText( $title ) ); 00015 if ( $page->getId() == 0 ) { 00016 $page->doEditContent( 00017 new WikitextContent( 'UTContent' ), 00018 'UTPageSummary', 00019 EDIT_NEW, 00020 false, 00021 User::newFromName( 'UTSysop' ) ); 00022 } 00023 } 00024 } 00025 00034 public function testFindTitle( $expected, $subpage, $langCode, $userLang ) { 00035 $this->setMwGlobals( 'wgLanguageCode', $langCode ); 00036 $special = new SpecialMyLanguage(); 00037 $special->getContext()->setLanguage( $userLang ); 00038 // Test with subpages both enabled and disabled 00039 $this->mergeMwGlobalArrayValue( 'wgNamespacesWithSubpages', array( NS_MAIN => true ) ); 00040 $this->assertTitle( $expected, $special->findTitle( $subpage ) ); 00041 $this->mergeMwGlobalArrayValue( 'wgNamespacesWithSubpages', array( NS_MAIN => false ) ); 00042 $this->assertTitle( $expected, $special->findTitle( $subpage ) ); 00043 } 00044 00049 private function assertTitle( $expected, $title ) { 00050 if ( $title ) { 00051 $title = $title->getPrefixedText(); 00052 } 00053 $this->assertEquals( $expected, $title ); 00054 } 00055 00056 public static function provideFindTitle() { 00057 return array( 00058 array( null, '::Fail', 'en', 'en' ), 00059 array( 'Page/Another', 'Page/Another/en', 'en', 'en' ), 00060 array( 'Page/Another', 'Page/Another', 'en', 'en' ), 00061 array( 'Page/Another/ru', 'Page/Another', 'en', 'ru' ), 00062 array( 'Page/Another', 'Page/Another', 'en', 'es' ), 00063 ); 00064 } 00065 }