12 $factory->register(
'unittest',
'GlobalVarConfig::newInstance' );
22 $factory->register(
'invalid',
'Invalid callback' );
31 $factory->register(
'invalidInstance',
new stdClass );
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' );
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' );
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' );
143 $factory->makeConfig(
'nobuilderregistered' );
151 $factory->register(
'unittest',
function () {
155 $factory->makeConfig(
'unittest' );
164 $factory = MediaWikiServices::getInstance()->getConfigFactory();
165 $this->assertInstanceOf(
Config::class, $factory->makeConfig(
'main' ) );