12 $factory->register(
'unittest',
'GlobalVarConfig::newInstance' );
21 $this->setExpectedException(
'InvalidArgumentException' );
22 $factory->register(
'invalid',
'Invalid callback' );
31 $factory->register(
'unittest', $config );
32 $this->assertSame( $config, $factory->makeConfig(
'unittest' ) );
40 $factory->register(
'unittest',
'GlobalVarConfig::newInstance' );
41 $config1 = $factory->makeConfig(
'unittest' );
43 $factory->register(
'unittest',
'GlobalVarConfig::newInstance' );
44 $config2 = $factory->makeConfig(
'unittest' );
46 $this->assertNotSame( $config1, $config2 );
54 $oldFactory->register(
'foo',
'GlobalVarConfig::newInstance' );
55 $oldFactory->register(
'bar',
'GlobalVarConfig::newInstance' );
56 $oldFactory->register(
'quux',
'GlobalVarConfig::newInstance' );
59 $foo = $oldFactory->makeConfig(
'foo' );
60 $bar = $oldFactory->makeConfig(
'bar' );
61 $quux = $oldFactory->makeConfig(
'quux' );
65 $newFactory->register(
'foo',
'GlobalVarConfig::newInstance' );
66 $newFactory->register(
'bar',
function () {
72 $newFactory->salvage( $oldFactory );
74 $newFoo = $newFactory->makeConfig(
'foo' );
75 $this->assertSame( $foo, $newFoo,
'existing instance should be salvaged' );
77 $newBar = $newFactory->makeConfig(
'bar' );
78 $this->assertNotSame( $bar, $newBar,
'don\'t salvage if callbacks differ' );
81 $this->setExpectedException(
'ConfigException' );
82 $newFactory->makeConfig(
'quux' );
90 $factory->register(
'foo',
'GlobalVarConfig::newInstance' );
93 $this->assertEquals( [
'foo',
'bar' ], $factory->getConfigNames() );
101 $factory->register(
'unittest',
'GlobalVarConfig::newInstance' );
103 $conf = $factory->makeConfig(
'unittest' );
104 $this->assertInstanceOf(
'Config', $conf );
105 $this->assertSame( $conf, $factory->makeConfig(
'unittest' ) );
114 $factory->register(
'test', $conf );
115 $this->assertSame( $conf, $factory->makeConfig(
'test' ) );
123 $factory->register(
'*',
'GlobalVarConfig::newInstance' );
124 $conf = $factory->makeConfig(
'unittest' );
125 $this->assertInstanceOf(
'Config', $conf );
133 $this->setExpectedException(
'ConfigException' );
134 $factory->makeConfig(
'nobuilderregistered' );
142 $factory->register(
'unittest',
function () {
145 $this->setExpectedException(
'UnexpectedValueException' );
146 $factory->makeConfig(
'unittest' );
155 $factory = MediaWikiServices::getInstance()->getConfigFactory();
156 $this->assertInstanceOf(
'Config', $factory->makeConfig(
'main' ) );