DefaultSettings: Clean up "URLs and file paths" section.
[lhc/web/wiklou.git] / tests / qunit / data / testloader.php
1 <?php
2 /**
3 * ResourceLoader stub working with pre-defined test modules.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
19 *
20 * @file
21 * @package MediaWiki
22 * @author Lupo
23 * @since 1.20
24 */
25 header( 'Content-Type: text/javascript; charset=utf-8' );
26
27 require_once dirname( __FILE__ ) . "/../../../includes/Xml.php";
28 require_once dirname( __FILE__ ) . "/../../../includes/resourceloader/ResourceLoaderContext.php";
29
30 $modules = array (
31 'test.use_missing' => array (
32 'src' => 'mw.loader.implement("test.use_missing", function () {start(); ok(false, "Module test.use_missing should not run.");}, {}, {});',
33 'deps' => array ( 'test.missing' )
34 ),
35 'test.use_missing2' => array (
36 'src' => 'mw.loader.implement("test.use_missing2", function () {start(); ok(false, "Module test.use_missing2 should not run.");}, {}, {});',
37 'deps' => array ( 'test.missing2' )
38 )
39 );
40
41 function addModule ( $modules, $moduleName, &$gotten ) {
42 $result = "";
43 if ( isset( $gotten[$moduleName] ) ) {
44 return $result;
45 }
46 $gotten[$moduleName] = true;
47 if ( isset( $modules[$moduleName] ) ) {
48 $deps = $modules[$moduleName]['deps'];
49 foreach ( $deps as $depName ) {
50 $result .= addModule( $depName, $gotten ) . "\n";
51 }
52 $result .= $modules[$moduleName]['src'] . "\n";
53 } else {
54 $result .= 'mw.loader.state( ' . Xml::encodeJsVar( $moduleName ) . ', "missing" );' . "\n";
55 }
56 return $result . "\n";
57 }
58
59 $result = "";
60
61 if ( isset( $_GET['modules'] ) ) {
62 $toGet = ResourceLoaderContext::expandModuleNames( $_GET['modules'] );
63 $gotten = array();
64 foreach ( $toGet as $moduleName ) {
65 $result .= addModule( $modules, $moduleName, $gotten );
66 }
67 }
68
69 echo $result;