X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2Fresourceloader%2FResourceLoaderFileModuleTest.php;h=a9e7fcfd3214c12ccd7b150a8607ba22de27846a;hb=424eb75d77f7a7513cd59083198f5b3a407a8715;hp=1585cbcef002681ff282c1d78ed331427b038a69;hpb=a50fb366834ced0ac78cbb836167d5589b9ac6a3;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/phpunit/includes/resourceloader/ResourceLoaderFileModuleTest.php b/tests/phpunit/includes/resourceloader/ResourceLoaderFileModuleTest.php index 1585cbcef0..a9e7fcfd32 100644 --- a/tests/phpunit/includes/resourceloader/ResourceLoaderFileModuleTest.php +++ b/tests/phpunit/includes/resourceloader/ResourceLoaderFileModuleTest.php @@ -1,7 +1,6 @@ setService( 'SkinFactory', $skinFactory ); + + // This test is not expected to query any database + MediaWiki\MediaWikiServices::disableStorageBackend(); } private static function getModules() { $base = [ - 'localBasePath' => realpath( __DIR__ ), + 'localBasePath' => __DIR__, ]; return [ @@ -229,12 +231,12 @@ class ResourceLoaderFileModuleTest extends ResourceLoaderTestCase { */ public function testMixedCssAnnotations() { $basePath = __DIR__ . '/../../data/css'; - $testModule = new ResourceLoaderFileModule( [ + $testModule = new ResourceLoaderFileTestModule( [ 'localBasePath' => $basePath, 'styles' => [ 'test.css' ], ] ); $testModule->setName( 'testing' ); - $expectedModule = new ResourceLoaderFileModule( [ + $expectedModule = new ResourceLoaderFileTestModule( [ 'localBasePath' => $basePath, 'styles' => [ 'expected.css' ], ] ); @@ -263,6 +265,47 @@ 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. + * + * @covers ResourceLoaderFilePath::getLocalBasePath + * @covers ResourceLoaderFilePath::getRemoteBasePath + */ + public function testResourceLoaderFilePath() { + $basePath = __DIR__ . '/../../data/blahblah'; + $filePath = __DIR__ . '/../../data/rlfilepath'; + $testModule = new ResourceLoaderFileModule( [ + 'localBasePath' => $basePath, + 'remoteBasePath' => 'blahblah', + 'styles' => new ResourceLoaderFilePath( 'style.css', $filePath, 'rlfilepath' ), + 'skinStyles' => [ + 'vector' => new ResourceLoaderFilePath( 'skinStyle.css', $filePath, 'rlfilepath' ), + ], + 'scripts' => new ResourceLoaderFilePath( 'script.js', $filePath, 'rlfilepath' ), + 'templates' => new ResourceLoaderFilePath( 'template.html', $filePath, 'rlfilepath' ), + ] ); + $expectedModule = new ResourceLoaderFileModule( [ + 'localBasePath' => $filePath, + 'remoteBasePath' => 'rlfilepath', + 'styles' => 'style.css', + 'skinStyles' => [ + 'vector' => 'skinStyle.css', + ], + 'scripts' => 'script.js', + 'templates' => 'template.html', + ] ); + + $context = $this->getResourceLoaderContext(); + $this->assertEquals( + $expectedModule->getModuleContent( $context ), + $testModule->getModuleContent( $context ), + "Using ResourceLoaderFilePath works correctly" + ); + } + public static function providerGetTemplates() { $modules = self::getModules(); @@ -319,7 +362,7 @@ class ResourceLoaderFileModuleTest extends ResourceLoaderTestCase { */ public function testBomConcatenation() { $basePath = __DIR__ . '/../../data/css'; - $testModule = new ResourceLoaderFileModule( [ + $testModule = new ResourceLoaderFileTestModule( [ 'localBasePath' => $basePath, 'styles' => [ 'bom.css' ], ] );