コード例 #1
0
 /**
  * @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);
 }
コード例 #2
0
 /**
  * @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;
 }
コード例 #3
0
 /**
  * @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]);
 }
コード例 #4
0
 /**
  * @covers ConfigFactory::register
  */
 public function testRegisterInstance()
 {
     $config = GlobalVarConfig::newInstance();
     $factory = new ConfigFactory();
     $factory->register('unittest', $config);
     $this->assertSame($config, $factory->makeConfig('unittest'));
 }
コード例 #5
0
 public function getConfig($name)
 {
     if ($this->config === null) {
         $this->config = GlobalVarConfig::newInstance();
     }
     if ($this->config->has($name)) {
         return $this->config->get($name);
     }
     return null;
 }