3 class ResourceLoaderStartupModuleTest
extends ResourceLoaderTestCase
{
5 public static function provideGetModuleRegistrations() {
8 'msg' => 'Empty registry',
11 mw.loader.addSource( {
13 "loadScript": "/w/load.php",
14 "apiScript": "/w/api.php"
16 } );mw.loader.register( [] );'
19 'msg' => 'Basic registry',
21 'test.blank' => new ResourceLoaderTestModule(),
24 mw.loader.addSource( {
26 "loadScript": "/w/load.php",
27 "apiScript": "/w/api.php"
29 } );mw.loader.register( [
37 'msg' => 'Group signature',
39 'test.blank' => new ResourceLoaderTestModule(),
40 'test.group.foo' => new ResourceLoaderTestModule( array( 'group' => 'x-foo' ) ),
41 'test.group.bar' => new ResourceLoaderTestModule( array( 'group' => 'x-bar' ) ),
44 mw.loader.addSource( {
46 "loadScript": "/w/load.php",
47 "apiScript": "/w/api.php"
49 } );mw.loader.register( [
69 'msg' => 'Different target (non-test should not be registered)',
71 'test.blank' => new ResourceLoaderTestModule(),
72 'test.target.foo' => new ResourceLoaderTestModule( array( 'targets' => array( 'x-foo' ) ) ),
75 mw.loader.addSource( {
77 "loadScript": "/w/load.php",
78 "apiScript": "/w/api.php"
80 } );mw.loader.register( [
88 'msg' => 'Foreign source',
91 'loadScript' => 'http://example.org/w/load.php',
92 'apiScript' => 'http://example.org/w/api.php',
96 'test.blank' => new ResourceLoaderTestModule( array( 'source' => 'example' ) ),
99 mw.loader.addSource( {
101 "loadScript": "/w/load.php",
102 "apiScript": "/w/api.php"
105 "loadScript": "http://example.org/w/load.php",
106 "apiScript": "http://example.org/w/api.php"
108 } );mw.loader.register( [
119 // This may seem like an edge case, but a plain MediaWiki core install
120 // with a few extensions installed is likely far more complex than this
121 // even, not to mention an install like Wikipedia.
122 // TODO: Make this even more realistic.
123 'msg' => 'Advanced (everything combined)',
126 'loadScript' => 'http://example.org/w/load.php',
127 'apiScript' => 'http://example.org/w/api.php',
131 'test.blank' => new ResourceLoaderTestModule(),
132 'test.x.core' => new ResourceLoaderTestModule(),
133 'test.x.util' => new ResourceLoaderTestModule( array(
134 'dependencies' => array(
138 'test.x.foo' => new ResourceLoaderTestModule( array(
139 'dependencies' => array(
143 'test.x.bar' => new ResourceLoaderTestModule( array(
144 'dependencies' => array(
149 'test.x.quux' => new ResourceLoaderTestModule( array(
150 'dependencies' => array(
156 'test.group.foo.1' => new ResourceLoaderTestModule( array(
159 'test.group.foo.2' => new ResourceLoaderTestModule( array(
162 'test.group.bar.1' => new ResourceLoaderTestModule( array(
165 'test.group.bar.2' => new ResourceLoaderTestModule( array(
167 'source' => 'example',
169 'test.target.foo' => new ResourceLoaderTestModule( array(
170 'targets' => array( 'x-foo' ),
172 'test.target.bar' => new ResourceLoaderTestModule( array(
173 'source' => 'example',
174 'targets' => array( 'x-foo' ),
178 mw.loader.addSource( {
180 "loadScript": "/w/load.php",
181 "apiScript": "/w/api.php"
184 "loadScript": "http://example.org/w/load.php",
185 "apiScript": "http://example.org/w/api.php"
187 } );mw.loader.register( [
258 * @dataProvider provideGetModuleRegistrations
259 * @covers ResourceLoaderStartUpModule::getModuleRegistrations
261 public function testGetModuleRegistrations( $case ) {
262 if ( isset( $case['sources'] ) ) {
263 $this->setMwGlobals( 'wgResourceLoaderSources', $case['sources'] );
266 $context = self
::getResourceLoaderContext();
267 $rl = $context->getResourceLoader();
269 $rl->register( $case['modules'] );
272 ltrim( $case['out'], "\n" ),
273 ResourceLoaderStartUpModule
::getModuleRegistrations( $context ),