4 * @covers MediaWikiTestCase
5 * @author Adam Shorland
7 class MediaWikiTestCaseTest
extends MediaWikiTestCase
{
9 const GLOBAL_KEY_EXISTING
= 'MediaWikiTestCaseTestGLOBAL-Existing';
10 const GLOBAL_KEY_NONEXISTING
= 'MediaWikiTestCaseTestGLOBAL-NONExisting';
12 public static function setUpBeforeClass() {
13 parent
::setUpBeforeClass();
14 $GLOBALS[self
::GLOBAL_KEY_EXISTING
] = 'foo';
17 public static function tearDownAfterClass() {
18 parent
::tearDownAfterClass();
19 unset( $GLOBALS[self
::GLOBAL_KEY_EXISTING
] );
23 * @covers MediaWikiTestCase::setMwGlobals
24 * @covers MediaWikiTestCase::tearDown
26 public function testSetGlobalsAreRestoredOnTearDown() {
27 $this->setMwGlobals( self
::GLOBAL_KEY_EXISTING
, 'bar' );
30 $GLOBALS[self
::GLOBAL_KEY_EXISTING
],
31 'Global failed to correctly set'
38 $GLOBALS[self
::GLOBAL_KEY_EXISTING
],
39 'Global failed to be restored on tearDown'
44 * @covers MediaWikiTestCase::stashMwGlobals
45 * @covers MediaWikiTestCase::tearDown
47 public function testStashedGlobalsAreRestoredOnTearDown() {
48 $this->stashMwGlobals( self
::GLOBAL_KEY_EXISTING
);
49 $GLOBALS[self
::GLOBAL_KEY_EXISTING
] = 'bar';
52 $GLOBALS[self
::GLOBAL_KEY_EXISTING
],
53 'Global failed to correctly set'
60 $GLOBALS[self
::GLOBAL_KEY_EXISTING
],
61 'Global failed to be restored on tearDown'
66 * @covers MediaWikiTestCase::stashMwGlobals
68 public function testExceptionThrownWhenStashingNonExistentGlobals() {
69 $this->setExpectedException(
71 'Global with key ' . self
::GLOBAL_KEY_NONEXISTING
. ' doesn\'t exist and cant be stashed'
74 $this->stashMwGlobals( self
::GLOBAL_KEY_NONEXISTING
);