Remove usage of deprecated SkinFactory::getDefaultInstance()
[lhc/web/wiklou.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::class,
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 = new SkinFactory();
20 $skinFactory->register(
21 'fakemonobook',
22 'FakeMonoBook',
23 function () {
24 }
25 );
26 $this->setService( 'SkinFactory', $skinFactory );
27
28 $r = new ReflectionMethod( ExtensionRegistry::class, 'exportExtractedData' );
29 $r->setAccessible( true );
30 $r->invoke( ExtensionRegistry::getInstance(), [
31 'globals' => [],
32 'defines' => [],
33 'callbacks' => [],
34 'credits' => [],
35 'autoloaderPaths' => [],
36 'attributes' => [
37 'SkinOOUIThemes' => [
38 'fakemonobook' => 'Apex',
39 ],
40 ],
41 ] );
42
43 $styles = $module->getStyles( $this->getResourceLoaderContext( [ 'skin' => 'fakemonobook' ] ) );
44 $this->assertRegExp(
45 '/stu-apex/',
46 $styles['all'],
47 'Generated styles use the non-default image (embed)'
48 );
49 $this->assertRegExp(
50 '/fakemonobook/',
51 $styles['all'],
52 'Generated styles use the non-default image (link)'
53 );
54
55 $styles = $module->getStyles( $this->getResourceLoaderContext() );
56 $this->assertRegExp(
57 '/stu-wikimediaui/',
58 $styles['all'],
59 'Generated styles use the default image (embed)'
60 );
61 $this->assertRegExp(
62 '/fallback/',
63 $styles['all'],
64 'Generated styles use the default skin (link)'
65 );
66 }
67
68 }