]> scripts.mit.edu Git - autoinstallsdev/mediawiki.git/blob - tests/phpunit/includes/resourceloader/ResourceLoaderOOUIImageModuleTest.php
MediaWiki 1.30.2
[autoinstallsdev/mediawiki.git] / tests / phpunit / includes / resourceloader / ResourceLoaderOOUIImageModuleTest.php
1 <?php
2
3 /**
4  * @group ResourceLoader
5  */
6 class ResourceLoaderOOUIImageModuleTest extends ResourceLoaderTestCase {
7
8         /**
9          * @covers ResourceLoaderOOUIImageModule::loadFromDefinition
10          */
11         public function testNonDefaultSkin() {
12                 $module = new ResourceLoaderOOUIImageModule( [
13                         'class' => 'ResourceLoaderOOUIImageModule',
14                         'name' => 'icons',
15                         'rootPath' => 'tests/phpunit/data/resourceloader/oouiimagemodule',
16                 ] );
17
18                 // Pretend that 'fakemonobook' is a real skin using the Apex theme
19                 SkinFactory::getDefaultInstance()->register(
20                         'fakemonobook',
21                         'FakeMonoBook',
22                         function () {
23                         }
24                 );
25                 $r = new ReflectionMethod( 'ExtensionRegistry', 'exportExtractedData' );
26                 $r->setAccessible( true );
27                 $r->invoke( ExtensionRegistry::getInstance(), [
28                         'globals' => [],
29                         'defines' => [],
30                         'callbacks' => [],
31                         'credits' => [],
32                         'autoloaderPaths' => [],
33                         'attributes' => [
34                                 'SkinOOUIThemes' => [
35                                         'fakemonobook' => 'Apex',
36                                 ],
37                         ],
38                 ] );
39
40                 $styles = $module->getStyles( $this->getResourceLoaderContext( [ 'skin' => 'fakemonobook' ] ) );
41                 $this->assertRegExp(
42                         '/stu-apex/',
43                         $styles['all'],
44                         'Generated styles use the non-default image (embed)'
45                 );
46                 $this->assertRegExp(
47                         '/fakemonobook/',
48                         $styles['all'],
49                         'Generated styles use the non-default image (link)'
50                 );
51
52                 $styles = $module->getStyles( $this->getResourceLoaderContext() );
53                 $this->assertRegExp(
54                         '/stu-wikimediaui/',
55                         $styles['all'],
56                         'Generated styles use the default image (embed)'
57                 );
58                 $this->assertRegExp(
59                         '/vector/',
60                         $styles['all'],
61                         'Generated styles use the default image (link)'
62                 );
63         }
64
65 }