diff options
author | matt <matt@59fd770c-687e-43c8-a1e3-f5a4ff64c105> | 2008-02-05 10:49:07 +0300 |
---|---|---|
committer | matt <matt@59fd770c-687e-43c8-a1e3-f5a4ff64c105> | 2008-02-05 10:49:07 +0300 |
commit | d6b9af741d34a9dc71131cf3e65d69f4c1071070 (patch) | |
tree | 5cb9afe148eb1a00520749186c3ca63295de6569 /tests | |
parent | 37ce066b84ef4be2ca900cd4d415fbe8fc657da5 (diff) |
- added test that checks that piwik.php DEBUG is set to false
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/config_test.php | 5 | ||||
-rw-r--r-- | tests/modules/piwik.php.test.php | 59 |
2 files changed, 63 insertions, 1 deletions
diff --git a/tests/config_test.php b/tests/config_test.php index 8e044a070c..bf82456957 100755 --- a/tests/config_test.php +++ b/tests/config_test.php @@ -29,15 +29,18 @@ set_include_path( PATH_TEST_TO_ROOT .'/' . PATH_SEPARATOR . getcwd() . '/../modules/' . PATH_SEPARATOR . getcwd() . '/../../tests/' . PATH_SEPARATOR . getcwd() . '/../tests/' + . PATH_SEPARATOR . getcwd() . '/../' . PATH_SEPARATOR . PATH_TEST_TO_ROOT . '/plugins/' . PATH_SEPARATOR . PATH_TEST_TO_ROOT . '/config/' . PATH_SEPARATOR . PATH_TEST_TO_ROOT . '/modules/' . PATH_SEPARATOR . PATH_TEST_TO_ROOT . '/tests/' + . PATH_SEPARATOR . PATH_TEST_TO_ROOT . '/' . PATH_SEPARATOR . PATH_TEST_TO_ROOT2 . '/libs/' . PATH_SEPARATOR . PATH_TEST_TO_ROOT2 . '/config/' . PATH_SEPARATOR . PATH_TEST_TO_ROOT2 . '/plugins/' . PATH_SEPARATOR . PATH_TEST_TO_ROOT2 . '/modules/' - . PATH_SEPARATOR . PATH_TEST_TO_ROOT2 . '/tests/'
+ . PATH_SEPARATOR . PATH_TEST_TO_ROOT2 . '/tests/' + . PATH_SEPARATOR . PATH_TEST_TO_ROOT2 . '/'
. PATH_SEPARATOR . get_include_path()
. PATH_SEPARATOR . get_include_path() . '../' ); diff --git a/tests/modules/piwik.php.test.php b/tests/modules/piwik.php.test.php new file mode 100644 index 0000000000..01086ad18b --- /dev/null +++ b/tests/modules/piwik.php.test.php @@ -0,0 +1,59 @@ +<?php +// we def have problems with INCLUDE_PATH on these tests.... +if(!defined("PATH_TEST_TO_ROOT")) { + define('PATH_TEST_TO_ROOT', '..'); + $content = file_get_contents('../../piwik.php'); +} +else +{ + $content = file_get_contents('../piwik.php'); +} +$GLOBALS['content'] = $content; + +if(!defined('CONFIG_TEST_INCLUDED')) +{ + require_once PATH_TEST_TO_ROOT ."/../tests/config_test.php"; + +} + +class Test_PiwikPhp extends UnitTestCase +{ + function __construct( $title = '') + { + parent::__construct( $title ); + } + + function testDebugOff() + { + // catch that the string GLOBALS['DEBUGPIWIK'] = false + $ereg = "(GLOBALS\['DEBUGPIWIK'\])([ ])*=([ ])*(false;)"; + + // first we test the ereg :) + + $good = array( + '$GLOBALS[\'DEBUGPIWIK\'] = false;', + '$GLOBALS[\'DEBUGPIWIK\'] = false;', + ' $GLOBALS[\'DEBUGPIWIK\'] = false;', + ); + + foreach($good as $test) + { + $this->assertTrue( ereg($ereg,$test) !== false); + } + $bad = array( + '$GLOBALS[\'DEBUGPIWIK\'] = true;', + '$GLOBALS[\'DEBUGPIWIK\'] = 1;', + ' $GLOBALS[\'DEBUGPIWIK\']=\'false\';', + ); + + foreach($bad as $test) + { + $this->assertTrue( ereg($ereg,$test) === false); + } + + + // then we check that the piwik.php content does have the DEBUG variable set to off + $this->assertTrue( ereg($ereg, $GLOBALS['content']) !== false, + 'The $GLOBALS[\'DEBUGPIWIK\'] MUST BE SET TO false IN A PRODUCTION ENVIRONMENT !!!'); + } +}
\ No newline at end of file |