Merge "hooks.txt: Convert docs to modern extension registration style"
[lhc/web/wiklou.git] / tests / phpunit / includes / config / GlobalVarConfigTest.php
index db5f73d..591f27d 100644 (file)
@@ -8,8 +8,7 @@ class GlobalVarConfigTest extends MediaWikiTestCase {
        public function testNewInstance() {
                $config = GlobalVarConfig::newInstance();
                $this->assertInstanceOf( GlobalVarConfig::class, $config );
-               $this->maybeStashGlobal( 'wgBaz' );
-               $GLOBALS['wgBaz'] = 'somevalue';
+               $this->setMwGlobals( 'wgBaz', 'somevalue' );
                // Check prefix is set to 'wg'
                $this->assertEquals( 'somevalue', $config->get( 'Baz' ) );
        }
@@ -20,12 +19,10 @@ class GlobalVarConfigTest extends MediaWikiTestCase {
         */
        public function testConstructor( $prefix ) {
                $var = $prefix . 'GlobalVarConfigTest';
-               $rand = wfRandomString();
-               $this->maybeStashGlobal( $var );
-               $GLOBALS[$var] = $rand;
+               $this->setMwGlobals( $var, 'testvalue' );
                $config = new GlobalVarConfig( $prefix );
                $this->assertInstanceOf( GlobalVarConfig::class, $config );
-               $this->assertEquals( $rand, $config->get( 'GlobalVarConfigTest' ) );
+               $this->assertEquals( 'testvalue', $config->get( 'GlobalVarConfigTest' ) );
        }
 
        public static function provideConstructor() {
@@ -43,9 +40,7 @@ class GlobalVarConfigTest extends MediaWikiTestCase {
         * @covers GlobalVarConfig::hasWithPrefix
         */
        public function testHas() {
-               $this->maybeStashGlobal( 'wgGlobalVarConfigTestHas' );
-               $GLOBALS['wgGlobalVarConfigTestHas'] = wfRandomString();
-               $this->maybeStashGlobal( 'wgGlobalVarConfigTestNotHas' );
+               $this->setMwGlobals( 'wgGlobalVarConfigTestHas', 'testvalue' );
                $config = new GlobalVarConfig();
                $this->assertTrue( $config->has( 'GlobalVarConfigTestHas' ) );
                $this->assertFalse( $config->has( 'GlobalVarConfigTestNotHas' ) );
@@ -87,11 +82,4 @@ class GlobalVarConfigTest extends MediaWikiTestCase {
                }
                $this->assertEquals( $config->get( $name ), $expected );
        }
-
-       private function maybeStashGlobal( $var ) {
-               if ( array_key_exists( $var, $GLOBALS ) ) {
-                       // Will be reset after this test is over
-                       $this->stashMwGlobals( $var );
-               }
-       }
 }