resourceloader: Use 'phpunit' instead of 'test' as default target in PHPUnit tests
[lhc/web/wiklou.git] / tests / phpunit / ResourceLoaderTestCase.php
index deecb31..f22f4a1 100644 (file)
@@ -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 ) )
@@ -25,27 +25,35 @@ abstract class ResourceLoaderTestCase extends MediaWikiTestCase {
                return $ctx;
        }
 
-       protected function setUp() {
-               parent::setUp();
-
-               ResourceLoader::clearCache();
-
-               $this->setMwGlobals( array(
+       public static function getSettings() {
+               return array(
                        // For ResourceLoader::inDebugMode since it doesn't have context
-                       'wgResourceLoaderDebug' => true,
+                       'ResourceLoaderDebug' => true,
 
                        // Avoid influence from wgInvalidateCacheOnLocalSettingsChange
-                       'wgCacheEpoch' => '20140101000000',
+                       'CacheEpoch' => '20140101000000',
 
                        // For ResourceLoader::__construct()
-                       'wgResourceLoaderSources' => array(),
+                       'ResourceLoaderSources' => array(),
 
                        // For wfScript()
-                       'wgScriptPath' => '/w',
-                       'wgScriptExtension' => '.php',
-                       'wgScript' => '/w/index.php',
-                       'wgLoadScript' => '/w/load.php',
-               ) );
+                       'ScriptPath' => '/w',
+                       'ScriptExtension' => '.php',
+                       'Script' => '/w/index.php',
+                       'LoadScript' => '/w/load.php',
+               );
+       }
+
+       protected function setUp() {
+               parent::setUp();
+
+               ResourceLoader::clearCache();
+
+               $globals = array();
+               foreach ( self::getSettings() as $key => $value ) {
+                       $globals['wg' . $key] = $value;
+               }
+               $this->setMwGlobals( $globals );
        }
 }
 
@@ -59,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 ) {
@@ -68,14 +76,14 @@ class ResourceLoaderTestModule extends ResourceLoaderModule {
        }
 
        public function getScript( ResourceLoaderContext $context ) {
-               return $this->script;
+               return $this->validateScriptFile( 'input', $this->script );
        }
 
        public function getStyles( ResourceLoaderContext $context ) {
                return array( '' => $this->styles );
        }
 
-       public function getDependencies() {
+       public function getDependencies( ResourceLoaderContext $context = null ) {
                return $this->dependencies;
        }
 
@@ -94,6 +102,10 @@ class ResourceLoaderTestModule extends ResourceLoaderModule {
        public function isRaw() {
                return $this->isRaw;
        }
+
+       public function enableModuleContentVersion() {
+               return true;
+       }
 }
 
 class ResourceLoaderFileModuleTestModule extends ResourceLoaderFileModule {