diff options
author | Bartosz Dziewoński <matma.rex@gmail.com> | 2017-03-17 03:14:05 +0100 |
---|---|---|
committer | Bartosz Dziewoński <matma.rex@gmail.com> | 2019-07-10 22:08:14 +0200 |
commit | 77f4bab8b749ed43438cc77dd6b2330ef0f99b8a (patch) | |
tree | 465ede91496e1933c04e69a7291d8e4d01752321 /tests/phpunit/includes/resourceloader/ResourceLoaderImageModuleTest.php | |
parent | d72f24589b3eece35b334d080e6e609b048fc22f (diff) | |
download | mediawikicore-77f4bab8b749ed43438cc77dd6b2330ef0f99b8a.tar.gz mediawikicore-77f4bab8b749ed43438cc77dd6b2330ef0f99b8a.zip |
Allow skins/extensions to define custom OOUI themes
This change follows I39cc2a735d9625c87bf4ede6f5fb0ec441d47dcc.
docs/extension.schema.v1.json
docs/extension.schema.v2.json
includes/registration/ExtensionProcessor.php
* The new extension attribute 'OOUIThemePaths' can be used to define
custom OOUI themes. See I9187a63e509b601b8558ea82850fa828e5c8cc0a
for an example usage.
includes/resourceloader/ResourceLoaderOOUIModule.php
* Add support for 'OOUIThemePaths'.
* Defining 'images' is now optional. I figure custom themes are
unlikely to have or need them.
* Use ResourceLoaderFilePath objects to allow skin-/extension-defined
OOUI module files to use skin/extension's base paths.
This was previously used to support $wgResourceModuleSkinStyles,
but only for 'skinStyles' - now ResourceLoaderFileModule needs
to also handle it for 'skinScripts', and ResourceLoaderImageModule
for 'images').
includes/resourceloader/ResourceLoaderFilePath.php
* Add getters for local/remote base paths, for when we need to
construct a new ResourceLoaderFilePath based on existing one.
includes/resourceloader/ResourceLoaderFileModule.php
includes/resourceloader/ResourceLoaderImageModule.php
includes/resourceloader/ResourceLoaderOOUIImageModule.php
* Add or improve handling of ResourceLoaderFilePaths:
* Replace `(array)` casts with explicit array wrapping, to avoid
casting objects into associative arrays.
* Use getLocalPath() instead of string concatenation.
tests/phpunit/includes/resourceloader/ResourceLoaderFileModuleTest.php
tests/phpunit/includes/resourceloader/ResourceLoaderImageModuleTest.php
* Some basic checks for the above.
Bug: T100896
Change-Id: I74362f0fc215b26f1f104ce7bdbbac1e106736ad
Diffstat (limited to 'tests/phpunit/includes/resourceloader/ResourceLoaderImageModuleTest.php')
-rw-r--r-- | tests/phpunit/includes/resourceloader/ResourceLoaderImageModuleTest.php | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/tests/phpunit/includes/resourceloader/ResourceLoaderImageModuleTest.php b/tests/phpunit/includes/resourceloader/ResourceLoaderImageModuleTest.php index 3f5704d6f4d1..dad9f1ed4fe6 100644 --- a/tests/phpunit/includes/resourceloader/ResourceLoaderImageModuleTest.php +++ b/tests/phpunit/includes/resourceloader/ResourceLoaderImageModuleTest.php @@ -145,6 +145,55 @@ class ResourceLoaderImageModuleTest extends ResourceLoaderTestCase { } /** + * Test reading files from elsewhere than localBasePath using ResourceLoaderFilePath. + * + * This mimics modules modified by skins using 'ResourceModuleSkinStyles' and 'OOUIThemePaths' + * skin attributes. + * + * @covers ResourceLoaderFilePath::getLocalBasePath + * @covers ResourceLoaderFilePath::getRemoteBasePath + */ + public function testResourceLoaderFilePath() { + $basePath = __DIR__ . '/../../data/blahblah'; + $filePath = __DIR__ . '/../../data/rlfilepath'; + $testModule = new ResourceLoaderImageModule( [ + 'localBasePath' => $basePath, + 'remoteBasePath' => 'blahblah', + 'prefix' => 'foo', + 'images' => [ + 'eye' => new ResourceLoaderFilePath( 'eye.svg', $filePath, 'rlfilepath' ), + 'flag' => [ + 'file' => [ + 'ltr' => new ResourceLoaderFilePath( 'flag-ltr.svg', $filePath, 'rlfilepath' ), + 'rtl' => new ResourceLoaderFilePath( 'flag-rtl.svg', $filePath, 'rlfilepath' ), + ], + ], + ], + ] ); + $expectedModule = new ResourceLoaderImageModule( [ + 'localBasePath' => $filePath, + 'remoteBasePath' => 'rlfilepath', + 'prefix' => 'foo', + 'images' => [ + 'eye' => 'eye.svg', + 'flag' => [ + 'file' => [ + 'ltr' => 'flag-ltr.svg', + 'rtl' => 'flag-rtl.svg', + ], + ], + ], + ] ); + + $context = $this->getResourceLoaderContext(); + $this->assertEquals( + $expectedModule->getModuleContent( $context ), + $testModule->getModuleContent( $context ), + "Using ResourceLoaderFilePath works correctly" + ); + } + + /** * @dataProvider providerGetModules * @covers ResourceLoaderImageModule::getStyles */ |