diff options
Diffstat (limited to 'tests/PHPUnit/Core/ReleaseCheckListTest.php')
-rw-r--r-- | tests/PHPUnit/Core/ReleaseCheckListTest.php | 82 |
1 files changed, 36 insertions, 46 deletions
diff --git a/tests/PHPUnit/Core/ReleaseCheckListTest.php b/tests/PHPUnit/Core/ReleaseCheckListTest.php index d0d9a75a5d..a14ed292f7 100644 --- a/tests/PHPUnit/Core/ReleaseCheckListTest.php +++ b/tests/PHPUnit/Core/ReleaseCheckListTest.php @@ -40,11 +40,10 @@ class ReleaseCheckListTest extends PHPUnit_Framework_TestCase $section = key($key); $optionName = current($key); $value = null; - if(isset($this->globalConfig[$section][$optionName])) - { + if (isset($this->globalConfig[$section][$optionName])) { $value = $this->globalConfig[$section][$optionName]; } - $this->assertEquals($valueExpected, $value, "$section -> $optionName was '".var_export($value, true) ."', expected '".var_export($valueExpected,true)."'"); + $this->assertEquals($valueExpected, $value, "$section -> $optionName was '" . var_export($value, true) . "', expected '" . var_export($valueExpected, true) . "'"); } /** @@ -55,10 +54,9 @@ class ReleaseCheckListTest extends PHPUnit_Framework_TestCase { $patternFailIfFound = '{debug}'; $files = Piwik::globr(PIWIK_INCLUDE_PATH . '/plugins', '*.tpl'); - foreach($files as $file) - { + foreach ($files as $file) { $content = file_get_contents($file); - $this->assertFalse(strpos($content, $patternFailIfFound), 'found in '.$file); + $this->assertFalse(strpos($content, $patternFailIfFound), 'found in ' . $file); } } @@ -69,15 +67,13 @@ class ReleaseCheckListTest extends PHPUnit_Framework_TestCase public function testCheckThatGivenPluginsAreDisabledByDefault() { $pluginsShouldBeDisabled = array( - 'AnonymizeIP', - 'DBStats', - 'SecurityInfo', - 'VisitorGenerator', + 'AnonymizeIP', + 'DBStats', + 'SecurityInfo', + 'VisitorGenerator', ); - foreach($pluginsShouldBeDisabled as $pluginName) - { - if(in_array($pluginName, $this->globalConfig['Plugins']['Plugins'])) - { + foreach ($pluginsShouldBeDisabled as $pluginName) { + if (in_array($pluginName, $this->globalConfig['Plugins']['Plugins'])) { throw new Exception("Plugin $pluginName is enabled by default but shouldn't."); } } @@ -102,7 +98,7 @@ class ReleaseCheckListTest extends PHPUnit_Framework_TestCase public function testPiwikTrackerDebugIsOff() { $this->assertTrue(!isset($GLOBALS['PIWIK_TRACKER_DEBUG'])); - + $oldGet = $_GET; $_GET = array('idsite' => 1); @@ -110,7 +106,7 @@ class ReleaseCheckListTest extends PHPUnit_Framework_TestCase ob_start(); include PIWIK_PATH_TEST_TO_ROOT . "/piwik.php"; ob_end_clean(); - + $_GET = $oldGet; $this->assertTrue($GLOBALS['PIWIK_TRACKER_DEBUG'] === false); @@ -125,13 +121,13 @@ class ReleaseCheckListTest extends PHPUnit_Framework_TestCase Piwik::createConfigObject(); Piwik_Config::getInstance()->setTestEnvironment(); - $jqueryJs = file_get_contents( PIWIK_DOCUMENT_ROOT . '/libs/jquery/jquery.js', false, NULL, 0, 512 ); - $this->assertTrue( (boolean)preg_match('/jQuery (?:JavaScript Library )?v?([0-9.]+)/', $jqueryJs, $matches) ); - $this->assertEquals( Piwik_Config::getInstance()->General['jquery_version'], $matches[1] ); + $jqueryJs = file_get_contents(PIWIK_DOCUMENT_ROOT . '/libs/jquery/jquery.js', false, NULL, 0, 512); + $this->assertTrue((boolean)preg_match('/jQuery (?:JavaScript Library )?v?([0-9.]+)/', $jqueryJs, $matches)); + $this->assertEquals(Piwik_Config::getInstance()->General['jquery_version'], $matches[1]); - $jqueryuiJs = file_get_contents( PIWIK_DOCUMENT_ROOT . '/libs/jquery/jquery-ui.js', false, NULL, 0, 512 ); - $this->assertTrue( (boolean)preg_match('/jQuery UI (?:- v)?([0-9.]+)/', $jqueryuiJs, $matches) ); - $this->assertEquals( Piwik_Config::getInstance()->General['jqueryui_version'], $matches[1] ); + $jqueryuiJs = file_get_contents(PIWIK_DOCUMENT_ROOT . '/libs/jquery/jquery-ui.js', false, NULL, 0, 512); + $this->assertTrue((boolean)preg_match('/jQuery UI (?:- v)?([0-9.]+)/', $jqueryuiJs, $matches)); + $this->assertEquals(Piwik_Config::getInstance()->General['jqueryui_version'], $matches[1]); } @@ -141,46 +137,40 @@ class ReleaseCheckListTest extends PHPUnit_Framework_TestCase */ public function testSvnEolStyle() { - if(Piwik_Common::isWindows()) { + if (Piwik_Common::isWindows()) { // SVN native does not make this work on windows return; } - foreach(Piwik::globr(PIWIK_DOCUMENT_ROOT, '*') as $file) - { + foreach (Piwik::globr(PIWIK_DOCUMENT_ROOT, '*') as $file) { // skip files in these folders - if(strpos($file, '/.git/') !== false || + if (strpos($file, '/.git/') !== false || strpos($file, '/documentation/') !== false || strpos($file, '/tests/') !== false || strpos($file, '/lang/') !== false || strpos($file, 'yuicompressor') !== false || - strpos($file, '/tmp/') !== false) - { + strpos($file, '/tmp/') !== false + ) { continue; } // skip files with these file extensions - if(preg_match('/\.(bmp|fdf|gif|deflate|gz|ico|jar|jpg|p12|pdf|png|rar|swf|vsd|z|zip|ttf|so|dat|eps)$/', $file)) - { + if (preg_match('/\.(bmp|fdf|gif|deflate|gz|ico|jar|jpg|p12|pdf|png|rar|swf|vsd|z|zip|ttf|so|dat|eps)$/', $file)) { continue; } - if(!is_dir($file)) - { + if (!is_dir($file)) { $contents = file_get_contents($file); // expect CRLF - if(preg_match('/\.(bat|ps1)$/', $file)) - { + if (preg_match('/\.(bat|ps1)$/', $file)) { $contents = str_replace("\r\n", '', $contents); - $this->assertTrue(strpos($contents, "\n") === false, 'Incorrect line endings in '.$file); - } - else - { - // expect native - $hasWindowsEOL = strpos($contents, "\r\n"); + $this->assertTrue(strpos($contents, "\n") === false, 'Incorrect line endings in ' . $file); + } else { + // expect native + $hasWindowsEOL = strpos($contents, "\r\n"); - // overwrite translations files with incorrect line endings - $this->assertTrue($hasWindowsEOL === false, 'Incorrect line endings \r\n found in '.$file); + // overwrite translations files with incorrect line endings + $this->assertTrue($hasWindowsEOL === false, 'Incorrect line endings \r\n found in ' . $file); } } } @@ -195,11 +185,11 @@ class ReleaseCheckListTest extends PHPUnit_Framework_TestCase // check source against Snort rule 8443 // @see http://dev.piwik.org/trac/ticket/2203 $pattern = '/\x5b\x5c{2}.*\x5c{2}[\x22\x27]/'; - $contents = file_get_contents( PIWIK_DOCUMENT_ROOT . '/js/piwik.js' ); + $contents = file_get_contents(PIWIK_DOCUMENT_ROOT . '/js/piwik.js'); - $this->assertTrue( preg_match($pattern, $contents) == 0 ); + $this->assertTrue(preg_match($pattern, $contents) == 0); - $contents = file_get_contents( PIWIK_DOCUMENT_ROOT . '/piwik.js' ); - $this->assertTrue( preg_match($pattern, $contents) == 0 ); + $contents = file_get_contents(PIWIK_DOCUMENT_ROOT . '/piwik.js'); + $this->assertTrue(preg_match($pattern, $contents) == 0); } } |