public function testLoadingMultipleScriptsWithSameDependancies() { ResourceLoader::clearResources(); ResourceLoader::addScriptCode("doThis();", ["/a.js", "/b.js"]); ResourceLoader::addScriptCode("doThat();", ["/a.js", "/b.js"]); $scripts = ResourceLoader::getResourceInjectionHtml(); $this->assertEquals("<script src=\"/client/resource-manager.js\" type=\"text/javascript\"></script>\n<script type=\"text/javascript\">\nwindow.resourceManager.loadResources( [ \"/a.js\", \"/b.js\" ], function()\n{\n\tdoThis();\n\tdoThat();\n} );\n</script>", $scripts); }
public function testLoadingMultipleScriptsWithSameDependancies() { ResourceLoader::clearResources(); ResourceLoader::addScriptCode("doThis();", ["/a.js", "/b.js"]); ResourceLoader::addScriptCode("doThat();", ["/a.js", "/b.js"]); $scripts = ResourceLoader::getResourceInjectionHtml(); $fileName = ""; $pathToFile = "resources/resource-manager.js"; if (file_exists($pathToFile)) { $fileName = filemtime($pathToFile); } $this->assertEquals("<script src=\"/deployed/resources/resource-manager.js?" . $fileName . ".js\" type=\"text/javascript\"></script>\n<script type=\"text/javascript\" src=\"/a.js\"></script>\n<script type=\"text/javascript\" src=\"/b.js\"></script><script type=\"text/javascript\">\n//<![CDATA[\nwindow.resourceManager.runWhenDocumentReady( function()\n{\n\tdoThis();\n\tdoThat();\n} );\n\n//]]>\n</script>", $scripts); }