And also assertNotRegExp -> assertDoesNotMatchRegularExpression. The methods were renamed in PHPUnit 9. Done automatically with: grep -rl assertRegExp tests/ | xargs sed -r -i "s/>assertRegExp\(/>assertMatchesRegularExpression\(/" grep -rl assertNotRegExp tests/ | xargs sed -r -i "s/>assertNotRegExp\(/>assertDoesNotMatchRegularExpression\(/" Split out from Ifdba0f9e98eb6bce4590b7eb73170c51a697d7c6 so that it remains smaller and easier to review. Also make a test use MediaWikiUnitTestCase (it's already in the unit/ dir) so that it can access the forward-compat method. Bug: T243600 Change-Id: Ifa279d5f201d7abeebece292141ebface8278046
65 lines
1.7 KiB
PHP
65 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace MediaWiki\Tests\ResourceLoader;
|
|
|
|
use ExtensionRegistry;
|
|
use MediaWiki\ResourceLoader\OOUIImageModule;
|
|
use Psr\Container\ContainerInterface;
|
|
use ResourceLoaderTestCase;
|
|
use SkinFactory;
|
|
use Wikimedia\ObjectFactory\ObjectFactory;
|
|
|
|
/**
|
|
* @group ResourceLoader
|
|
* @covers \MediaWiki\ResourceLoader\OOUIImageModule
|
|
*/
|
|
class OOUIImageModuleTest extends ResourceLoaderTestCase {
|
|
|
|
public function testNonDefaultSkin() {
|
|
$module = new OOUIImageModule( [
|
|
'class' => OOUIImageModule::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->assertMatchesRegularExpression(
|
|
'/stu-apex/',
|
|
$styles['all'],
|
|
'Generated styles use the non-default image (embed)'
|
|
);
|
|
$this->assertMatchesRegularExpression(
|
|
'/fakemonobook/',
|
|
$styles['all'],
|
|
'Generated styles use the non-default image (link)'
|
|
);
|
|
|
|
$styles = $module->getStyles( $this->getResourceLoaderContext() );
|
|
$this->assertMatchesRegularExpression(
|
|
'/stu-wikimediaui/',
|
|
$styles['all'],
|
|
'Generated styles use the default image (embed)'
|
|
);
|
|
$this->assertMatchesRegularExpression(
|
|
'/fallback/',
|
|
$styles['all'],
|
|
'Generated styles use the default skin (link)'
|
|
);
|
|
}
|
|
|
|
}
|