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-02-08 03:09:57 +0300
committermattab <matthieu.aubry@gmail.com>2016-02-08 03:09:57 +0300
commit437fd9744543b14130d58c3ea5b7b10495e8e7a7 (patch)
tree88f38e775480902aef57300f4a874c96d1f78cb0 /tests
parent35f85973d7e9c14f12145d9fcdf7b23f818aa6a3 (diff)
New release check list integration test to pro-actively detect 'abnormal whitespaces' issue
Refs #9729 #9715 #9712
Diffstat (limited to 'tests')
-rw-r--r--tests/PHPUnit/Integration/ReleaseCheckListTest.php65
1 files changed, 64 insertions, 1 deletions
diff --git a/tests/PHPUnit/Integration/ReleaseCheckListTest.php b/tests/PHPUnit/Integration/ReleaseCheckListTest.php
index 58970199f0..6d8553802a 100644
--- a/tests/PHPUnit/Integration/ReleaseCheckListTest.php
+++ b/tests/PHPUnit/Integration/ReleaseCheckListTest.php
@@ -184,6 +184,30 @@ class ReleaseCheckListTest extends \PHPUnit_Framework_TestCase
}
}
+ public function test_jsfilesDoNotContainFakeSpaces()
+ {
+ $js = Filesystem::globr(PIWIK_INCLUDE_PATH, '*.js');
+ $this->checkFilesDoNotHaveWeirdSpaces($js);
+ }
+
+ public function test_phpfilesDoNotContainFakeSpaces()
+ {
+ $js = Filesystem::globr(PIWIK_INCLUDE_PATH, '*.php');
+ $this->checkFilesDoNotHaveWeirdSpaces($js);
+ }
+
+ public function test_twigfilesDoNotContainFakeSpaces()
+ {
+ $js = Filesystem::globr(PIWIK_INCLUDE_PATH, '*.twig');
+ $this->checkFilesDoNotHaveWeirdSpaces($js);
+ }
+
+ public function test_htmlfilesDoNotContainFakeSpaces()
+ {
+ $js = Filesystem::globr(PIWIK_INCLUDE_PATH, '*.html');
+ $this->checkFilesDoNotHaveWeirdSpaces($js);
+ }
+
public function test_directoriesShouldBeChmod755()
{
$pluginsPath = realpath(PIWIK_INCLUDE_PATH . '/plugins/');
@@ -422,7 +446,7 @@ class ReleaseCheckListTest extends \PHPUnit_Framework_TestCase
}
// in build-package.sh we have: `find ./ -iname 'tests' -type d -prune -exec rm -rf {} \;`
- if(stripos($file, "/tests/") !== false) {
+ if($this->isFileBelongToTests($file)) {
return false;
}
if(strpos($file, PIWIK_INCLUDE_PATH . "/tmp/") !== false) {
@@ -586,4 +610,43 @@ class ReleaseCheckListTest extends \PHPUnit_Framework_TestCase
}
return $filesizes;
}
+
+ /**
+ * @param $files
+ * @throws Exception
+ */
+ protected function checkFilesDoNotHaveWeirdSpaces($files)
+ {
+ $weirdSpace = ' ';
+ $this->assertEquals('c2a0', bin2hex($weirdSpace), "Checking that this test file was not tampered with");
+ $this->assertEquals('20', bin2hex(' '), "Checking that this test file was not tampered with");
+
+ $errors = array();
+ foreach ($files as $file) {
+
+ if($this->isFileBelongToTests($file)) {
+ continue;
+ }
+
+ $content = file_get_contents($file);
+ $posWeirdSpace = strpos($content, $weirdSpace);
+ if ($posWeirdSpace !== false) {
+ $around = substr($content, $posWeirdSpace - 20, 40);
+ $around = trim($around);
+ $errors[] = "File $file contains an unusual space character, please remove it from here: ...$around...";
+ }
+ }
+ if (!empty($errors)) {
+ throw new Exception(implode(",\n\n ", $errors));
+ }
+ }
+
+ /**
+ * @param $file
+ * @return bool
+ */
+ private function isFileBelongToTests($file)
+ {
+ return stripos($file, "/tests/") !== false;
+ }
}