MediaWiki  REL1_24
load.mock.php
Go to the documentation of this file.
00001 <?php
00025 header( 'Content-Type: text/javascript; charset=utf-8' );
00026 
00027 require_once __DIR__ . '/../../../includes/json/FormatJson.php';
00028 require_once __DIR__ . '/../../../includes/Xml.php';
00029 
00030 $moduleImplementations = array(
00031     'testUsesMissing' => "
00032 mw.loader.implement( 'testUsesMissing', function () {
00033     QUnit.ok( false, 'Module usesMissing script should not run.' );
00034     QUnit.start();
00035 }, {}, {});
00036 ",
00037 
00038     'testUsesNestedMissing' => "
00039 mw.loader.implement( 'testUsesNestedMissing', function () {
00040     QUnit.ok( false, 'Module testUsesNestedMissing script should not run.' );
00041     QUnit.start();
00042 }, {}, {});
00043 ",
00044 
00045     'testSkipped' =>"
00046 mw.loader.implement( 'testSkipped', function () {
00047     QUnit.ok( false, 'Module testSkipped was supposed to be skipped.' );
00048 }, {}, {});
00049 ",
00050 
00051     'testNotSkipped' =>"
00052 mw.loader.implement( 'testNotSkipped', function () {}, {}, {});
00053 ",
00054 
00055     'testUsesSkippable' =>"
00056 mw.loader.implement( 'testUsesSkippable', function () {}, {}, {});
00057 ",
00058 );
00059 
00060 $response = '';
00061 
00062 // Only support for non-encoded module names, full module names expected
00063 if ( isset( $_GET['modules'] ) ) {
00064     $modules = explode( ',', $_GET['modules'] );
00065     foreach ( $modules as $module ) {
00066         if ( isset( $moduleImplementations[$module] ) ) {
00067             $response .= $moduleImplementations[$module];
00068         } else {
00069             $response .= Xml::encodeJsCall( 'mw.loader.state', array( $module, 'missing' ), true );
00070         }
00071     }
00072 }
00073 
00074 echo $response;