From f1c3e9d7916275a813ec327ed16b365d54072ff2 Mon Sep 17 00:00:00 2001 From: Timo Tijhof Date: Tue, 17 Nov 2015 03:55:19 +0000 Subject: [PATCH] resourceloader: Use 'phpunit' instead of 'test' as default target in PHPUnit tests Follows-up e9b9e4df7a5, which started using target=test as reserved for Special:JavaScriptTest. However that conflicted with this. Without this change, the unit tests fail if the MediaWiki install has $wgEnableJavaScriptTest enabled. Change-Id: I471017e7aedb74dddb4dc18ee4e89c1706ff09b5 --- includes/resourceloader/ResourceLoaderStartUpModule.php | 4 ++-- tests/phpunit/ResourceLoaderTestCase.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/includes/resourceloader/ResourceLoaderStartUpModule.php b/includes/resourceloader/ResourceLoaderStartUpModule.php index e900200c6c..9e840d5b6e 100644 --- a/includes/resourceloader/ResourceLoaderStartUpModule.php +++ b/includes/resourceloader/ResourceLoaderStartUpModule.php @@ -187,8 +187,8 @@ class ResourceLoaderStartUpModule extends ResourceLoaderModule { $resourceLoader = $context->getResourceLoader(); $target = $context->getRequest()->getVal( 'target', 'desktop' ); - // Bypass target filter if this request is from a unit test context. To prevent misuse in - // production, this is only allowed if testing is enabled server-side. + // Bypass target filter if this request is Special:JavaScriptTest. + // To prevent misuse in production, this is only allowed if testing is enabled server-side. $byPassTargetFilter = $this->getConfig()->get( 'EnableJavaScriptTest' ) && $target === 'test'; $out = ''; diff --git a/tests/phpunit/ResourceLoaderTestCase.php b/tests/phpunit/ResourceLoaderTestCase.php index 325b20eec1..f22f4a15a3 100644 --- a/tests/phpunit/ResourceLoaderTestCase.php +++ b/tests/phpunit/ResourceLoaderTestCase.php @@ -13,7 +13,7 @@ abstract class ResourceLoaderTestCase extends MediaWikiTestCase { 'modules' => 'startup', 'only' => 'scripts', 'skin' => 'vector', - 'target' => 'test', + 'target' => 'phpunit', ) ); $ctx = $this->getMockBuilder( 'ResourceLoaderContext' ) ->setConstructorArgs( array( $resourceLoader, $request ) ) @@ -67,7 +67,7 @@ class ResourceLoaderTestModule extends ResourceLoaderModule { protected $styles = ''; protected $skipFunction = null; protected $isRaw = false; - protected $targets = array( 'test' ); + protected $targets = array( 'phpunit' ); public function __construct( $options = array() ) { foreach ( $options as $key => $value ) { -- 2.20.1