Skip to content
Permalink
Browse files

Unknown errors cannot be mapped as they generate another error. Havin…

…g a default case doesn't make much sense here.

Adding additional coverage to ErrorHandler.
  • Loading branch information...
markstory committed Nov 22, 2010
1 parent 845edf3 commit 04d3feb6c06bba019fd5d62d237955e98ffc74e0
Showing with 30 additions and 3 deletions.
  1. +0 −3 cake/libs/error_handler.php
  2. +30 −0 cake/tests/cases/libs/error_handler.test.php
@@ -185,9 +185,6 @@ protected static function _mapErrorCode($code) {
$error = 'Deprecated';
$log = LOG_NOTICE;
break;
default:
return array();
break;
}
return array($error, $log);
}
@@ -83,6 +83,36 @@ function testHandleErrorDebugOn() {
$this->assertPattern('/variable:\s+wrong/', $result);
}
/**
* provides errors for mapping tests.
*
* @return void
*/
public static function errorProvider() {
return array(
array(E_USER_NOTICE, 'Notice'),
array(E_USER_WARNING, 'Warning'),
array(E_USER_ERROR, 'Fatal Error'),
);
}
/**
* test error mappings
*
* @dataProvider errorProvider
* @return void
*/
function testErrorMapping($error, $expected) {
set_error_handler('ErrorHandler::handleError');
$this->_restoreError = true;
ob_start();
trigger_error('Test error', $error);
$result = ob_get_clean();
$this->assertPattern('/<b>' . $expected . '<\/b>/', $result);
}
/**
* Test that errors go into CakeLog when debug = 0.
*

0 comments on commit 04d3feb

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