diff options
author | Timo Tijhof <krinklemail@gmail.com> | 2021-08-11 19:29:09 +0100 |
---|---|---|
committer | Catrope <roan@wikimedia.org> | 2021-08-19 01:14:00 +0000 |
commit | 76245d70ffd5dde20f2a823d8b4fca508b69f393 (patch) | |
tree | bca7d20fa5556ef1e0fd7efe07d374d3822735e2 /tests/phpunit/includes/resourceloader/ResourceLoaderFileModuleTest.php | |
parent | a14ae963de5c3979da181a079611e93d98cad3c6 (diff) | |
download | mediawikicore-76245d70ffd5dde20f2a823d8b4fca508b69f393.tar.gz mediawikicore-76245d70ffd5dde20f2a823d8b4fca508b69f393.zip |
resourceloader: Add integration test for ResourceModuleSkinStyles
This was covered in small ways already, but we did not have coverage
of the registration logic where the skin attribute is injected into
the module info, and this then correctly getting read and composed
into a single stylesheet.
This is prep for an optimisation in a subsequent commit.
Change-Id: Ia6fff44a345bb4f5811956638cada8b3e6b6ea71
Diffstat (limited to 'tests/phpunit/includes/resourceloader/ResourceLoaderFileModuleTest.php')
-rw-r--r-- | tests/phpunit/includes/resourceloader/ResourceLoaderFileModuleTest.php | 39 |
1 files changed, 37 insertions, 2 deletions
diff --git a/tests/phpunit/includes/resourceloader/ResourceLoaderFileModuleTest.php b/tests/phpunit/includes/resourceloader/ResourceLoaderFileModuleTest.php index a90ee86e3a5f..bc01ce49053f 100644 --- a/tests/phpunit/includes/resourceloader/ResourceLoaderFileModuleTest.php +++ b/tests/phpunit/includes/resourceloader/ResourceLoaderFileModuleTest.php @@ -222,6 +222,40 @@ class ResourceLoaderFileModuleTest extends ResourceLoaderTestCase { } /** + * Confirm that 'ResourceModuleSkinStyles' skin attributes get injected + * into the module, and have their file contents read correctly from their + * own (out-of-module) directories. + * + * @covers ResourceLoader + * @covers ResourceLoaderFileModule + */ + public function testInjectSkinStyles() { + $moduleDir = __DIR__ . '/../../data/resourceloader'; + $skinDir = __DIR__ . '/../../data/resourceloader/myskin'; + $rl = new ResourceLoader( new HashConfig( self::getSettings() ) ); + $rl->setModuleSkinStyles( [ + 'fakeskin' => [ + 'localBasePath' => $skinDir, + 'testing' => [ + 'override.css', + ], + ], + ] ); + $rl->register( 'testing', [ + 'localBasePath' => $moduleDir, + 'styles' => [ 'simple.css' ], + ] ); + $ctx = $this->getResourceLoaderContext( [ 'skin' => 'fakeskin' ], $rl ); + + $module = $rl->getModule( 'testing' ); + $this->assertInstanceOf( ResourceLoaderFileModule::class, $module ); + $this->assertEquals( + [ 'all' => ".example { color: blue; }\n\n.override { line-height: 2; }\n" ], + $module->getStyles( $ctx ) + ); + } + + /** * What happens when you mix @embed and @noflip? * This really is an integration test, but oh well. * @@ -305,8 +339,9 @@ class ResourceLoaderFileModuleTest extends ResourceLoaderTestCase { /** * Test reading files from elsewhere than localBasePath using ResourceLoaderFilePath. * - * This mimics modules modified by skins using 'ResourceModuleSkinStyles' and 'OOUIThemePaths' - * skin attributes. + * The use of ResourceLoaderFilePath objects resembles the way that ResourceLoader::getModule() + * injects additional files when 'ResourceModuleSkinStyles' or 'OOUIThemePaths' skin attributes + * apply to a given module. * * @covers ResourceLoaderFilePath::getLocalBasePath * @covers ResourceLoaderFilePath::getRemoteBasePath |