MediaWiki
REL1_22
|
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 ) ); 00020 } 00021 00025 protected function tearDown() { 00026 parent::tearDown(); 00027 } 00028 00036 public function testTitleObjectStringConversion() { 00037 $title = Title::newFromText( "text" ); 00038 $this->assertInstanceOf( 'Title', $title, "Title creation" ); 00039 $this->assertEquals( "Text", $title, "Automatic string conversion" ); 00040 00041 $title = Title::newFromText( "text", NS_MEDIA ); 00042 $this->assertEquals( "Media:Text", $title, "Title creation with namespace" ); 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 public function testTitleObjectFromObject() { 00102 $title = Title::newFromText( Title::newFromText( "test" ) ); 00103 $this->assertEquals( "Test", $title->isLocal() ); 00104 } 00105 }