Add unit tests for the Debug class

This commit is contained in:
Kijin Sung 2016-02-15 16:11:00 +09:00
parent 3045ac9c42
commit 0947bafa66
2 changed files with 82 additions and 6 deletions

View file

@ -18,6 +18,11 @@ class Debug
protected static $_slow_triggers = array();
protected static $_slow_widgets = array();
/**
* Also write to error log.
*/
public static $write_to_error_log = true;
/**
* Get all entries.
*
@ -118,9 +123,12 @@ class Debug
self::$_entries[] = $entry;
// Add the entry to the error log.
$log_entry = str_replace("\0", '', sprintf('Rhymix Debug: %s in %s on line %d',
var_export($message, true), $entry->file, $entry->line));
error_log($log_entry);
if (self::$write_to_error_log)
{
$log_entry = str_replace("\0", '', sprintf('Rhymix Debug: %s in %s on line %d',
var_export($message, true), $entry->file, $entry->line));
error_log($log_entry);
}
}
/**
@ -165,9 +173,12 @@ class Debug
);
// Add the entry to the error log.
$log_entry = str_replace("\0", '', sprintf('PHP %s: %s in %s on line %d',
$errinfo->type, $errstr, $errfile, intval($errline)));
error_log($log_entry);
if (self::$write_to_error_log)
{
$log_entry = str_replace("\0", '', sprintf('PHP %s: %s in %s on line %d',
$errinfo->type, $errstr, $errfile, intval($errline)));
error_log($log_entry);
}
}
/**