From: Timo Tijhof Date: Thu, 13 Jul 2017 05:16:53 +0000 (-0700) Subject: resourceloader: Avoid mw-exception log spam from PHPUnit tests X-Git-Tag: 1.31.0-rc.0~2707^2 X-Git-Url: https://git.cyclocoop.org/%7B%7B%20url_for%28?a=commitdiff_plain;h=e4a52de02530fbaec779c7ab3103144eb1fbebf5;p=lhc%2Fweb%2Fwiklou.git resourceloader: Avoid mw-exception log spam from PHPUnit tests Bug: T50002 Change-Id: Ida18f271883535eca2a1d26ee34120190914d87a --- diff --git a/tests/phpunit/includes/resourceloader/ResourceLoaderStartUpModuleTest.php b/tests/phpunit/includes/resourceloader/ResourceLoaderStartUpModuleTest.php index 1e09e92a10..03a609b664 100644 --- a/tests/phpunit/includes/resourceloader/ResourceLoaderStartUpModuleTest.php +++ b/tests/phpunit/includes/resourceloader/ResourceLoaderStartUpModuleTest.php @@ -400,6 +400,10 @@ mw.loader.register( [ $module = new ResourceLoaderStartUpModule(); $out = ltrim( $case['out'], "\n" ); + // Disable log from getModuleRegistrations via MWExceptionHandler + // for case where getVersionHash() is expected to throw. + $this->setLogger( 'exception', new Psr\Log\NullLogger() ); + $this->assertEquals( self::expandPlaceholders( $out ), $module->getModuleRegistrations( $context ), diff --git a/tests/phpunit/includes/resourceloader/ResourceLoaderTest.php b/tests/phpunit/includes/resourceloader/ResourceLoaderTest.php index 1422adc11b..e6f709d782 100644 --- a/tests/phpunit/includes/resourceloader/ResourceLoaderTest.php +++ b/tests/phpunit/includes/resourceloader/ResourceLoaderTest.php @@ -588,7 +588,9 @@ mw.example(); * @covers ResourceLoader::getCombinedVersion */ public function testGetCombinedVersion() { - $rl = new EmptyResourceLoader(); + $rl = $this->getMockBuilder( EmptyResourceLoader::class ) + // Disable log from outputErrorAndLog + ->setMethods( [ 'outputErrorAndLog' ] )->getMock(); $rl->register( [ 'foo' => self::getSimpleModuleMock(), 'ferry' => self::getFailFerryMock(), @@ -720,6 +722,9 @@ mw.example(); $rl ); + // Disable log from makeModuleResponse via outputErrorAndLog + $this->setLogger( 'exception', new Psr\Log\NullLogger() ); + $response = $rl->makeModuleResponse( $context, $modules ); $errors = $rl->getErrors(); @@ -764,6 +769,9 @@ mw.example(); 'getModuleNames' ); + // Disable log from makeModuleResponse via outputErrorAndLog + $this->setLogger( 'exception', new Psr\Log\NullLogger() ); + $modules = [ 'startup' => $rl->getModule( 'startup' ) ]; $response = $rl->makeModuleResponse( $context, $modules ); $errors = $rl->getErrors();