12 $factory->register(
'unittest',
'GlobalVarConfig::newInstance' );
13 $this->assertInstanceOf( GlobalVarConfig::class, $factory->makeConfig(
'unittest' ) );
21 $this->setExpectedException( InvalidArgumentException::class );
22 $factory->register(
'invalid',
'Invalid callback' );
30 $this->setExpectedException( InvalidArgumentException::class );
31 $factory->register(
'invalidInstance',
new stdClass );
38 $config = GlobalVarConfig::newInstance();
40 $factory->register(
'unittest', $config );
41 $this->assertSame( $config, $factory->makeConfig(
'unittest' ) );
49 $factory->register(
'unittest',
'GlobalVarConfig::newInstance' );
50 $config1 = $factory->makeConfig(
'unittest' );
52 $factory->register(
'unittest',
'GlobalVarConfig::newInstance' );
53 $config2 = $factory->makeConfig(
'unittest' );
55 $this->assertNotSame( $config1, $config2 );
63 $oldFactory->register(
'foo',
'GlobalVarConfig::newInstance' );
64 $oldFactory->register(
'bar',
'GlobalVarConfig::newInstance' );
65 $oldFactory->register(
'quux',
'GlobalVarConfig::newInstance' );
68 $foo = $oldFactory->makeConfig(
'foo' );
69 $bar = $oldFactory->makeConfig(
'bar' );
70 $quux = $oldFactory->makeConfig(
'quux' );
74 $newFactory->register(
'foo',
'GlobalVarConfig::newInstance' );
75 $newFactory->register(
'bar',
function () {
81 $newFactory->salvage( $oldFactory );
83 $newFoo = $newFactory->makeConfig(
'foo' );
84 $this->assertSame( $foo, $newFoo,
'existing instance should be salvaged' );
86 $newBar = $newFactory->makeConfig(
'bar' );
87 $this->assertNotSame( $bar, $newBar,
'don\'t salvage if callbacks differ' );
90 $this->setExpectedException( ConfigException::class );
91 $newFactory->makeConfig(
'quux' );
99 $factory->register(
'foo',
'GlobalVarConfig::newInstance' );
100 $factory->register(
'bar',
new HashConfig() );
102 $this->assertEquals( [
'foo',
'bar' ], $factory->getConfigNames() );
110 $factory->register(
'unittest',
'GlobalVarConfig::newInstance' );
112 $conf = $factory->makeConfig(
'unittest' );
113 $this->assertInstanceOf( Config::class, $conf );
114 $this->assertSame( $conf, $factory->makeConfig(
'unittest' ) );
123 $factory->register(
'test', $conf );
124 $this->assertSame( $conf, $factory->makeConfig(
'test' ) );
132 $factory->register(
'*',
'GlobalVarConfig::newInstance' );
133 $conf = $factory->makeConfig(
'unittest' );
134 $this->assertInstanceOf( Config::class, $conf );
142 $this->setExpectedException( ConfigException::class );
143 $factory->makeConfig(
'nobuilderregistered' );
151 $factory->register(
'unittest',
function () {
154 $this->setExpectedException( UnexpectedValueException::class );
155 $factory->makeConfig(
'unittest' );
164 $factory = MediaWikiServices::getInstance()->getConfigFactory();
165 $this->assertInstanceOf( Config::class, $factory->makeConfig(
'main' ) );
testRegister()
ConfigFactory::register.
testRegisterInvalid()
ConfigFactory::register.
testMakeConfigWithCallback()
ConfigFactory::makeConfig.
testMakeConfigWithInvalidCallback()
ConfigFactory::makeConfig.
testMakeConfigWithNoBuilders()
ConfigFactory::makeConfig.
testGetDefaultInstance()
ConfigFactory::getDefaultInstance.
testRegisterInvalidInstance()
ConfigFactory::register.
testRegisterInstance()
ConfigFactory::register.
testMakeConfigFallback()
ConfigFactory::makeConfig.
testGetConfigNames()
ConfigFactory::getConfigNames.
testRegisterAgain()
ConfigFactory::register.
testSalvage()
ConfigFactory::salvage.
testMakeConfigWithObject()
ConfigFactory::makeConfig.
Factory class to create Config objects.
A Config instance which stores all settings as a member variable.