Skip to content
Permalink
Browse files

Changing method names on CakeLog and Debugger to better reflect what …

…they do. Updating test cases.
  • Loading branch information...
markstory committed Nov 15, 2010
1 parent da3bf1c commit 4960b6e7bf3c8114056c4cc21c8dfc6b4a070f79
@@ -236,10 +236,7 @@ public static function write($type, $message) {
* @param array $context Context
* @return void
*/
public static function handleError($code, $description, $file = null, $line = null, $context = null) {
if ($code === 2048 || $code === 8192) {
return;
}
public static function logError($code, $description, $file = null, $line = null, $context = null) {
switch ($code) {
case E_PARSE:
case E_ERROR:
@@ -269,7 +266,3 @@ public static function handleError($code, $description, $file = null, $line = nu
CakeLog::write($level, $message);
}
}
if (!defined('DISABLE_DEFAULT_ERROR_HANDLING')) {
set_error_handler(array('CakeLog', 'handleError'));
}
@@ -236,11 +236,7 @@ public static function log($var, $level = LOG_DEBUG) {
* @param array $context Context
* @return boolean true if error was handled
*/
public function handleError($code, $description, $file = null, $line = null, $context = null) {
if (error_reporting() == 0 || $code === 2048 || $code === 8192) {
return;
}
public function showError($code, $description, $file = null, $line = null, $context = null) {
$_this = Debugger::getInstance();
if (empty($file)) {
@@ -672,20 +668,4 @@ public static function checkSecurityKeys() {
}
}
/**
* Invokes the given debugger object as the current error handler, taking over control from the
* previous handler in a stack-like hierarchy.
*
* @param object $debugger A reference to the Debugger object
* @access public
* @static
* @link http://book.cakephp.org/view/1191/Using-the-Debugger-Class
*/
function invoke(&$debugger) {
set_error_handler(array(&$debugger, 'handleError'));
}
}
if (!defined('DISABLE_DEFAULT_ERROR_HANDLING')) {
Debugger::invoke(Debugger::getInstance());
}
@@ -174,7 +174,7 @@ function testLoggingWithErrorHandling() {
Configure::write('log', E_ALL & ~E_DEPRECATED);
Configure::write('debug', 0);
set_error_handler(array('CakeLog', 'handleError'));
set_error_handler(array('CakeLog', 'logError'));
$out .= '';
$result = file(LOGS . 'debug.log');
@@ -39,6 +39,8 @@ class DebuggerTest extends CakeTestCase {
// !!! Be careful with changing code below as it may
// !!! change line numbers which are used in the tests
// !!!
protected $_restoreError = false;
/**
* setUp method
*
@@ -60,6 +62,9 @@ function setUp() {
function tearDown() {
parent::teardown();
Configure::write('log', true);
if ($this->_restoreError) {
restore_error_handler();
}
}
/**
@@ -106,7 +111,9 @@ function testExcerpt() {
* @return void
*/
function testOutput() {
Debugger::invoke(Debugger::getInstance());
set_error_handler('Debugger::showError');
$this->_restoreError = true;
$result = Debugger::output(false);
$this->assertEqual($result, '');
$out .= '';
@@ -141,8 +148,8 @@ function testOutput() {
'pre' => array('class' => 'cake-debug'),
'a' => array(
'href' => "javascript:void(0);",
'onclick' => "document.getElementById('cakeErr4-trace').style.display = " .
"(document.getElementById('cakeErr4-trace').style.display == 'none'" .
'onclick' => "document.getElementById('cakeErr9-trace').style.display = " .
"(document.getElementById('cakeErr9-trace').style.display == 'none'" .
" ? '' : 'none');"
),
'b' => array(), 'Notice', '/b', ' (8)',
@@ -151,8 +158,6 @@ function testOutput() {
$this->assertPattern('/Undefined variable:\s+buzz/', $result[1]);
$this->assertPattern('/<a[^>]+>Code/', $result[1]);
$this->assertPattern('/<a[^>]+>Context/', $result[2]);
restore_error_handler();
}
/**
@@ -161,7 +166,9 @@ function testOutput() {
* @return void
*/
function testChangeOutputFormats() {
Debugger::invoke(Debugger::getInstance());
set_error_handler('Debugger::showError');
$this->_restoreError = true;
Debugger::output('js', array(
'traceLine' => '{:reference} - <a href="txmt://open?url=file://{:file}' .
'&line={:line}">{:path}</a>, line {:line}'
@@ -190,8 +197,6 @@ function testChangeOutputFormats() {
'/error'
);
$this->assertTags($result, $data, true);
restore_error_handler();
}
/**

0 comments on commit 4960b6e

Please sign in to comment.
You can’t perform that action at this time.