*/
class ResourceLoaderClientHtmlTest extends PHPUnit_Framework_TestCase {
+ use MediaWikiCoversValidator;
+
protected static function expandVariables( $text ) {
return strtr( $text, [
'{blankVer}' => ResourceLoaderTestCase::BLANK_VERSION
'test.top' => [ 'position' => 'top' ],
'test.private.top' => [ 'group' => 'private', 'position' => 'top' ],
'test.private.bottom' => [ 'group' => 'private', 'position' => 'bottom' ],
+ 'test.shouldembed.empty' => [ 'shouldEmbed' => true, 'isKnownEmpty' => true ],
'test.shouldembed' => [ 'shouldEmbed' => true ],
'test.styles.pure' => [ 'type' => ResourceLoaderModule::LOAD_STYLES ],
'test.private.bottom',
'test.private.top',
'test.top',
+ 'test.shouldembed.empty',
'test.shouldembed',
'test.unregistered',
] );
'states' => [
'test.private.top' => 'loading',
'test.private.bottom' => 'loading',
+ 'test.shouldembed.empty' => 'ready',
'test.shouldembed' => 'loading',
'test.styles.pure' => 'ready',
'test.styles.user.empty' => 'ready',
'test.exempt' => 'ready',
] );
- // @codingStandardsIgnoreStart Generic.Files.LineLength
+ // phpcs:disable Generic.Files.LineLength
$expected = '<script>document.documentElement.className = document.documentElement.className.replace( /(^|\s)client-nojs(\s|$)/, "$1client-js$2" );</script>' . "\n"
. '<script>(window.RLQ=window.RLQ||[]).push(function(){'
. 'mw.config.set({"key":"value"});'
. '<link rel="stylesheet" href="/w/load.php?debug=false&lang=nl&modules=test.styles.pure&only=styles&skin=fallback"/>' . "\n"
. '<style>.private{}</style>' . "\n"
. '<script async="" src="/w/load.php?debug=false&lang=nl&modules=startup&only=scripts&skin=fallback"></script>';
- // @codingStandardsIgnoreEnd
+ // phpcs:enable
$expected = self::expandVariables( $expected );
$this->assertEquals( $expected, $client->getHeadHtml() );
}
public static function provideMakeLoad() {
+ // phpcs:disable Generic.Files.LineLength
return [
- // @codingStandardsIgnoreStart Generic.Files.LineLength
[
'context' => [],
'modules' => [ 'test.unknown' ],
'only' => ResourceLoaderModule::TYPE_SCRIPTS,
'output' => '<script async="" src="/w/load.php?debug=false&lang=nl&modules=test.scripts.raw&only=scripts&skin=fallback"></script>',
],
+ [
+ 'context' => [ 'sync' => true ],
+ 'modules' => [ 'test.scripts.raw' ],
+ 'only' => ResourceLoaderModule::TYPE_SCRIPTS,
+ 'output' => '<script src="/w/load.php?debug=false&lang=nl&modules=test.scripts.raw&only=scripts&skin=fallback&sync=1"></script>',
+ ],
[
'context' => [],
'modules' => [ 'test.scripts.user' ],
. '<style>.orderingC{}.orderingD{}</style>' . "\n"
. '<link rel="stylesheet" href="/w/load.php?debug=false&lang=nl&modules=test.ordering.e&only=styles&skin=fallback"/>'
],
- // @codingStandardsIgnoreEnd
];
+ // phpcs:enable
}
/**
public function testMakeLoad( array $extraQuery, array $modules, $type, $expected ) {
$context = self::makeContext( $extraQuery );
$context->getResourceLoader()->register( self::makeSampleModules() );
- $actual = ResourceLoaderClientHtml::makeLoad( $context, $modules, $type );
+ $actual = ResourceLoaderClientHtml::makeLoad( $context, $modules, $type, $extraQuery );
$expected = self::expandVariables( $expected );
$this->assertEquals( $expected, (string)$actual );
}