coreHome = new CoreHome(); } /** * @dataProvider getJavaScriptsContainingNoSourceMapDefinition */ public function testFilterMergedJavaScriptsShouldNotChangeAnythingIfJsDoesNotContainAnySourceMap($content) { $expectedContent = $content; $this->coreHome->filterMergedJavaScripts($content); $this->assertSame($expectedContent, $content); } /** * @dataProvider getJavaScriptsContainingSourceMapDefinition */ public function testFilterMergedJavaScriptsShouldRemoveSourceMapIfDefinedInJs($content, $expectedContent) { $this->coreHome->filterMergedJavaScripts($content); $this->assertSame($expectedContent, $content); } public function testFilterMergedJavaScriptsShouldRemoveMultipleSourceMapDefinitionsInOneContent() { $content = 'var x = 5; //# sourceMappingURL=whatever.js.map .map init(); x = 6; //# sourceMappingURL=js.map foo("bar"); '; $expected = 'var x = 5; //# .map init(); x = 6; //# foo("bar"); '; $this->coreHome->filterMergedJavaScripts($content); $this->assertSame($expected, $content); } public function testAddStylesheetsPrependsModeAgnosticThemeStyles() { $originalContent = '.existing { color: red; }'; $content = $originalContent; $this->coreHome->addStylesheets($content); $this->assertSame(ThemeStyles::get()->toLessCode() . "\n" . $originalContent, $content); } public function getJavaScriptsContainingNoSourceMapDefinition() { $js = array(); $js[] = array(''); $js[] = array('var x = 5; init();'); $js[] = array('//# sourceMappingURL'); $js[] = array('//# sourceMappingURL='); $js[] = array('//# sourceMappingURL.map'); $js[] = array('sourceMappingURL= cc.map'); return $js; } public function getJavaScriptsContainingSourceMapDefinition() { $js = array(); $js[] = array('//# sourceMappingURL=55.map', '//# '); $js[] = array('//# sourceMappingURL=.map', '//# '); $js[] = array('sourceMappingURL=whatever.js.map', ''); $js[] = array('sourceMappingURL=whatever.js.map .map', ' .map'); $js[] = array('var x = 5; //# sourceMappingURL=whatever.js.map .map', 'var x = 5; //# .map'); return $js; } }