/** * @param string $name * @param string $prefix * @param string $expected * @dataProvider provideGet * @covers GlobalVarConfig::get * @covers GlobalVarConfig::getWithPrefix */ public function testGet($name, $prefix, $expected) { $config = new GlobalVarConfig($prefix); if ($expected === false) { $this->setExpectedException('ConfigException', 'GlobalVarConfig::get: undefined option:'); } $this->assertEquals($config->get($name), $expected); }
/** * @return Config */ private function newTestConfig() { $globalConfig = new GlobalVarConfig(); $testConfig = new HashConfig(); $testConfig->set('ServiceWiringFiles', $globalConfig->get('ServiceWiringFiles')); $testConfig->set('ConfigRegistry', $globalConfig->get('ConfigRegistry')); return $testConfig; }
/** * @dataProvider provideSet * @covers GlobalVarConfig::set * @covers GlobalVarConfig::setWithPrefix */ public function testSet($name, $prefix, $var) { $this->maybeStashGlobal($var); $config = new GlobalVarConfig($prefix); $random = wfRandomString(); $config->set($name, $random); $this->assertArrayHasKey($var, $GLOBALS); $this->assertEquals($random, $GLOBALS[$var]); }
/** * @covers ConfigFactory::register */ public function testRegisterInstance() { $config = GlobalVarConfig::newInstance(); $factory = new ConfigFactory(); $factory->register('unittest', $config); $this->assertSame($config, $factory->makeConfig('unittest')); }
public function getConfig($name) { if ($this->config === null) { $this->config = GlobalVarConfig::newInstance(); } if ($this->config->has($name)) { return $this->config->get($name); } return null; }