Merge "Indicate the actual version of HHVM in use"
[lhc/web/wiklou.git] / tests / phpunit / includes / OutputPageTest.php
index 2cfdfcd..5c1994b 100644 (file)
@@ -25,7 +25,7 @@ class OutputPageTest extends MediaWikiTestCase {
         * options['expectedReturn'] - expected return value
         * options['message'] - PHPUnit message for assertion
         *
-        * @param array $args key-value array of arguments as shown above
+        * @param array $args Key-value array of arguments as shown above
         */
        protected function assertTransformCssMediaCase( $args ) {
                $queryData = array();
@@ -141,35 +141,40 @@ class OutputPageTest extends MediaWikiTestCase {
                        // Load module script only
                        array(
                                array( 'test.foo', ResourceLoaderModule::TYPE_SCRIPTS ),
-                               '<script src="http://127.0.0.1:8080/w/load.php?debug=false&amp;lang=en&amp;modules=test.foo&amp;only=scripts&amp;skin=vector&amp;*"></script>
+                               '<script src="http://127.0.0.1:8080/w/load.php?debug=false&amp;lang=en&amp;modules=test.foo&amp;only=scripts&amp;skin=fallback&amp;*"></script>
 '
                        ),
                        // Load module styles only
                        // This also tests the order the modules are put into the url
                        array(
                                array( array( 'test.baz', 'test.foo', 'test.bar' ), ResourceLoaderModule::TYPE_STYLES ),
-                               '<link rel=stylesheet href="http://127.0.0.1:8080/w/load.php?debug=false&amp;lang=en&amp;modules=test.bar%2Cbaz%2Cfoo&amp;only=styles&amp;skin=vector&amp;*">
+                               '<link rel=stylesheet href="http://127.0.0.1:8080/w/load.php?debug=false&amp;lang=en&amp;modules=test.bar%2Cbaz%2Cfoo&amp;only=styles&amp;skin=fallback&amp;*">
+'
+                       ),
+                       // Load private module (scripts)
+                       array(
+                               array( 'test.quux', ResourceLoaderModule::TYPE_SCRIPTS ),
+                               '<script>if(window.mw){mw.test.baz({token:123});mw.loader.state({"test.quux":"ready"});}
+</script>
 '
                        ),
                        // Load private module (combined)
                        array(
                                array( 'test.quux', ResourceLoaderModule::TYPE_COMBINED ),
-                               '<script>if(window.mw){
-mw.loader.implement("test.quux",function($,jQuery){mw.test.baz({token:123});},{"css":[".mw-icon{transition:none}\n/* cache key: wiki:resourceloader:filter:minify-css:7:fd8ea20b3336b2bfb230c789d430067a */"]},{});
-/* cache key: wiki:resourceloader:filter:minify-js:7:274ccee17be73cd5f4dda5dc2a819188 */
-}</script>
+                               '<script>mw.loader.implement("test.quux",function($,jQuery){mw.test.baz({token:123});},{"css":[".mw-icon{transition:none}\n"]},{});
+</script>
 '
                        ),
                        // Load module script with with ESI
                        array(
                                array( 'test.foo', ResourceLoaderModule::TYPE_SCRIPTS, true ),
-                               '<script><esi:include src="http://127.0.0.1:8080/w/load.php?debug=false&amp;lang=en&amp;modules=test.foo&amp;only=scripts&amp;skin=vector&amp;*" /></script>
+                               '<script><esi:include src="http://127.0.0.1:8080/w/load.php?debug=false&amp;lang=en&amp;modules=test.foo&amp;only=scripts&amp;skin=fallback&amp;*" /></script>
 '
                        ),
                        // Load module styles with with ESI
                        array(
                                array( 'test.foo', ResourceLoaderModule::TYPE_STYLES, true ),
-                               '<style><esi:include src="http://127.0.0.1:8080/w/load.php?debug=false&amp;lang=en&amp;modules=test.foo&amp;only=styles&amp;skin=vector&amp;*" /></style>
+                               '<style><esi:include src="http://127.0.0.1:8080/w/load.php?debug=false&amp;lang=en&amp;modules=test.foo&amp;only=styles&amp;skin=fallback&amp;*" /></style>
 ',
                        ),
                );
@@ -186,16 +191,12 @@ mw.loader.implement("test.quux",function($,jQuery){mw.test.baz({token:123});},{"
                        'wgLoadScript' => 'http://127.0.0.1:8080/w/load.php',
                        // Affects whether CDATA is inserted
                        'wgWellFormedXml' => false,
-                       // Cache key is based on database name, and affects output;
-                       // this test should not touch the database anyways.
-                       'wgDBname' => 'wiki',
-                       'wgDBprefix' => '',
                ) );
                $class = new ReflectionClass( 'OutputPage' );
                $method = $class->getMethod( 'makeResourceLoaderLink' );
                $method->setAccessible( true );
                $ctx = new RequestContext();
-               $ctx->setSkin( Skin::newFromKey( 'vector' ) );
+               $ctx->setSkin( SkinFactory::getDefaultInstance()->makeSkin( 'fallback' ) );
                $ctx->setLanguage( 'en' );
                $out = new OutputPage( $ctx );
                $rl = $out->getResourceLoader();
@@ -219,6 +220,8 @@ mw.loader.implement("test.quux",function($,jQuery){mw.test.baz({token:123});},{"
                        )),
                ) );
                $links = $method->invokeArgs( $out, $args );
-               $this->assertEquals( $expectedHtml, $links['html'] );
+               // Strip comments to avoid variation due to wgDBname in WikiID and cache key
+               $actualHtml = preg_replace( '#/\*[^*]+\*/#', '', $links['html'] );
+               $this->assertEquals( $expectedHtml, $actualHtml );
        }
 }