Unknown errors cannot be mapped as they generate another error. Having a default case doesn't make much sense here.

Adding additional coverage to ErrorHandler.
This commit is contained in:
mark_story 2010-11-21 23:02:02 -05:00
parent 845edf38e1
commit 04d3feb6c0
2 changed files with 30 additions and 3 deletions

View file

@ -185,9 +185,6 @@ class ErrorHandler {
$error = 'Deprecated'; $error = 'Deprecated';
$log = LOG_NOTICE; $log = LOG_NOTICE;
break; break;
default:
return array();
break;
} }
return array($error, $log); return array($error, $log);
} }

View file

@ -83,6 +83,36 @@ class ErrorHandlerTest extends CakeTestCase {
$this->assertPattern('/variable:\s+wrong/', $result); $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. * Test that errors go into CakeLog when debug = 0.
* *