aboutsummaryrefslogtreecommitdiffstats
path: root/tests/phpunit/includes/resourceloader/ResourceLoaderModuleTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/phpunit/includes/resourceloader/ResourceLoaderModuleTest.php')
-rw-r--r--tests/phpunit/includes/resourceloader/ResourceLoaderModuleTest.php46
1 files changed, 46 insertions, 0 deletions
diff --git a/tests/phpunit/includes/resourceloader/ResourceLoaderModuleTest.php b/tests/phpunit/includes/resourceloader/ResourceLoaderModuleTest.php
index 17861d8929be..6057b9710baf 100644
--- a/tests/phpunit/includes/resourceloader/ResourceLoaderModuleTest.php
+++ b/tests/phpunit/includes/resourceloader/ResourceLoaderModuleTest.php
@@ -94,6 +94,52 @@ class ResourceLoaderModuleTest extends ResourceLoaderTestCase {
);
}
+ public static function provideBuildContentScripts() {
+ return [
+ [
+ "mw.foo()",
+ "mw.foo();\n",
+ ],
+ [
+ "mw.foo();",
+ "mw.foo();",
+ ],
+ [
+ "mw.foo();\n",
+ "mw.foo();\n",
+ ],
+ [
+ "mw.foo()\n",
+ "mw.foo()\n;\n",
+ ],
+ [
+ "mw.foo()\n// mw.bar();",
+ "mw.foo()\n// mw.bar();",
+ ],
+ [
+ "mw.foo()// mw.bar();",
+ "mw.foo()// mw.bar();",
+ ],
+ ];
+ }
+
+ /**
+ * @dataProvider provideBuildContentScripts
+ * @covers ResourceLoaderModule::buildContent
+ */
+ public function testBuildContentScripts( $raw, $build, $message = null ) {
+ $context = $this->getResourceLoaderContext();
+ $module = new ResourceLoaderTestModule( [
+ 'script' => $raw
+ ] );
+ $this->assertEquals( $raw, $module->getScript( $context ), 'Raw script' );
+ $this->assertEquals(
+ [ 'scripts' => $build ],
+ $module->getModuleContent( $context ),
+ $message
+ );
+ }
+
/**
* @covers ResourceLoaderModule::getRelativePaths
* @covers ResourceLoaderModule::expandRelativePaths