+ public static function provideRegistrations() {
+ return array(
+ array( array(
+ 'test.blank' => new ResourceLoaderTestModule(),
+ 'test.min' => new ResourceLoaderTestModule( array(
+ 'skipFunction' =>
+ 'return !!(' .
+ ' window.JSON &&' .
+ ' JSON.parse &&' .
+ ' JSON.stringify' .
+ ');',
+ 'dependencies' => array(
+ 'test.blank',
+ ),
+ ) ),
+ ) )
+ );
+ }
+ /**
+ * @dataProvider provideRegistrations
+ */
+ public function testRegistrationsMinified( $modules ) {
+ $this->setMwGlobals( 'wgResourceLoaderDebug', false );
+
+ $context = self::getResourceLoaderContext();
+ $rl = $context->getResourceLoader();
+ $rl->register( $modules );
+ $this->assertEquals(
+'mw.loader.addSource({"local":{"loadScript":"/w/load.php","apiScript":"/w/api.php"}});'
+. 'mw.loader.register(['
+. '["test.blank","1388534400"],'
+. '["test.min","1388534400",["test.blank"],null,"local",'
+. '"return!!(window.JSON\u0026\u0026JSON.parse\u0026\u0026JSON.stringify);"'
+. ']]);',
+ ResourceLoaderStartUpModule::getModuleRegistrations( $context ),
+ 'Minified output'
+ );
+ }
+
+ /**
+ * @dataProvider provideRegistrations
+ */
+ public function testRegistrationsUnminified( $modules ) {
+ $context = self::getResourceLoaderContext();
+ $rl = $context->getResourceLoader();
+ $rl->register( $modules );
+ $this->assertEquals(
+'mw.loader.addSource( {
+ "local": {
+ "loadScript": "/w/load.php",
+ "apiScript": "/w/api.php"
+ }
+} );mw.loader.register( [
+ [
+ "test.blank",
+ "1388534400"
+ ],
+ [
+ "test.min",
+ "1388534400",
+ [
+ "test.blank"
+ ],
+ null,
+ "local",
+ "return !!( window.JSON \u0026\u0026 JSON.parse \u0026\u0026 JSON.stringify);"
+ ]
+] );',
+ ResourceLoaderStartUpModule::getModuleRegistrations( $context ),
+ 'Unminified output'
+ );
+ }
+