MediaWiki  REL1_23
SampleTest.php
Go to the documentation of this file.
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 
00049     public function provideTitles() {
00050         return array(
00051             array( 'Text', NS_MEDIA, 'Media:Text' ),
00052             array( 'Text', null, 'Text' ),
00053             array( 'text', null, 'Text' ),
00054             array( 'Text', NS_USER, 'User:Text' ),
00055             array( 'Photo.jpg', NS_FILE, 'File:Photo.jpg' )
00056         );
00057     }
00058 
00063     public function testCreateBasicListOfTitles( $titleName, $ns, $text ) {
00064         $title = Title::newFromText( $titleName, $ns );
00065         $this->assertEquals( $text, "$title", "see if '$titleName' matches '$text'" );
00066     }
00067 
00068     public function testSetUpMainPageTitleForNextTest() {
00069         $title = Title::newMainPage();
00070         $this->assertEquals( "Main Page", "$title", "Test initial creation of a title" );
00071 
00072         return $title;
00073     }
00074 
00091     public function testCheckMainPageTitleIsConsideredLocal( $title ) {
00092         $this->assertTrue( $title->isLocal() );
00093     }
00094 
00099     public function testTitleObjectFromObject() {
00100         $title = Title::newFromText( Title::newFromText( "test" ) );
00101         $this->assertEquals( "Test", $title->isLocal() );
00102     }
00103 }