MediaWiki  1.23.2
SampleTest.php
Go to the documentation of this file.
1 <?php
2 
4 
8  protected function setUp() {
9  // Be sure to do call the parent setup and teardown functions.
10  // This makes sure that all the various cleanup and restorations
11  // happen as they should (including the restoration for setMwGlobals).
12  parent::setUp();
13 
14  // This sets the globals and will restore them automatically
15  // after each test.
16  $this->setMwGlobals( array(
17  'wgContLang' => Language::factory( 'en' ),
18  'wgLanguageCode' => 'en',
19  ) );
20  }
21 
25  protected function tearDown() {
26  parent::tearDown();
27  }
28 
36  public function testTitleObjectStringConversion() {
37  $title = Title::newFromText( "text" );
38  $this->assertInstanceOf( 'Title', $title, "Title creation" );
39  $this->assertEquals( "Text", $title, "Automatic string conversion" );
40 
41  $title = Title::newFromText( "text", NS_MEDIA );
42  $this->assertEquals( "Media:Text", $title, "Title creation with namespace" );
43  }
44 
49  public function provideTitles() {
50  return array(
51  array( 'Text', NS_MEDIA, 'Media:Text' ),
52  array( 'Text', null, 'Text' ),
53  array( 'text', null, 'Text' ),
54  array( 'Text', NS_USER, 'User:Text' ),
55  array( 'Photo.jpg', NS_FILE, 'File:Photo.jpg' )
56  );
57  }
58 
63  public function testCreateBasicListOfTitles( $titleName, $ns, $text ) {
64  $title = Title::newFromText( $titleName, $ns );
65  $this->assertEquals( $text, "$title", "see if '$titleName' matches '$text'" );
66  }
67 
70  $this->assertEquals( "Main Page", "$title", "Test initial creation of a title" );
71 
72  return $title;
73  }
74 
92  $this->assertTrue( $title->isLocal() );
93  }
94 
99  public function testTitleObjectFromObject() {
101  $this->assertEquals( "Test", $title->isLocal() );
102  }
103 }
Title\newFromText
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
Definition: Title.php:189
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
TestSample\testTitleObjectStringConversion
testTitleObjectStringConversion()
Name tests so that PHPUnit can turn them into sentences when they run.
Definition: SampleTest.php:36
Title\newMainPage
static newMainPage()
Create a new Title for the Main Page.
Definition: Title.php:441
TestSample\testTitleObjectFromObject
testTitleObjectFromObject()
@expectedException MWException object See http://www.phpunit.de/manual/3.4/en/appendixes....
Definition: SampleTest.php:99
NS_FILE
const NS_FILE
Definition: Defines.php:85
TestSample\provideTitles
provideTitles()
If you want to run a the same test with a variety of data, use a data provider.
Definition: SampleTest.php:49
TestSample\testCheckMainPageTitleIsConsideredLocal
testCheckMainPageTitleIsConsideredLocal( $title)
Instead of putting a bunch of tests in a single test method, you should put only one or two tests in ...
Definition: SampleTest.php:91
TestSample
Definition: SampleTest.php:3
MediaWikiTestCase\setMwGlobals
setMwGlobals( $pairs, $value=null)
Definition: MediaWikiTestCase.php:302
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
TestSample\tearDown
tearDown()
Anything cleanup you need to do should go here.
Definition: SampleTest.php:25
$title
presenting them properly to the user as errors is done by the caller $title
Definition: hooks.txt:1324
NS_MEDIA
const NS_MEDIA
Definition: Defines.php:67
MediaWikiLangTestCase
Base class that store and restore the Language objects.
Definition: MediaWikiLangTestCase.php:6
TestSample\testCreateBasicListOfTitles
testCreateBasicListOfTitles( $titleName, $ns, $text)
@dataProvider provideTitles See http://www.phpunit.de/manual/3.4/en/appendixes.annotations....
Definition: SampleTest.php:63
TestSample\setUp
setUp()
Anything that needs to happen before your tests should go here.
Definition: SampleTest.php:8
TestSample\testSetUpMainPageTitleForNextTest
testSetUpMainPageTitleForNextTest()
Definition: SampleTest.php:68
NS_USER
const NS_USER
Definition: Defines.php:81
Language\factory
static factory( $code)
Get a cached or new language object for a given language code.
Definition: Language.php:184