2017-03-20 19:34:21 +00:00
|
|
|
<?php
|
|
|
|
|
|
2020-02-06 09:44:05 +00:00
|
|
|
use Psr\Container\ContainerInterface;
|
2022-03-09 22:16:22 +00:00
|
|
|
use Wikimedia\ObjectFactory\ObjectFactory;
|
2020-02-06 09:44:05 +00:00
|
|
|
|
2017-03-20 19:34:21 +00:00
|
|
|
/**
|
|
|
|
|
* @group ResourceLoader
|
|
|
|
|
*/
|
|
|
|
|
class ResourceLoaderOOUIImageModuleTest extends ResourceLoaderTestCase {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @covers ResourceLoaderOOUIImageModule::loadFromDefinition
|
|
|
|
|
*/
|
|
|
|
|
public function testNonDefaultSkin() {
|
|
|
|
|
$module = new ResourceLoaderOOUIImageModule( [
|
2018-01-13 00:02:09 +00:00
|
|
|
'class' => ResourceLoaderOOUIImageModule::class,
|
2017-03-20 19:34:21 +00:00
|
|
|
'name' => 'icons',
|
|
|
|
|
'rootPath' => 'tests/phpunit/data/resourceloader/oouiimagemodule',
|
|
|
|
|
] );
|
|
|
|
|
|
|
|
|
|
// Pretend that 'fakemonobook' is a real skin using the Apex theme
|
2020-07-15 05:28:37 +00:00
|
|
|
$skinFactory = new SkinFactory(
|
|
|
|
|
new ObjectFactory( $this->createMock( ContainerInterface::class ) ), []
|
|
|
|
|
);
|
2019-06-03 00:55:00 +00:00
|
|
|
$skinFactory->register(
|
2017-03-20 19:34:21 +00:00
|
|
|
'fakemonobook',
|
|
|
|
|
'FakeMonoBook',
|
2020-02-06 09:44:05 +00:00
|
|
|
[]
|
2017-03-20 19:34:21 +00:00
|
|
|
);
|
2019-06-03 00:55:00 +00:00
|
|
|
$this->setService( 'SkinFactory', $skinFactory );
|
|
|
|
|
|
2019-06-03 00:58:58 +00:00
|
|
|
$reset = ExtensionRegistry::getInstance()->setAttributeForTest(
|
|
|
|
|
'SkinOOUIThemes', [ 'fakemonobook' => 'Apex' ]
|
|
|
|
|
);
|
2017-03-20 19:34:21 +00:00
|
|
|
|
|
|
|
|
$styles = $module->getStyles( $this->getResourceLoaderContext( [ 'skin' => 'fakemonobook' ] ) );
|
|
|
|
|
$this->assertRegExp(
|
2017-06-06 13:04:09 +00:00
|
|
|
'/stu-apex/',
|
2017-03-20 19:34:21 +00:00
|
|
|
$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(
|
2017-06-06 13:04:09 +00:00
|
|
|
'/stu-wikimediaui/',
|
2017-03-20 19:34:21 +00:00
|
|
|
$styles['all'],
|
|
|
|
|
'Generated styles use the default image (embed)'
|
|
|
|
|
);
|
|
|
|
|
$this->assertRegExp(
|
2019-04-15 19:21:00 +00:00
|
|
|
'/fallback/',
|
2017-03-20 19:34:21 +00:00
|
|
|
$styles['all'],
|
2019-04-15 19:21:00 +00:00
|
|
|
'Generated styles use the default skin (link)'
|
2017-03-20 19:34:21 +00:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|