diff options
author | Benaka Moorthi <benaka.moorthi@gmail.com> | 2013-09-26 16:17:03 +0400 |
---|---|---|
committer | Benaka Moorthi <benaka.moorthi@gmail.com> | 2013-09-26 16:17:03 +0400 |
commit | 8aad84b17a3c0b90aa1a4393dae76550be113f59 (patch) | |
tree | be4f3426f77da6e5708ae05c1e8f13ad69f8bd40 /core | |
parent | 4157032dbf90ff95fccacffd0ecf9962e47aa6e1 (diff) |
Got tests to pass when running all Core tests.
Diffstat (limited to 'core')
-rw-r--r-- | core/Error.php | 29 | ||||
-rw-r--r-- | core/ExceptionHandler.php | 7 |
2 files changed, 25 insertions, 11 deletions
diff --git a/core/Error.php b/core/Error.php index 475283c231..abf1aee9b0 100644 --- a/core/Error.php +++ b/core/Error.php @@ -21,6 +21,11 @@ class Error /** * TODO */ + public static $debugBacktraceForTests = null; + + /** + * TODO + */ public $errno; /** @@ -154,17 +159,21 @@ class Error } $backtrace = ''; - $bt = @debug_backtrace(); - if ($bt !== null && isset($bt[0])) { - foreach ($bt as $i => $debug) { - $backtrace .= "#$i " - . (isset($debug['class']) ? $debug['class'] : '') - . (isset($debug['type']) ? $debug['type'] : '') - . (isset($debug['function']) ? $debug['function'] : '') - . '(...) called at [' - . (isset($debug['file']) ? $debug['file'] : '') . ':' - . (isset($debug['line']) ? $debug['line'] : '') . ']' . "\n"; + if (empty(self::$debugBacktraceForTests)) { + $bt = @debug_backtrace(); + if ($bt !== null && isset($bt[0])) { + foreach ($bt as $i => $debug) { + $backtrace .= "#$i " + . (isset($debug['class']) ? $debug['class'] : '') + . (isset($debug['type']) ? $debug['type'] : '') + . (isset($debug['function']) ? $debug['function'] : '') + . '(...) called at [' + . (isset($debug['file']) ? $debug['file'] : '') . ':' + . (isset($debug['line']) ? $debug['line'] : '') . ']' . "\n"; + } } + } else { + $backtrace = self::$debugBacktraceForTests; } $error = new Error($errno, $errstr, $errfile, $errline, $backtrace); diff --git a/core/ExceptionHandler.php b/core/ExceptionHandler.php index cc25f3b989..47cfa12634 100644 --- a/core/ExceptionHandler.php +++ b/core/ExceptionHandler.php @@ -22,6 +22,11 @@ use Piwik\API\ResponseBuilder; */ class ExceptionHandler { + /** + * TODO + */ + public static $debugBacktraceForTests = null; + public static function setUp() { Piwik_AddAction('Log.formatFileMessage', array('\\Piwik\\ExceptionHandler', 'formatFileAndDBLogMessage')); @@ -35,7 +40,7 @@ class ExceptionHandler { if ($message instanceof \Exception) { $message = sprintf("%s(%d): %s\n%s", $message->getFile(), $message->getLine(), $message->getMessage(), - $message->getTraceAsString()); + self::$debugBacktraceForTests ?: $message->getTraceAsString()); $message = $log->formatMessage($level, $pluginName, $datetime, $message); } |