The old way of providing a callable to SkinFactory::register is still supported. Those callables expected the skin name as their first argument. Coincidentally, so does the constructor of Skin. Some skins might not define any constructor parameters at all, which is acceptable to PHP, as it will just discard the argument. The registration using $wgValidSkinNames has not been changed, and skins that want to define services to be injected will still need to manually register their skin to the skin factory. CodeSearch did not indicate any extensions or skins manually constructing a SkinFactory in tests, but for posterity, the old way of creating a SkinFactory for testing can be replaced with new SkinFactory( new ObjectFactory( $this->createMock( ContainerInterface::class ) ) ); Note that the constructor for SkinFactory for internal use only, in accordance with the Stable interface policy. You should use MediaWikiServices::getInstance()->getSkinFactory instead. Bug: T244466 Change-Id: I8ba9d869bddd9b6124e47697b789d752c0620b02
61 lines
1.5 KiB
PHP
61 lines
1.5 KiB
PHP
<?php
|
|
|
|
use Psr\Container\ContainerInterface;
|
|
use Wikimedia\ObjectFactory;
|
|
|
|
/**
|
|
* @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 = new SkinFactory( new ObjectFactory(
|
|
$this->createMock( ContainerInterface::class )
|
|
) );
|
|
$skinFactory->register(
|
|
'fakemonobook',
|
|
'FakeMonoBook',
|
|
[]
|
|
);
|
|
$this->setService( 'SkinFactory', $skinFactory );
|
|
|
|
$reset = ExtensionRegistry::getInstance()->setAttributeForTest(
|
|
'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)'
|
|
);
|
|
}
|
|
|
|
}
|