MediaWiki
REL1_24
|
00001 <?php 00002 00003 class TestSample extends MediaWikiLangTestCase { 00004 00008 protected function setUp() { 00009 // Be sure to do call the parent setup and teardown functions. 00010 // This makes sure that all the various cleanup and restorations 00011 // happen as they should (including the restoration for setMwGlobals). 00012 parent::setUp(); 00013 00014 // This sets the globals and will restore them automatically 00015 // after each test. 00016 $this->setMwGlobals( array( 00017 'wgContLang' => Language::factory( 'en' ), 00018 'wgLanguageCode' => 'en', 00019 'wgCapitalLinks' => true, 00020 ) ); 00021 } 00022 00026 protected function tearDown() { 00027 parent::tearDown(); 00028 } 00029 00037 public function testTitleObjectStringConversion() { 00038 $title = Title::newFromText( "text" ); 00039 $this->assertInstanceOf( 'Title', $title, "Title creation" ); 00040 $this->assertEquals( "Text", $title, "Automatic string conversion" ); 00041 00042 $title = Title::newFromText( "text", NS_MEDIA ); 00043 $this->assertEquals( "Media:Text", $title, "Title creation with namespace" ); 00044 } 00045 00050 public static function provideTitles() { 00051 return array( 00052 array( 'Text', NS_MEDIA, 'Media:Text' ), 00053 array( 'Text', null, 'Text' ), 00054 array( 'text', null, 'Text' ), 00055 array( 'Text', NS_USER, 'User:Text' ), 00056 array( 'Photo.jpg', NS_FILE, 'File:Photo.jpg' ) 00057 ); 00058 } 00059 00066 public function testCreateBasicListOfTitles( $titleName, $ns, $text ) { 00067 $title = Title::newFromText( $titleName, $ns ); 00068 $this->assertEquals( $text, "$title", "see if '$titleName' matches '$text'" ); 00069 } 00070 00071 public function testSetUpMainPageTitleForNextTest() { 00072 $title = Title::newMainPage(); 00073 $this->assertEquals( "Main Page", "$title", "Test initial creation of a title" ); 00074 00075 return $title; 00076 } 00077 00094 public function testCheckMainPageTitleIsConsideredLocal( $title ) { 00095 $this->assertTrue( $title->isLocal() ); 00096 } 00097 00098 // @codingStandardsIgnoreStart Ignore long line warning 00103 // @codingStandardsIgnoreEnd 00104 public function testTitleObjectFromObject() { 00105 $title = Title::newFromText( Title::newFromText( "test" ) ); 00106 $this->assertEquals( "Test", $title->isLocal() ); 00107 } 00108 }