maintenance: Enable gzip in router.php for static files
[lhc/web/wiklou.git] / tests / phpunit / includes / resourceloader / ResourceLoaderFileModuleTest.php
index 1585cbc..a9e7fcf 100644 (file)
@@ -1,7 +1,6 @@
 <?php
 
 /**
- * @group Database
  * @group ResourceLoader
  */
 class ResourceLoaderFileModuleTest extends ResourceLoaderTestCase {
@@ -19,11 +18,14 @@ class ResourceLoaderFileModuleTest extends ResourceLoaderTestCase {
                        }
                );
                $this->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' ],
                ] );