MediaWiki  1.23.0
MediaWikiTestCaseTest.php
Go to the documentation of this file.
1 <?php
2 
8 
9  const GLOBAL_KEY_EXISTING = 'MediaWikiTestCaseTestGLOBAL-Existing';
10  const GLOBAL_KEY_NONEXISTING = 'MediaWikiTestCaseTestGLOBAL-NONExisting';
11 
12  public static function setUpBeforeClass() {
13  parent::setUpBeforeClass();
15  }
16 
17  public static function tearDownAfterClass() {
18  parent::tearDownAfterClass();
19  unset( $GLOBALS[self::GLOBAL_KEY_EXISTING] );
20  }
21 
27  $this->setMwGlobals( self::GLOBAL_KEY_EXISTING, 'bar' );
28  $this->assertEquals(
29  'bar',
30  $GLOBALS[self::GLOBAL_KEY_EXISTING],
31  'Global failed to correctly set'
32  );
33 
34  $this->tearDown();
35 
36  $this->assertEquals(
37  'foo',
38  $GLOBALS[self::GLOBAL_KEY_EXISTING],
39  'Global failed to be restored on tearDown'
40  );
41  }
42 
48  $this->stashMwGlobals( self::GLOBAL_KEY_EXISTING );
50  $this->assertEquals(
51  'bar',
52  $GLOBALS[self::GLOBAL_KEY_EXISTING],
53  'Global failed to correctly set'
54  );
55 
56  $this->tearDown();
57 
58  $this->assertEquals(
59  'foo',
60  $GLOBALS[self::GLOBAL_KEY_EXISTING],
61  'Global failed to be restored on tearDown'
62  );
63  }
64 
69  $this->setExpectedException(
70  'Exception',
71  'Global with key ' . self::GLOBAL_KEY_NONEXISTING . ' doesn\'t exist and cant be stashed'
72  );
73 
74  $this->stashMwGlobals( self::GLOBAL_KEY_NONEXISTING );
75  }
76 
77 }
MediaWikiTestCase\stashMwGlobals
stashMwGlobals( $globalKeys)
Stashes the global, will be restored in tearDown()
Definition: MediaWikiTestCase.php:329
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
MediaWikiTestCaseTest\testStashedGlobalsAreRestoredOnTearDown
testStashedGlobalsAreRestoredOnTearDown()
@covers MediaWikiTestCase::stashMwGlobals @covers MediaWikiTestCase::tearDown
Definition: MediaWikiTestCaseTest.php:47
MediaWikiTestCaseTest\testExceptionThrownWhenStashingNonExistentGlobals
testExceptionThrownWhenStashingNonExistentGlobals()
@covers MediaWikiTestCase::stashMwGlobals
Definition: MediaWikiTestCaseTest.php:68
MediaWikiTestCaseTest\tearDownAfterClass
static tearDownAfterClass()
Definition: MediaWikiTestCaseTest.php:17
MediaWikiTestCaseTest\GLOBAL_KEY_NONEXISTING
const GLOBAL_KEY_NONEXISTING
Definition: MediaWikiTestCaseTest.php:10
MediaWikiTestCase\setMwGlobals
setMwGlobals( $pairs, $value=null)
Definition: MediaWikiTestCase.php:302
MediaWikiTestCase
Definition: MediaWikiTestCase.php:6
MediaWikiTestCaseTest
@covers MediaWikiTestCase
Definition: MediaWikiTestCaseTest.php:7
MediaWikiTestCaseTest\GLOBAL_KEY_EXISTING
const GLOBAL_KEY_EXISTING
Definition: MediaWikiTestCaseTest.php:9
MediaWikiTestCaseTest\setUpBeforeClass
static setUpBeforeClass()
Definition: MediaWikiTestCaseTest.php:12
MediaWikiTestCaseTest\testSetGlobalsAreRestoredOnTearDown
testSetGlobalsAreRestoredOnTearDown()
@covers MediaWikiTestCase::setMwGlobals @covers MediaWikiTestCase::tearDown
Definition: MediaWikiTestCaseTest.php:26
$GLOBALS
$GLOBALS['IP']
Definition: ComposerHookHandler.php:6
MediaWikiTestCase\tearDown
tearDown()
Definition: MediaWikiTestCase.php:216