class GlobalVarConfigTest extends MediaWikiTestCase {
+ /**
+ * @covers GlobalVarConfig::newInstance
+ */
+ public function testNewInstance() {
+ $config = GlobalVarConfig::newInstance();
+ $this->assertInstanceOf( 'GlobalVarConfig', $config );
+ }
+
public function provideGet() {
$set = array(
'wgSomething' => 'default1',
* @param string $expected
* @dataProvider provideGet
* @covers GlobalVarConfig::get
+ * @covers GlobalVarConfig::getWithPrefix
*/
public function testGet( $name, $prefix, $expected ) {
$config = new GlobalVarConfig( $prefix );
$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' ),
+ );
+ }
+
+ /**
+ * @dataProvider provideSet
+ * @covers GlobalVarConfig::set
+ * @covers GlobalVarConfig::setWithPrefix
+ */
+ public function testSet( $name, $prefix, $var ) {
+ if ( array_key_exists( $var, $GLOBALS ) ) {
+ // Will be reset after this test is over
+ $this->stashMwGlobals( $var );
+ }
+ $config = new GlobalVarConfig( $prefix );
+ $random = wfRandomString();
+ $config->set( $name, $random );
+ $this->assertArrayHasKey( $var, $GLOBALS );
+ $this->assertEquals( $random, $GLOBALS[$var] );
+ }
}