/**
* Anything that needs to happen before your tests should go here.
*/
- function setUp() {
- global $wgContLang;
+ protected function setUp() {
+ // Be sure to do call the parent setup and teardown functions.
+ // This makes sure that all the various cleanup and restorations
+ // happen as they should (including the restoration for setMwGlobals).
parent::setUp();
- /* For example, we need to set $wgContLang for creating a new Title */
- $wgContLang = Language::factory( 'en' );
+ // This sets the globals and will restore them automatically
+ // after each test.
+ $this->setMwGlobals( array(
+ 'wgContLang' => Language::factory( 'en' ),
+ 'wgLanguageCode' => 'en',
+ ) );
}
/**
* Anything cleanup you need to do should go here.
*/
- function tearDown() {
+ protected function tearDown() {
parent::tearDown();
}
/**
- * Name tests so that PHPUnit can turn them into sentances when
+ * Name tests so that PHPUnit can turn them into sentences when
* they run. While MediaWiki isn't strictly an Agile Programming
* project, you are encouraged to use the naming described under
* "Agile Documentation" at
/**
* If you want to run a the same test with a variety of data. use a data provider.
* see: http://www.phpunit.de/manual/3.4/en/writing-tests-for-phpunit.html
+ *
+ * Note: Data providers are always called statically and outside setUp/tearDown!
*/
- public function provideTitles() {
+ public static function provideTitles() {
return array(
array( 'Text', NS_MEDIA, 'Media:Text' ),
array( 'Text', null, 'Text' ),
* example) as arguments to the next method (e.g. $title in
* testTitleDepends is whatever testInitialCreatiion returned.)
*/
+
/**
* @depends testSetUpMainPageTitleForNextTest
* See http://www.phpunit.de/manual/3.4/en/appendixes.annotations.html#appendixes.annotations.depends