- protected static function expandVariables( $text ) {
- return strtr( $text, [
- '{blankVer}' => ResourceLoaderTestCase::BLANK_VERSION
- ] );
- }
-
- protected static function makeContext( $extraQuery = [] ) {
- $conf = new HashConfig( [
- 'ResourceLoaderSources' => [],
- 'ResourceModuleSkinStyles' => [],
- 'ResourceModules' => [],
- 'EnableJavaScriptTest' => false,
- 'LoadScript' => '/w/load.php',
- ] );
- return new ResourceLoaderContext(
- new ResourceLoader( $conf ),
- new FauxRequest( array_merge( [
- 'lang' => 'nl',
- 'skin' => 'fallback',
- 'user' => 'Example',
- 'target' => 'phpunit',
- ], $extraQuery ) )
- );
- }
-
- protected static function makeModule( array $options = [] ) {
- return new ResourceLoaderTestModule( $options );
- }
-
- protected static function makeSampleModules() {
- $modules = [
- 'test' => [],
- 'test.private' => [ 'group' => 'private' ],
- 'test.shouldembed.empty' => [ 'shouldEmbed' => true, 'isKnownEmpty' => true ],
- 'test.shouldembed' => [ 'shouldEmbed' => true ],
- 'test.user' => [ 'group' => 'user' ],
-
- 'test.styles.pure' => [ 'type' => ResourceLoaderModule::LOAD_STYLES ],
- 'test.styles.mixed' => [],
- 'test.styles.noscript' => [
- 'type' => ResourceLoaderModule::LOAD_STYLES,
- 'group' => 'noscript',
- ],
- 'test.styles.user' => [
- 'type' => ResourceLoaderModule::LOAD_STYLES,
- 'group' => 'user',
- ],
- 'test.styles.user.empty' => [
- 'type' => ResourceLoaderModule::LOAD_STYLES,
- 'group' => 'user',
- 'isKnownEmpty' => true,
- ],
- 'test.styles.private' => [
- 'type' => ResourceLoaderModule::LOAD_STYLES,
- 'group' => 'private',
- 'styles' => '.private{}',
- ],
- 'test.styles.shouldembed' => [
- 'type' => ResourceLoaderModule::LOAD_STYLES,
- 'shouldEmbed' => true,
- 'styles' => '.shouldembed{}',
- ],
- 'test.styles.deprecated' => [
- 'type' => ResourceLoaderModule::LOAD_STYLES,
- 'deprecated' => 'Deprecation message.',
- ],
-
- 'test.scripts' => [],
- 'test.scripts.user' => [ 'group' => 'user' ],
- 'test.scripts.user.empty' => [ 'group' => 'user', 'isKnownEmpty' => true ],
- 'test.scripts.raw' => [ 'isRaw' => true ],
- 'test.scripts.shouldembed' => [ 'shouldEmbed' => true ],
-
- 'test.ordering.a' => [ 'shouldEmbed' => false ],
- 'test.ordering.b' => [ 'shouldEmbed' => false ],
- 'test.ordering.c' => [ 'shouldEmbed' => true, 'styles' => '.orderingC{}' ],
- 'test.ordering.d' => [ 'shouldEmbed' => true, 'styles' => '.orderingD{}' ],
- 'test.ordering.e' => [ 'shouldEmbed' => false ],
- ];
- return array_map( function ( $options ) {
- return self::makeModule( $options );
- }, $modules );
- }
-
- /**
- * @covers ResourceLoaderClientHtml::getDocumentAttributes
- */
- public function testGetDocumentAttributes() {
- $client = new ResourceLoaderClientHtml( self::makeContext() );
- $this->assertInternalType( 'array', $client->getDocumentAttributes() );
- }
-
- /**
- * @covers ResourceLoaderClientHtml::__construct
- * @covers ResourceLoaderClientHtml::setModules
- * @covers ResourceLoaderClientHtml::setModuleStyles
- * @covers ResourceLoaderClientHtml::getData
- * @covers ResourceLoaderClientHtml::getContext
- */