Merge "Introduce ContentHandler::exportTransform()"
[lhc/web/wiklou.git] / tests / phpunit / includes / config / ConfigFactoryTest.php
1 <?php
2
3 class ConfigFactoryTest extends MediaWikiTestCase {
4
5 /**
6 * @covers ConfigFactory::register
7 */
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' );
14 }
15
16 /**
17 * @covers ConfigFactory::makeConfig
18 */
19 public function testMakeConfig() {
20 $factory = new ConfigFactory();
21 $factory->register( 'unittest', 'GlobalVarConfig::newInstance' );
22 $conf = $factory->makeConfig( 'unittest' );
23 $this->assertInstanceOf( 'Config', $conf );
24 }
25
26 /**
27 * @covers ConfigFactory::makeConfig
28 */
29 public function testMakeConfigWithNoBuilders() {
30 $factory = new ConfigFactory();
31 $this->setExpectedException( 'ConfigException' );
32 $factory->makeConfig( 'nobuilderregistered' );
33 }
34
35 /**
36 * @covers ConfigFactory::makeConfig
37 */
38 public function testMakeConfigWithInvalidCallback() {
39 $factory = new ConfigFactory();
40 $factory->register( 'unittest', function() {
41 return true; // Not a Config object
42 });
43 $this->setExpectedException( 'UnexpectedValueException' );
44 $factory->makeConfig( 'unittest' );
45 }
46 }