diff --git a/core/Config.php b/core/Config.php index 3487357a30da75a8448a31d51f86c2f7f91e4eea..5d5a9c3828b830273308d090c69cfe54cefeae69 100644 --- a/core/Config.php +++ b/core/Config.php @@ -109,6 +109,7 @@ class Config } $this->init(); + if (isset($this->configGlobal['database_tests']) || isset($this->configLocal['database_tests']) ) { @@ -223,7 +224,6 @@ class Config */ public function init() { - $this->clear(); $this->initialized = true; $reportError = !empty($GLOBALS['PIWIK_TRACKER_MODE']); diff --git a/core/Log.php b/core/Log.php index 050b36a2cf9e50533b7684fc37f7d06cdc44bbef..3ef721272cab695b39566cd4c489ca438fcc4318 100644 --- a/core/Log.php +++ b/core/Log.php @@ -133,7 +133,7 @@ class Log * * @var string */ - private $logMessageFormat = "[%tag%%datetime%] %message%"; + private $logMessageFormat = "%tag%[%datetime%] %message%"; /** * If we're logging to a file, this is the path to the file to log to. @@ -236,7 +236,6 @@ class Log */ public function formatMessage($level, $tag, $datetime, $message) { - $tag = $tag ? $tag . ':' : ''; return str_replace( array("%tag%", "%message%", "%datetime%", "%level%"), array($tag, $message, $datetime, $this->getStringLevel($level)), @@ -332,7 +331,10 @@ class Log } if (is_string($message)) { - $message = '[' . $currentRequestKey . '] ' . $message; + if(!defined('PIWIK_TEST_MODE') + || !PIWIK_TEST_MODE) { + $message = '[' . $currentRequestKey . '] ' . $message; + } $message = $this->formatMessage($level, $tag, $datetime, $message); if(!Common::isPhpCliMode()) { diff --git a/tests/PHPUnit/Core/LogTest.php b/tests/PHPUnit/Core/LogTest.php index e3c3cde4ae189f4163796e97b8aa944da0bf1c4f..607e99fbee7cb6f989b3e79c6e4e66c6f3cd3b14 100644 --- a/tests/PHPUnit/Core/LogTest.php +++ b/tests/PHPUnit/Core/LogTest.php @@ -187,6 +187,7 @@ dummy backtrace' public function testLogMessagesIgnoredWhenNotWithinLevel($backend) { Config::getInstance()->log['log_writers'] = array($backend); + Config::getInstance()->log['log_level'] = 'ERROR'; ob_start(); Log::info(self::TESTMESSAGE); @@ -203,13 +204,14 @@ dummy backtrace' } if ($backend == 'screen') { - if ($formatMessage) { + if ($formatMessage + && !Common::isPhpCliMode()) { $expectedMessage = '<pre>' . $expectedMessage . '</pre>'; } $this->screenOutput = $this->removePathsFromBacktrace($this->screenOutput); - $this->assertEquals($expectedMessage . "\n", $this->screenOutput); + $this->assertEquals($expectedMessage . "\n", $this->screenOutput, "unexpected output: ".$this->screenOutput); } else if ($backend == 'file') { $this->assertTrue(file_exists(self::getLogFileLocation())); @@ -237,7 +239,7 @@ dummy backtrace' private function checkNoMessagesLogged($backend) { if ($backend == 'screen') { - $this->assertEmpty($this->screenOutput); + $this->assertEmpty($this->screenOutput, "Output not empty: ".$this->screenOutput); } else if ($backend == 'file') { $this->assertFalse(file_exists(self::getLogFileLocation())); } else if ($backend == 'database') { diff --git a/tests/index.php b/tests/index.php index c5acf9d64dd05340c314fc0ad342b26725b6dfef..3cbf2fdd11f7c44bf5d41c279b375a78bc2a49fe 100644 --- a/tests/index.php +++ b/tests/index.php @@ -31,7 +31,7 @@ </ul> </p> -<p>If you are new to the wonderful world of testing, <a href='README.txt'>see the README</a> for an introduction.</p> +<p>If you are new to the wonderful world of testing, <a href='https://github.com/piwik/piwik/blob/master/tests/README.md'>see the README</a> for an introduction.</p> <img src='resources/disturbing-image.jpg' alt='I find your lack of tests disturbing'> <br/><i><a href='http://www.flickr.com/photos/sebastian_bergmann/2282734669/'>Photo source & license</a></i>