3 class ConfigFactoryTest
extends MediaWikiTestCase
{
6 * @covers ConfigFactory::register
8 public function testRegister() {
9 $factory = new ConfigFactory();
10 $factory->register( 'unittest', 'GlobalVarConfig::newInstance' );
11 $this->assertTrue( true ); // No exception thrown
12 $this->setExpectedException( 'InvalidArgumentException' );
13 $factory->register( 'invalid', 'Invalid callback' );
17 * @covers ConfigFactory::makeConfig
19 public function testMakeConfig() {
20 $factory = new ConfigFactory();
21 $factory->register( 'unittest', 'GlobalVarConfig::newInstance' );
22 $conf = $factory->makeConfig( 'unittest' );
23 $this->assertInstanceOf( 'Config', $conf );
27 * @covers ConfigFactory::makeConfig
29 public function testMakeConfigWithNoBuilders() {
30 $factory = new ConfigFactory();
31 $this->setExpectedException( 'ConfigException' );
32 $factory->makeConfig( 'nobuilderregistered' );
36 * @covers ConfigFactory::makeConfig
38 public function testMakeConfigWithInvalidCallback() {
39 $factory = new ConfigFactory();
40 $factory->register( 'unittest', function () {
41 return true; // Not a Config object
43 $this->setExpectedException( 'UnexpectedValueException' );
44 $factory->makeConfig( 'unittest' );
48 * @covers ConfigFactory::getDefaultInstance
50 public function testGetDefaultInstance() {
51 $factory = ConfigFactory
::getDefaultInstance();
52 $this->assertInstanceOf( 'Config', $factory->makeConfig( 'main' ) );
54 $this->setExpectedException( 'ConfigException' );
55 $factory->makeConfig( 'xyzzy' );