Merge "Fix variable name to match code"
[lhc/web/wiklou.git] / tests / phpunit / includes / config / ConfigFactoryTest.php
index 8a76618..c0e51d7 100644 (file)
@@ -22,6 +22,15 @@ class ConfigFactoryTest extends MediaWikiTestCase {
                $factory->register( 'invalid', 'Invalid callback' );
        }
 
+       /**
+        * @covers ConfigFactory::register
+        */
+       public function testRegisterInvalidInstance() {
+               $factory = new ConfigFactory();
+               $this->setExpectedException( InvalidArgumentException::class );
+               $factory->register( 'invalidInstance', new stdClass );
+       }
+
        /**
         * @covers ConfigFactory::register
         */
@@ -47,7 +56,7 @@ class ConfigFactoryTest extends MediaWikiTestCase {
        }
 
        /**
-        * @covers ConfigFactory::register
+        * @covers ConfigFactory::salvage
         */
        public function testSalvage() {
                $oldFactory = new ConfigFactory();
@@ -63,7 +72,7 @@ class ConfigFactoryTest extends MediaWikiTestCase {
                // define new config instance
                $newFactory = new ConfigFactory();
                $newFactory->register( 'foo', 'GlobalVarConfig::newInstance' );
-               $newFactory->register( 'bar', function() {
+               $newFactory->register( 'bar', function () {
                        return new HashConfig();
                } );
 
@@ -83,7 +92,7 @@ class ConfigFactoryTest extends MediaWikiTestCase {
        }
 
        /**
-        * @covers ConfigFactory::register
+        * @covers ConfigFactory::getConfigNames
         */
        public function testGetConfigNames() {
                $factory = new ConfigFactory();
@@ -96,7 +105,7 @@ class ConfigFactoryTest extends MediaWikiTestCase {
        /**
         * @covers ConfigFactory::makeConfig
         */
-       public function testMakeConfig() {
+       public function testMakeConfigWithCallback() {
                $factory = new ConfigFactory();
                $factory->register( 'unittest', 'GlobalVarConfig::newInstance' );
 
@@ -105,6 +114,16 @@ class ConfigFactoryTest extends MediaWikiTestCase {
                $this->assertSame( $conf, $factory->makeConfig( 'unittest' ) );
        }
 
+       /**
+        * @covers ConfigFactory::makeConfig
+        */
+       public function testMakeConfigWithObject() {
+               $factory = new ConfigFactory();
+               $conf = new HashConfig();
+               $factory->register( 'test', $conf );
+               $this->assertSame( $conf, $factory->makeConfig( 'test' ) );
+       }
+
        /**
         * @covers ConfigFactory::makeConfig
         */