diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/phpunit/data/rlfilepath/eye.svg | 1 | ||||
-rw-r--r-- | tests/phpunit/data/rlfilepath/flag-ltr.svg | 1 | ||||
-rw-r--r-- | tests/phpunit/data/rlfilepath/flag-rtl.svg | 1 | ||||
-rw-r--r-- | tests/phpunit/data/rlfilepath/script.js | 1 | ||||
-rw-r--r-- | tests/phpunit/data/rlfilepath/skinStyle.css | 3 | ||||
-rw-r--r-- | tests/phpunit/data/rlfilepath/style.css | 3 | ||||
-rw-r--r-- | tests/phpunit/data/rlfilepath/template.html | 1 | ||||
-rw-r--r-- | tests/phpunit/includes/resourceloader/ResourceLoaderFileModuleTest.php | 41 | ||||
-rw-r--r-- | tests/phpunit/includes/resourceloader/ResourceLoaderImageModuleTest.php | 49 |
9 files changed, 101 insertions, 0 deletions
diff --git a/tests/phpunit/data/rlfilepath/eye.svg b/tests/phpunit/data/rlfilepath/eye.svg new file mode 100644 index 000000000000..be0c4e69d0e8 --- /dev/null +++ b/tests/phpunit/data/rlfilepath/eye.svg @@ -0,0 +1 @@ +<?xml version="1.0" encoding="UTF-8"?><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20"><title>eye</title><path d="M10 7.5a2.5 2.5 0 1 0 2.5 2.5A2.5 2.5 0 0 0 10 7.5zm0 7a4.5 4.5 0 1 1 4.5-4.5 4.5 4.5 0 0 1-4.5 4.5zM10 3C3 3 0 10 0 10s3 7 10 7 10-7 10-7-3-7-10-7z"/></svg>
\ No newline at end of file diff --git a/tests/phpunit/data/rlfilepath/flag-ltr.svg b/tests/phpunit/data/rlfilepath/flag-ltr.svg new file mode 100644 index 000000000000..d19bed5371e3 --- /dev/null +++ b/tests/phpunit/data/rlfilepath/flag-ltr.svg @@ -0,0 +1 @@ +<?xml version="1.0" encoding="UTF-8"?><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20"><title>flag</title><path d="M17 6L3 1v18h2v-6.87L17 6z"/></svg>
\ No newline at end of file diff --git a/tests/phpunit/data/rlfilepath/flag-rtl.svg b/tests/phpunit/data/rlfilepath/flag-rtl.svg new file mode 100644 index 000000000000..a58bb9242012 --- /dev/null +++ b/tests/phpunit/data/rlfilepath/flag-rtl.svg @@ -0,0 +1 @@ +<?xml version="1.0" encoding="UTF-8"?><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20"><title>flag</title><path d="M3 6l14-5v18h-2v-6.87L3 6z"/></svg>
\ No newline at end of file diff --git a/tests/phpunit/data/rlfilepath/script.js b/tests/phpunit/data/rlfilepath/script.js new file mode 100644 index 000000000000..f5d7aa52abdb --- /dev/null +++ b/tests/phpunit/data/rlfilepath/script.js @@ -0,0 +1 @@ +mw.test(); diff --git a/tests/phpunit/data/rlfilepath/skinStyle.css b/tests/phpunit/data/rlfilepath/skinStyle.css new file mode 100644 index 000000000000..575d19f7b0e2 --- /dev/null +++ b/tests/phpunit/data/rlfilepath/skinStyle.css @@ -0,0 +1,3 @@ +body { + color: red; +} diff --git a/tests/phpunit/data/rlfilepath/style.css b/tests/phpunit/data/rlfilepath/style.css new file mode 100644 index 000000000000..e87cc6abcd07 --- /dev/null +++ b/tests/phpunit/data/rlfilepath/style.css @@ -0,0 +1,3 @@ +body { + color: black; +} diff --git a/tests/phpunit/data/rlfilepath/template.html b/tests/phpunit/data/rlfilepath/template.html new file mode 100644 index 000000000000..7c89b545c5ac --- /dev/null +++ b/tests/phpunit/data/rlfilepath/template.html @@ -0,0 +1 @@ +<div></div> diff --git a/tests/phpunit/includes/resourceloader/ResourceLoaderFileModuleTest.php b/tests/phpunit/includes/resourceloader/ResourceLoaderFileModuleTest.php index 5be0f9b79fd3..a9e7fcfd3214 100644 --- a/tests/phpunit/includes/resourceloader/ResourceLoaderFileModuleTest.php +++ b/tests/phpunit/includes/resourceloader/ResourceLoaderFileModuleTest.php @@ -265,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(); 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 */ |