MediaWiki  REL1_19
SampleTest.php
Go to the documentation of this file.
00001 <?php
00002 
00003 class TestSample extends MediaWikiLangTestCase {
00004 
00008         function setUp() {
00009                 global $wgContLang;
00010                 parent::setUp();
00011 
00012                 /* For example, we need to set $wgContLang for creating a new Title */
00013                 $wgContLang = Language::factory( 'en' );
00014         }
00015 
00019         function tearDown() {
00020                 parent::tearDown();
00021         }
00022 
00030         function testTitleObjectStringConversion() {
00031                 $title = Title::newFromText("text");
00032                 $this->assertEquals("Text", $title->__toString(), "Title creation");
00033                 $this->assertEquals("Text", "Text", "Automatic string conversion");
00034 
00035                 $title = Title::newFromText("text", NS_MEDIA);
00036                 $this->assertEquals("Media:Text", $title->__toString(), "Title creation with namespace");
00037 
00038         }
00039 
00044         public function provideTitles() {
00045                 return array(
00046                         array( 'Text', NS_MEDIA, 'Media:Text' ),
00047                         array( 'Text', null, 'Text' ),
00048                         array( 'text', null, 'Text' ),
00049                         array( 'Text', NS_USER, 'User:Text' ),
00050                         array( 'Photo.jpg', NS_IMAGE, 'File:Photo.jpg' )
00051                 );
00052         }
00053 
00058         public function testCreateBasicListOfTitles($titleName, $ns, $text) {
00059                 $title = Title::newFromText($titleName, $ns);
00060                 $this->assertEquals($text, "$title", "see if '$titleName' matches '$text'");
00061         }
00062 
00063         public function testSetUpMainPageTitleForNextTest() {
00064                 $title = Title::newMainPage();
00065                 $this->assertEquals("Main Page", "$title", "Test initial creation of a title");
00066 
00067                 return $title;
00068         }
00069 
00085         public function testCheckMainPageTitleIsConsideredLocal( $title ) {
00086                 $this->assertTrue( $title->isLocal() );
00087         }
00088 
00093         function testTitleObjectFromObject() {
00094                 $title = Title::newFromText( Title::newFromText( "test" ) );
00095                 $this->assertEquals( "Test", $title->isLocal() );
00096         }
00097 }
00098