Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authormattab <matthieu.aubry@gmail.com>2016-03-30 10:31:18 +0300
committermattab <matthieu.aubry@gmail.com>2016-03-31 06:00:38 +0300
commitc928ff499504e319bb1b43e5abf2ae84484169e5 (patch)
treed60ccd3a3afb5a5e2079343d54d959eb774d5f0c /tests
parent85e0c15448af5a9b59b8c3dfe171d2c5cc512ffa (diff)
New automated test to detect when piwik.js minified file is out of sync with original piwik.js
Diffstat (limited to 'tests')
-rw-r--r--tests/PHPUnit/Integration/JsProxyTest.php4
-rw-r--r--tests/PHPUnit/Integration/ReleaseCheckListTest.php15
2 files changed, 16 insertions, 3 deletions
diff --git a/tests/PHPUnit/Integration/JsProxyTest.php b/tests/PHPUnit/Integration/JsProxyTest.php
index e2a68cf4c3..0fbab1890f 100644
--- a/tests/PHPUnit/Integration/JsProxyTest.php
+++ b/tests/PHPUnit/Integration/JsProxyTest.php
@@ -31,7 +31,7 @@ class JsProxyTest extends \PHPUnit_Framework_TestCase
$this->assertEquals($piwik_js, $fullResponse, 'script content');
}
- public function testPiwikJsNoComment()
+ public function testPiwik_WhiteLabelledJs_HasNoComment()
{
$curlHandle = curl_init();
curl_setopt($curlHandle, CURLOPT_URL, $this->getStaticSrvUrl() . '/js/tracker.php');
@@ -44,7 +44,7 @@ class JsProxyTest extends \PHPUnit_Framework_TestCase
$piwikJs = file_get_contents(PIWIK_PATH_TEST_TO_ROOT . '/piwik.js');
$piwikNoCommentJs = substr($piwikJs, strpos($piwikJs, "*/\n") + 3);
- $this->assertEquals($piwikNoCommentJs, $fullResponse, 'script content (if comment shows, $byteStart value in /js/tracker.php)');
+ $this->assertEquals($piwikNoCommentJs, trim($fullResponse), 'script content (if comment shows, $byteStart value in /js/tracker.php)');
}
public function testPiwikPhp()
diff --git a/tests/PHPUnit/Integration/ReleaseCheckListTest.php b/tests/PHPUnit/Integration/ReleaseCheckListTest.php
index fcda0177be..6cb62cccdf 100644
--- a/tests/PHPUnit/Integration/ReleaseCheckListTest.php
+++ b/tests/PHPUnit/Integration/ReleaseCheckListTest.php
@@ -12,6 +12,7 @@ use Exception;
use Piwik\Config;
use Piwik\Container\StaticContainer;
use Piwik\Filesystem;
+use Piwik\Http;
use Piwik\Ini\IniReader;
use Piwik\Plugin\Manager;
use Piwik\Tests\Framework\TestCase\SystemTestCase;
@@ -201,7 +202,7 @@ class ReleaseCheckListTest extends \PHPUnit_Framework_TestCase
$js = Filesystem::globr(PIWIK_INCLUDE_PATH, '*.twig');
$this->checkFilesDoNotHaveWeirdSpaces($js);
}
-
+
public function test_htmlfilesDoNotContainFakeSpaces()
{
$js = Filesystem::globr(PIWIK_INCLUDE_PATH, '*.html');
@@ -329,6 +330,18 @@ class ReleaseCheckListTest extends \PHPUnit_Framework_TestCase
$this->assertTrue(preg_match($pattern, $contents) == 0);
}
+ public function test_piwikJs_minified_isUpToDate()
+ {
+ Http::fetchRemoteFile('https://github.com/downloads/yui/yuicompressor/yuicompressor-2.4.7.zip', PIWIK_DOCUMENT_ROOT .'/tmp/yuicompressor.zip');
+ shell_exec('unzip -n '. PIWIK_DOCUMENT_ROOT .'/tmp/yuicompressor.zip');
+ shell_exec("sed '/<DEBUG>/,/<\/DEBUG>/d' < ". PIWIK_DOCUMENT_ROOT ."/js/piwik.js | sed 's/eval/replacedEvilString/' | java -jar yuicompressor-2.4.7/build/yuicompressor-2.4.7.jar --type js --line-break 1000 | sed 's/replacedEvilString/eval/' | sed 's/^[/][*]/\/*!/' > " . PIWIK_DOCUMENT_ROOT ."/piwik-minified.js");
+ $piwikJsMinified = file_get_contents(PIWIK_DOCUMENT_ROOT ."/piwik-minified.js");
+
+ $piwikJsMinifiedInGit = file_get_contents(PIWIK_DOCUMENT_ROOT . '/piwik.js');
+
+ $this->assertEquals($piwikJsMinified, $piwikJsMinifiedInGit, 'piwik.js minified is out of date - please re-generate the piwik.js. See instructions in js/README');
+ }
+
public function testTmpDirectoryContainsGitKeep()
{
$this->assertFileExists(PIWIK_DOCUMENT_ROOT . '/tmp/.gitkeep');