MediaWiki
REL1_24
|
00001 <?php 00002 00007 class MediaWikiTestCaseTest extends MediaWikiTestCase { 00008 00009 const GLOBAL_KEY_EXISTING = 'MediaWikiTestCaseTestGLOBAL-Existing'; 00010 const GLOBAL_KEY_NONEXISTING = 'MediaWikiTestCaseTestGLOBAL-NONExisting'; 00011 00012 public static function setUpBeforeClass() { 00013 parent::setUpBeforeClass(); 00014 $GLOBALS[self::GLOBAL_KEY_EXISTING] = 'foo'; 00015 } 00016 00017 public static function tearDownAfterClass() { 00018 parent::tearDownAfterClass(); 00019 unset( $GLOBALS[self::GLOBAL_KEY_EXISTING] ); 00020 } 00021 00026 public function testSetGlobalsAreRestoredOnTearDown() { 00027 $this->setMwGlobals( self::GLOBAL_KEY_EXISTING, 'bar' ); 00028 $this->assertEquals( 00029 'bar', 00030 $GLOBALS[self::GLOBAL_KEY_EXISTING], 00031 'Global failed to correctly set' 00032 ); 00033 00034 $this->tearDown(); 00035 00036 $this->assertEquals( 00037 'foo', 00038 $GLOBALS[self::GLOBAL_KEY_EXISTING], 00039 'Global failed to be restored on tearDown' 00040 ); 00041 } 00042 00047 public function testStashedGlobalsAreRestoredOnTearDown() { 00048 $this->stashMwGlobals( self::GLOBAL_KEY_EXISTING ); 00049 $GLOBALS[self::GLOBAL_KEY_EXISTING] = 'bar'; 00050 $this->assertEquals( 00051 'bar', 00052 $GLOBALS[self::GLOBAL_KEY_EXISTING], 00053 'Global failed to correctly set' 00054 ); 00055 00056 $this->tearDown(); 00057 00058 $this->assertEquals( 00059 'foo', 00060 $GLOBALS[self::GLOBAL_KEY_EXISTING], 00061 'Global failed to be restored on tearDown' 00062 ); 00063 } 00064 00068 public function testExceptionThrownWhenStashingNonExistentGlobals() { 00069 $this->setExpectedException( 00070 'Exception', 00071 'Global with key ' . self::GLOBAL_KEY_NONEXISTING . ' doesn\'t exist and cant be stashed' 00072 ); 00073 00074 $this->stashMwGlobals( self::GLOBAL_KEY_NONEXISTING ); 00075 } 00076 00077 }