MediaWiki  REL1_23
ConfigFactoryTest.php
Go to the documentation of this file.
00001 <?php
00002 
00003 class ConfigFactoryTest extends MediaWikiTestCase {
00004 
00008     public function testRegister() {
00009         $factory = new ConfigFactory();
00010         $factory->register( 'unittest', 'GlobalVarConfig::newInstance' );
00011         $this->assertTrue( True ); // No exception thrown
00012         $this->setExpectedException( 'InvalidArgumentException' );
00013         $factory->register( 'invalid', 'Invalid callback' );
00014     }
00015 
00019     public function testMakeConfig() {
00020         $factory = new ConfigFactory();
00021         $factory->register( 'unittest', 'GlobalVarConfig::newInstance' );
00022         $conf = $factory->makeConfig( 'unittest' );
00023         $this->assertInstanceOf( 'Config', $conf );
00024     }
00025 
00029     public function testMakeConfigWithNoBuilders() {
00030         $factory = new ConfigFactory();
00031         $this->setExpectedException( 'ConfigException' );
00032         $factory->makeConfig( 'nobuilderregistered' );
00033     }
00034 
00038     public function testMakeConfigWithInvalidCallback() {
00039         $factory = new ConfigFactory();
00040         $factory->register( 'unittest', function() {
00041             return true; // Not a Config object
00042         });
00043         $this->setExpectedException( 'UnexpectedValueException' );
00044         $factory->makeConfig( 'unittest' );
00045     }
00046 }