X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2Fconfig%2FConfigFactoryTest.php;h=3902858d617f8aa889e0b5959abe70e79d137ee7;hb=e1c18325882d7a45b168222116209559cc5f19ca;hp=11bce51b5eccdbecdfe7a0b362aff6d6e11cdbf9;hpb=eeead079979e37e276e2b5411dd82b67988ad357;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/phpunit/includes/config/ConfigFactoryTest.php b/tests/phpunit/includes/config/ConfigFactoryTest.php index 11bce51b5e..3902858d61 100644 --- a/tests/phpunit/includes/config/ConfigFactoryTest.php +++ b/tests/phpunit/includes/config/ConfigFactoryTest.php @@ -2,6 +2,12 @@ class ConfigFactoryTest extends MediaWikiTestCase { + public function tearDown() { + // Reset this since we mess with it a bit + ConfigFactory::destroyDefaultInstance(); + parent::tearDown(); + } + /** * @covers ConfigFactory::register */ @@ -37,10 +43,28 @@ class ConfigFactoryTest extends MediaWikiTestCase { */ public function testMakeConfigWithInvalidCallback() { $factory = new ConfigFactory(); - $factory->register( 'unittest', function() { + $factory->register( 'unittest', function () { return true; // Not a Config object } ); $this->setExpectedException( 'UnexpectedValueException' ); $factory->makeConfig( 'unittest' ); } + + /** + * @covers ConfigFactory::getDefaultInstance + */ + public function testGetDefaultInstance() { + // Set $wgConfigRegistry, and check the default + // instance read from it + $this->setMwGlobals( 'wgConfigRegistry', array( + 'conf1' => 'GlobalVarConfig::newInstance', + 'conf2' => 'GlobalVarConfig::newInstance', + ) ); + ConfigFactory::destroyDefaultInstance(); + $factory = ConfigFactory::getDefaultInstance(); + $this->assertInstanceOf( 'Config', $factory->makeConfig( 'conf1' ) ); + $this->assertInstanceOf( 'Config', $factory->makeConfig( 'conf2' ) ); + $this->setExpectedException( 'ConfigException' ); + $factory->makeConfig( 'conf3' ); + } }