return $this->hasWithPrefix( $this->prefix, $name );
}
- /**
- * @see MutableConfig::set
- * @deprecated since 1.24
- */
- public function set( $name, $value ) {
- wfDeprecated( __METHOD__, '1.24' );
- $this->setWithPrefix( $this->prefix, $name, $value );
- }
-
/**
* Get a variable with a given prefix, if not the defaults.
*
$var = $prefix . $name;
return array_key_exists( $var, $GLOBALS );
}
-
- /**
- * Get a variable with a given prefix, if not the defaults.
- *
- * @param string $prefix Prefix to use on the variable
- * @param string $name Variable name without prefix
- * @param mixed $value Value to set
- * @deprecated since 1.24
- */
- protected function setWithPrefix( $prefix, $name, $value ) {
- $GLOBALS[$prefix . $name] = $value;
- }
}
$this->assertEquals( $config->get( $name ), $expected );
}
- public static function provideSet() {
- return array(
- array( 'Foo', 'wg', 'wgFoo' ),
- array( 'SomethingRandom', 'wg', 'wgSomethingRandom' ),
- array( 'FromAnExtension', 'eg', 'egFromAnExtension' ),
- array( 'NoPrefixHere', '', 'NoPrefixHere' ),
- );
- }
-
private function maybeStashGlobal( $var ) {
if ( array_key_exists( $var, $GLOBALS ) ) {
// Will be reset after this test is over
$this->stashMwGlobals( $var );
}
}
-
- /**
- * @dataProvider provideSet
- * @covers GlobalVarConfig::set
- * @covers GlobalVarConfig::setWithPrefix
- */
- public function testSet( $name, $prefix, $var ) {
- $this->hideDeprecated( 'GlobalVarConfig::set' );
- $this->maybeStashGlobal( $var );
- $config = new GlobalVarConfig( $prefix );
- $random = wfRandomString();
- $config->set( $name, $random );
- $this->assertArrayHasKey( $var, $GLOBALS );
- $this->assertEquals( $random, $GLOBALS[$var] );
- }
}