diff --git a/cake/libs/error_handler.php b/cake/libs/error_handler.php index e79a4cb1b..57b16f575 100644 --- a/cake/libs/error_handler.php +++ b/cake/libs/error_handler.php @@ -185,9 +185,6 @@ class ErrorHandler { $error = 'Deprecated'; $log = LOG_NOTICE; break; - default: - return array(); - break; } return array($error, $log); } diff --git a/cake/tests/cases/libs/error_handler.test.php b/cake/tests/cases/libs/error_handler.test.php index 446b9ec2c..c95d7566a 100644 --- a/cake/tests/cases/libs/error_handler.test.php +++ b/cake/tests/cases/libs/error_handler.test.php @@ -83,6 +83,36 @@ class ErrorHandlerTest extends CakeTestCase { $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('/' . $expected . '<\/b>/', $result); + } + /** * Test that errors go into CakeLog when debug = 0. *