From: Timo Tijhof Date: Tue, 29 May 2018 02:03:31 +0000 (+0100) Subject: resourceloader: Add coverage for empty case in makeModuleResponse X-Git-Tag: 1.34.0-rc.0~5269^2 X-Git-Url: http://git.cyclocoop.org/%7B%24admin_url%7Dmes_infos.php?a=commitdiff_plain;h=af340d58b72092a1e94a4174e6a9bf5ad5ef68e4;p=lhc%2Fweb%2Fwiklou.git resourceloader: Add coverage for empty case in makeModuleResponse Adds coverage for line 1049-1056. Also, follow-up 6292d54dff by simpliying the regex by using /s modifier to enable PCRE_DOTALL which includes matching of new lines. Change-Id: Icec34dfe107d418951b3d155234295c79410ffaa --- diff --git a/tests/phpunit/includes/resourceloader/ResourceLoaderTest.php b/tests/phpunit/includes/resourceloader/ResourceLoaderTest.php index 71a6339536..4ff7719cb7 100644 --- a/tests/phpunit/includes/resourceloader/ResourceLoaderTest.php +++ b/tests/phpunit/includes/resourceloader/ResourceLoaderTest.php @@ -737,6 +737,21 @@ mw.example(); $this->assertEquals( $expected, $response, $message ?: 'Response' ); } + /** + * @covers ResourceLoader::makeModuleResponse + */ + public function testMakeModuleResponseEmpty() { + $rl = new EmptyResourceLoader(); + $context = $this->getResourceLoaderContext( + [ 'modules' => '', 'only' => 'scripts' ], + $rl + ); + + $response = $rl->makeModuleResponse( $context, [] ); + $this->assertSame( [], $rl->getErrors(), 'Errors' ); + $this->assertRegExp( '/^\/\*.+no modules were requested.+\*\/$/ms', $response ); + } + /** * Verify that when building module content in a load.php response, * an exception from one module will not break script output from @@ -809,7 +824,7 @@ mw.example(); $this->assertCount( 2, $errors ); $this->assertRegExp( '/Ferry not found/', $errors[0] ); - $this->assertRegExp( '/Problem.+\n\s*"ferry":\s*"error"/m', $errors[1] ); + $this->assertRegExp( '/Problem.+"ferry":\s*"error"/ms', $errors[1] ); $this->assertEquals( '.foo{}.bar{}', $response