From: Timo Tijhof Date: Sat, 19 May 2018 18:37:04 +0000 (+0200) Subject: resourceloader: Add test case for ResourceLoader::getLessCompiler X-Git-Tag: 1.34.0-rc.0~5365^2 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_aide%28?a=commitdiff_plain;h=f4d1039a2017499bd8773dd319ae88040ecbd1f2;p=lhc%2Fweb%2Fwiklou.git resourceloader: Add test case for ResourceLoader::getLessCompiler This was previously covered implicitly by an unrelated test. Change that test (dependency.less) to use ../ to access the file directly so that that test case is only about tracking dependencies and testing the parser. Then, add a second case that tests the use of import dirs. Bug: T140807 Change-Id: Ie85abffe313922c03b3e146422f36b1d6a79743d --- diff --git a/tests/phpunit/data/less/module/dependency.less b/tests/phpunit/data/less/module/dependency.less index c7725a2520..110e00bdbc 100644 --- a/tests/phpunit/data/less/module/dependency.less +++ b/tests/phpunit/data/less/module/dependency.less @@ -1,3 +1,3 @@ -@import "test.common.mixins"; +@import "../common/test.common.mixins"; @unitTestColor: green; diff --git a/tests/phpunit/data/less/module/use-import-dir.less b/tests/phpunit/data/less/module/use-import-dir.less new file mode 100644 index 0000000000..4710bc64d9 --- /dev/null +++ b/tests/phpunit/data/less/module/use-import-dir.less @@ -0,0 +1,6 @@ +@import "test.common.mixins"; + +/* @noflip */ +.unit-tests { + .test-mixin(green); +} diff --git a/tests/phpunit/includes/resourceloader/ResourceLoaderTest.php b/tests/phpunit/includes/resourceloader/ResourceLoaderTest.php index e811d874ff..95006aa923 100644 --- a/tests/phpunit/includes/resourceloader/ResourceLoaderTest.php +++ b/tests/phpunit/includes/resourceloader/ResourceLoaderTest.php @@ -8,9 +8,7 @@ class ResourceLoaderTest extends ResourceLoaderTestCase { parent::setUp(); $this->setMwGlobals( [ - 'wgResourceLoaderLESSImportPaths' => [ - dirname( dirname( __DIR__ ) ) . '/data/less/common', - ], + 'wgResourceLoaderLESSImportPaths' => [], 'wgResourceLoaderLESSVars' => [ 'foo' => '2px', 'Foo' => '#eeeeee', @@ -264,6 +262,20 @@ class ResourceLoaderTest extends ResourceLoaderTestCase { $this->assertStringEqualsFile( $basePath . '/styles.css', $styles['all'] ); } + /** + * @covers ResourceLoader::getLessCompiler + */ + public function testLessImportDirs() { + $rl = new EmptyResourceLoader(); + $lc = $rl->getLessCompiler(); + $basePath = dirname( dirname( __DIR__ ) ) . '/data/less'; + $lc->SetImportDirs( [ + "$basePath/common" => '', + ] ); + $css = $lc->parseFile( "$basePath/module/use-import-dir.less" )->getCss(); + $this->assertStringEqualsFile( "$basePath/module/styles.css", $css ); + } + public static function providePackedModules() { return [ [