Download plugins/CoreHome/tests/Unit/CoreHomeTest.php from Leon4gr45/matomo: direct link, hf CLI and curl.
- Browser
- Download file 2.9 kB
-
https://huggingface.co/spaces/Leon4gr45/matomo/resolve/main/plugins/CoreHome/tests/Unit/CoreHomeTest.php
- Command line
-
hf download hf://spaces/Leon4gr45/matomo/plugins/CoreHome/tests/Unit/CoreHomeTest.php
-
curl -L -o CoreHomeTest.php https://huggingface.co/spaces/Leon4gr45/matomo/resolve/main/plugins/CoreHome/tests/Unit/CoreHomeTest.php
2.9 kB
| /** | |
| * Matomo - free/libre analytics platform | |
| * | |
| * @link https://matomo.org | |
| * @license https://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later | |
| */ | |
| namespace Piwik\Plugins\CoreHome\tests\Unit; | |
| use Piwik\Plugin\ThemeStyles; | |
| use Piwik\Plugins\CoreHome\CoreHome; | |
| /** | |
| * @group CoreHome | |
| * @group CoreHomeTest | |
| * @group Plugins | |
| */ | |
| class CoreHomeTest extends \PHPUnit\Framework\TestCase | |
| { | |
| /** | |
| * @var CoreHome | |
| */ | |
| private $coreHome; | |
| public function setUp(): void | |
| { | |
| parent::setUp(); | |
| $this->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; | |
| } | |
| } | |