wiki.techinc.nl/tests/phpunit/includes/resourceloader/ResourceLoaderOOUIImageModuleTest.php
Timo Tijhof b54a1e709e resourceloader: Use 'fallback' as default for ResourceLoaderTestCase
Follows-up fa05976f5f. This broke the Travis CI tests because
the Vector skin is not installed there (unlike in Wikimedia CI).

Make the test no longer reliant on that detail.

* Fix ResourceLoaderTestCase to use a default that actually
  works in plain core (previously 'vector' would be rejected
  as being an unknown skin, but then be re-normalised back to
  'vector' thanks to wgDefaultSkin. This was fixed in fa05976f5f,
  and the unknown skin now produces 'fallback' which is better.

* Update ResourceLoaderOOUIImageModuleTest to match this
  new default and also fix the test message while at it
  to mention 'skin', not 'image'.

Change-Id: I5fb69a6a38a42b1a5f325c0134e01ad880f65087
2019-04-15 20:21:00 +01:00

65 lines
1.6 KiB
PHP

<?php
/**
* @group ResourceLoader
*/
class ResourceLoaderOOUIImageModuleTest extends ResourceLoaderTestCase {
/**
* @covers ResourceLoaderOOUIImageModule::loadFromDefinition
*/
public function testNonDefaultSkin() {
$module = new ResourceLoaderOOUIImageModule( [
'class' => ResourceLoaderOOUIImageModule::class,
'name' => 'icons',
'rootPath' => 'tests/phpunit/data/resourceloader/oouiimagemodule',
] );
// Pretend that 'fakemonobook' is a real skin using the Apex theme
SkinFactory::getDefaultInstance()->register(
'fakemonobook',
'FakeMonoBook',
function () {
}
);
$r = new ReflectionMethod( ExtensionRegistry::class, 'exportExtractedData' );
$r->setAccessible( true );
$r->invoke( ExtensionRegistry::getInstance(), [
'globals' => [],
'defines' => [],
'callbacks' => [],
'credits' => [],
'autoloaderPaths' => [],
'attributes' => [
'SkinOOUIThemes' => [
'fakemonobook' => 'Apex',
],
],
] );
$styles = $module->getStyles( $this->getResourceLoaderContext( [ 'skin' => 'fakemonobook' ] ) );
$this->assertRegExp(
'/stu-apex/',
$styles['all'],
'Generated styles use the non-default image (embed)'
);
$this->assertRegExp(
'/fakemonobook/',
$styles['all'],
'Generated styles use the non-default image (link)'
);
$styles = $module->getStyles( $this->getResourceLoaderContext() );
$this->assertRegExp(
'/stu-wikimediaui/',
$styles['all'],
'Generated styles use the default image (embed)'
);
$this->assertRegExp(
'/fallback/',
$styles['all'],
'Generated styles use the default skin (link)'
);
}
}