MediaWiki
master
|
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 ) ); 00019 } 00020 00024 protected function tearDown() { 00025 parent::tearDown(); 00026 } 00027 00035 function testTitleObjectStringConversion() { 00036 $title = Title::newFromText("text"); 00037 $this->assertEquals("Text", $title->__toString(), "Title creation"); 00038 $this->assertEquals("Text", "Text", "Automatic string conversion"); 00039 00040 $title = Title::newFromText("text", NS_MEDIA); 00041 $this->assertEquals("Media:Text", $title->__toString(), "Title creation with namespace"); 00042 00043 } 00044 00051 public static function provideTitles() { 00052 return array( 00053 array( 'Text', NS_MEDIA, 'Media:Text' ), 00054 array( 'Text', null, 'Text' ), 00055 array( 'text', null, 'Text' ), 00056 array( 'Text', NS_USER, 'User:Text' ), 00057 array( 'Photo.jpg', NS_FILE, 'File:Photo.jpg' ) 00058 ); 00059 } 00060 00065 public function testCreateBasicListOfTitles($titleName, $ns, $text) { 00066 $title = Title::newFromText($titleName, $ns); 00067 $this->assertEquals($text, "$title", "see if '$titleName' matches '$text'"); 00068 } 00069 00070 public function testSetUpMainPageTitleForNextTest() { 00071 $title = Title::newMainPage(); 00072 $this->assertEquals("Main Page", "$title", "Test initial creation of a title"); 00073 00074 return $title; 00075 } 00076 00093 public function testCheckMainPageTitleIsConsideredLocal( $title ) { 00094 $this->assertTrue( $title->isLocal() ); 00095 } 00096 00101 function testTitleObjectFromObject() { 00102 $title = Title::newFromText( Title::newFromText( "test" ) ); 00103 $this->assertEquals( "Test", $title->isLocal() ); 00104 } 00105 } 00106