Index: branches/JSTesting/includes/resourceloader/ResourceLoader.php |
— | — | @@ -187,7 +187,7 @@ |
188 | 188 | * Registers core modules and runs registration hooks. |
189 | 189 | */ |
190 | 190 | public function __construct() { |
191 | | - global $IP, $wgResourceModules, $wgResourceLoaderSources, $wgLoadScript, $wgEnableJavaScriptTest; |
| 191 | + global $IP, $wgResourceModules, $wgResourceLoaderSources, $wgLoadScript; |
192 | 192 | |
193 | 193 | wfProfileIn( __METHOD__ ); |
194 | 194 | |
— | — | @@ -199,36 +199,13 @@ |
200 | 200 | |
201 | 201 | // Register core modules |
202 | 202 | $this->register( include( "$IP/resources/Resources.php" ) ); |
| 203 | + |
203 | 204 | // Register extension modules |
204 | 205 | wfRunHooks( 'ResourceLoaderRegisterModules', array( &$this ) ); |
205 | 206 | $this->register( $wgResourceModules ); |
206 | 207 | |
207 | | - if ( $wgEnableJavaScriptTest === true ) { |
208 | 208 | |
209 | | - // Get core test suites |
210 | | - $testModules = array(); |
211 | | - $testModules['qunit'] = include( "$IP/tests/qunit/QUnitTestResources.php" ); |
212 | | - // Get other test suites (e.g. from extensions) |
213 | | - wfRunHooks( 'ResourceLoaderTestModules', array( &$testModules, &$this ) ); |
214 | 209 | |
215 | | - // Add the testrunner (which configures QUnit) to the dependencies. |
216 | | - // Since it must be ready before any of the test suites are executed. |
217 | | - foreach( $testModules['qunit'] as $moduleName => $moduleProps ) { |
218 | | - $testModules['qunit'][$moduleName]['dependencies'][] = 'mediawiki.tests.qunit.testrunner'; |
219 | | - } |
220 | | - |
221 | | - foreach( $testModules as $id => $names ) { |
222 | | - // Register test modules |
223 | | - $this->register( $testModules[$id] ); |
224 | | - |
225 | | - // Keep track of their names so that they can be loaded together |
226 | | - $this->testModuleNames[$id] = array_keys( $testModules[$id] ); |
227 | | - } |
228 | | - |
229 | | - } |
230 | | - |
231 | | - |
232 | | - |
233 | 210 | wfProfileOut( __METHOD__ ); |
234 | 211 | } |
235 | 212 | |
— | — | @@ -292,6 +269,39 @@ |
293 | 270 | } |
294 | 271 | |
295 | 272 | /** |
| 273 | + */ |
| 274 | + public function registerTestModules() { |
| 275 | + global $wgEnableJavaScriptTest, $IP; |
| 276 | + if ( $wgEnableJavaScriptTest === false ) { |
| 277 | + throw new MWException( 'Attempt to register JavaScript test modules but <tt>$wgEnableJavaScriptTest</tt> is false. Edit your <tt>LocalSettings.php</tt> to enable it.' ); |
| 278 | + } |
| 279 | + |
| 280 | + wfProfileIn( __METHOD__ ); |
| 281 | + |
| 282 | + // Get core test suites |
| 283 | + $testModules = array(); |
| 284 | + $testModules['qunit'] = include( "$IP/tests/qunit/QUnitTestResources.php" ); |
| 285 | + // Get other test suites (e.g. from extensions) |
| 286 | + wfRunHooks( 'ResourceLoaderTestModules', array( &$testModules, &$this ) ); |
| 287 | + |
| 288 | + // Add the testrunner (which configures QUnit) to the dependencies. |
| 289 | + // Since it must be ready before any of the test suites are executed. |
| 290 | + foreach( $testModules['qunit'] as $moduleName => $moduleProps ) { |
| 291 | + $testModules['qunit'][$moduleName]['dependencies'][] = 'mediawiki.tests.qunit.testrunner'; |
| 292 | + } |
| 293 | + |
| 294 | + foreach( $testModules as $id => $names ) { |
| 295 | + // Register test modules |
| 296 | + $this->register( $testModules[$id] ); |
| 297 | + |
| 298 | + // Keep track of their names so that they can be loaded together |
| 299 | + $this->testModuleNames[$id] = array_keys( $testModules[$id] ); |
| 300 | + } |
| 301 | + |
| 302 | + wfProfileOut( __METHOD__ ); |
| 303 | + } |
| 304 | + |
| 305 | + /** |
296 | 306 | * Add a foreign source of modules. |
297 | 307 | * |
298 | 308 | * Source properties: |
Index: branches/JSTesting/includes/specials/SpecialJavaScriptTest.php |
— | — | @@ -29,6 +29,8 @@ |
30 | 30 | return; |
31 | 31 | } |
32 | 32 | |
| 33 | + $out->getResourceLoader()->registerTestModules(); |
| 34 | + |
33 | 35 | $out->addModules( 'mediawiki.special.javaScriptTest' ); |
34 | 36 | |
35 | 37 | // Determine framework |