X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2Fconfig%2FConfigFactoryTest.php;h=ea747afac14fee51573536718ceee4f92ca95fc0;hb=faf7cc4a09848c538320bd2b9067b1a77c0a0183;hp=608d8d949d1126f47c0f2c58436e4f1c3fc42b9a;hpb=956c2430c7b8fceb289aaeacc8d6c2e0def2c56e;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/phpunit/includes/config/ConfigFactoryTest.php b/tests/phpunit/includes/config/ConfigFactoryTest.php index 608d8d949d..ea747afac1 100644 --- a/tests/phpunit/includes/config/ConfigFactoryTest.php +++ b/tests/phpunit/includes/config/ConfigFactoryTest.php @@ -18,10 +18,19 @@ class ConfigFactoryTest extends MediaWikiTestCase { */ public function testRegisterInvalid() { $factory = new ConfigFactory(); - $this->setExpectedException( 'InvalidArgumentException' ); + $this->setExpectedException( InvalidArgumentException::class ); $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 */ @@ -78,7 +87,7 @@ class ConfigFactoryTest extends MediaWikiTestCase { $this->assertNotSame( $bar, $newBar, 'don\'t salvage if callbacks differ' ); // the new factory doesn't have quux defined, so the quux instance should not be salvaged - $this->setExpectedException( 'ConfigException' ); + $this->setExpectedException( ConfigException::class ); $newFactory->makeConfig( 'quux' ); } @@ -101,7 +110,7 @@ class ConfigFactoryTest extends MediaWikiTestCase { $factory->register( 'unittest', 'GlobalVarConfig::newInstance' ); $conf = $factory->makeConfig( 'unittest' ); - $this->assertInstanceOf( 'Config', $conf ); + $this->assertInstanceOf( Config::class, $conf ); $this->assertSame( $conf, $factory->makeConfig( 'unittest' ) ); } @@ -122,7 +131,7 @@ class ConfigFactoryTest extends MediaWikiTestCase { $factory = new ConfigFactory(); $factory->register( '*', 'GlobalVarConfig::newInstance' ); $conf = $factory->makeConfig( 'unittest' ); - $this->assertInstanceOf( 'Config', $conf ); + $this->assertInstanceOf( Config::class, $conf ); } /** @@ -130,7 +139,7 @@ class ConfigFactoryTest extends MediaWikiTestCase { */ public function testMakeConfigWithNoBuilders() { $factory = new ConfigFactory(); - $this->setExpectedException( 'ConfigException' ); + $this->setExpectedException( ConfigException::class ); $factory->makeConfig( 'nobuilderregistered' ); } @@ -142,7 +151,7 @@ class ConfigFactoryTest extends MediaWikiTestCase { $factory->register( 'unittest', function () { return true; // Not a Config object } ); - $this->setExpectedException( 'UnexpectedValueException' ); + $this->setExpectedException( UnexpectedValueException::class ); $factory->makeConfig( 'unittest' ); } @@ -153,7 +162,7 @@ class ConfigFactoryTest extends MediaWikiTestCase { // NOTE: the global config factory returned here has been overwritten // for operation in test mode. It may not reflect LocalSettings. $factory = MediaWikiServices::getInstance()->getConfigFactory(); - $this->assertInstanceOf( 'Config', $factory->makeConfig( 'main' ) ); + $this->assertInstanceOf( Config::class, $factory->makeConfig( 'main' ) ); } }