mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 02:56:15 +00:00
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:
parent
845edf38e1
commit
04d3feb6c0
2 changed files with 30 additions and 3 deletions
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Add table
Reference in a new issue