*/
class ResourceLoaderClientHtmlTest extends PHPUnit_Framework_TestCase {
+ protected static function expandVariables( $text ) {
+ return strtr( $text, [
+ '{blankVer}' => ResourceLoaderTestCase::BLANK_VERSION
+ ] );
+ }
+
protected static function makeContext( $extraQuery = [] ) {
$conf = new HashConfig( [
'ResourceLoaderSources' => [],
'test.scripts.mixed.user.empty' => 'ready',
],
'general' => [
- 'top' => [ 'test.top' ],
- 'bottom' => [ 'test' ],
+ 'test',
+ 'test.top',
],
'styles' => [
'test.styles.mixed',
'test.styles.pure',
],
'scripts' => [
- 'top' => [ 'test.scripts.top' ],
- 'bottom' => [ 'test.scripts' ],
+ 'test.scripts',
+ 'test.scripts.top',
],
'embed' => [
'styles' => [ 'test.styles.private' ],
'general' => [
- 'top' => [ 'test.private.top' ],
- 'bottom' => [ 'test.private.bottom' ],
+ 'test.private.bottom',
+ 'test.private.top',
],
],
];
. '<script>(window.RLQ=window.RLQ||[]).push(function(){'
. 'mw.config.set({"key":"value"});'
. 'mw.loader.state({"test.exempt":"ready","test.private.top":"loading","test.styles.pure":"ready","test.styles.private":"ready","test.scripts.top":"loading"});'
- . 'mw.loader.implement("test.private.top",function($,jQuery,require,module){},{"css":[]});'
+ . 'mw.loader.implement("test.private.top@{blankVer}",function($,jQuery,require,module){},{"css":[]});'
. 'mw.loader.load(["test.top"]);'
. 'mw.loader.load("/w/load.php?debug=false\u0026lang=nl\u0026modules=test.scripts.top\u0026only=scripts\u0026skin=fallback");'
. '});</script>' . "\n"
. '<style>.private{}</style>' . "\n"
. '<script async="" src="/w/load.php?debug=false&lang=nl&modules=startup&only=scripts&skin=fallback"></script>';
// @codingStandardsIgnoreEnd
+ $expected = self::expandVariables( $expected );
$this->assertEquals( $expected, $client->getHeadHtml() );
}
'test.scripts',
] );
- // @codingStandardsIgnoreStart Generic.Files.LineLength
- $expected = '<script>(window.RLQ=window.RLQ||[]).push(function(){'
- . 'mw.loader.implement("test.private.bottom",function($,jQuery,require,module){},{"css":[]});'
- . 'mw.loader.load("/w/load.php?debug=false\u0026lang=nl\u0026modules=test.scripts\u0026only=scripts\u0026skin=fallback");'
- . 'mw.loader.load(["test"]);'
- . '});</script>';
- // @codingStandardsIgnoreEnd
+ $expected = '';
+ $expected = self::expandVariables( $expected );
$this->assertEquals( $expected, $client->getBodyHtml() );
}
'context' => [],
'modules' => [ 'test.private.top' ],
'only' => ResourceLoaderModule::TYPE_COMBINED,
- 'output' => '<script>(window.RLQ=window.RLQ||[]).push(function(){mw.loader.implement("test.private.top",function($,jQuery,require,module){},{"css":[]});});</script>',
+ 'output' => '<script>(window.RLQ=window.RLQ||[]).push(function(){mw.loader.implement("test.private.top@{blankVer}",function($,jQuery,require,module){},{"css":[]});});</script>',
],
[
'context' => [],
'context' => [ 'debug' => true ],
'modules' => [ 'test.styles.pure', 'test.styles.mixed' ],
'only' => ResourceLoaderModule::TYPE_STYLES,
- 'output' => '<link rel="stylesheet" href="/w/load.php?debug=true&lang=nl&modules=test.styles.pure&only=styles&skin=fallback"/>' . "\n"
- . '<link rel="stylesheet" href="/w/load.php?debug=true&lang=nl&modules=test.styles.mixed&only=styles&skin=fallback"/>',
+ 'output' => '<link rel="stylesheet" href="/w/load.php?debug=true&lang=nl&modules=test.styles.mixed&only=styles&skin=fallback"/>' . "\n"
+ . '<link rel="stylesheet" href="/w/load.php?debug=true&lang=nl&modules=test.styles.pure&only=styles&skin=fallback"/>',
+ ],
+ [
+ 'context' => [ 'debug' => false ],
+ 'modules' => [ 'test.styles.pure', 'test.styles.mixed' ],
+ 'only' => ResourceLoaderModule::TYPE_STYLES,
+ 'output' => '<link rel="stylesheet" href="/w/load.php?debug=false&lang=nl&modules=test.styles.mixed%2Cpure&only=styles&skin=fallback"/>',
],
[
'context' => [],
$context = self::makeContext( $extraQuery );
$context->getResourceLoader()->register( self::makeSampleModules() );
$actual = ResourceLoaderClientHtml::makeLoad( $context, $modules, $type );
+ $expected = self::expandVariables( $expected );
$this->assertEquals( $expected, (string)$actual );
}
}