X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2Fresourceloader%2FResourceLoaderImageModuleTest.php;h=dad9f1ed4fe64e8cb814c7d9db397b5008463b63;hb=7af7bbe7476996bf60d8d8e48a84687ccd7505df;hp=e5b338ed979e117a047fee2b742a26b42f15d507;hpb=236488d398046838059f758b0915341648b64c7b;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/phpunit/includes/resourceloader/ResourceLoaderImageModuleTest.php b/tests/phpunit/includes/resourceloader/ResourceLoaderImageModuleTest.php index e5b338ed97..dad9f1ed4f 100644 --- a/tests/phpunit/includes/resourceloader/ResourceLoaderImageModuleTest.php +++ b/tests/phpunit/includes/resourceloader/ResourceLoaderImageModuleTest.php @@ -59,7 +59,7 @@ class ResourceLoaderImageModuleTest extends ResourceLoaderTestCase { return [ [ [ - 'class' => 'ResourceLoaderImageModule', + 'class' => ResourceLoaderImageModule::class, 'prefix' => 'oo-ui-icon', 'variants' => self::$commonImageVariants, 'images' => self::$commonImageData, @@ -100,7 +100,7 @@ class ResourceLoaderImageModuleTest extends ResourceLoaderTestCase { ], [ [ - 'class' => 'ResourceLoaderImageModule', + 'class' => ResourceLoaderImageModule::class, 'selectorWithoutVariant' => '.mw-ui-icon-{name}:after, .mw-ui-icon-{name}:before', 'selectorWithVariant' => '.mw-ui-icon-{name}-{variant}:after, .mw-ui-icon-{name}-{variant}:before', @@ -144,6 +144,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 @@ -239,7 +288,7 @@ TEXT } private function getImageMock( ResourceLoaderContext $context, $dataUriReturnValue ) { - $image = $this->getMockBuilder( 'ResourceLoaderImage' ) + $image = $this->getMockBuilder( ResourceLoaderImage::class ) ->disableOriginalConstructor() ->getMock(); $image->method( 'getDataUri' )