Skip to content

Commit

Permalink
Fixing error handler tests for real
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzo committed Jun 18, 2013
1 parent a07e695 commit f7072eb
Showing 1 changed file with 26 additions and 8 deletions.
34 changes: 26 additions & 8 deletions lib/Cake/Test/TestCase/Error/ErrorHandlerTest.php
Expand Up @@ -57,9 +57,6 @@ public function setUp() {
$request->base = '';
Router::setRequestInfo($request);
Configure::write('debug', 2);

Log::disable('stdout');
Log::disable('stderr');
}

/**
Expand All @@ -72,8 +69,6 @@ public function tearDown() {
if ($this->_restoreError) {
restore_error_handler();
}
Log::enable('stdout');
Log::enable('stderr');
}

/**
Expand Down Expand Up @@ -204,6 +199,12 @@ public function testHandleErrorLoggingTrace() {
*/
public function testHandleException() {
$error = new Error\NotFoundException('Kaboom!');
Configure::write('Exception', [
'handler' => 'Cake\Error\ErrorHandler::handleException',
'renderer' => 'Cake\Error\ExceptionRenderer'
]);

$this->_restoreError = true;
ob_start();
ErrorHandler::handleException($error);
$result = ob_get_clean();
Expand All @@ -219,7 +220,11 @@ public function testHandleExceptionLog() {
if (file_exists(LOGS . 'error.log')) {
unlink(LOGS . 'error.log');
}
Configure::write('Exception.log', true);
Configure::write('Exception', [
'handler' => 'Cake\Error\ErrorHandler::handleException',
'renderer' => 'Cake\Error\ExceptionRenderer',
'log' => true
]);
$error = new Error\NotFoundException('Kaboom!');

ob_start();
Expand All @@ -241,8 +246,12 @@ public function testHandleExceptionLogSkipping() {
if (file_exists(LOGS . 'error.log')) {
unlink(LOGS . 'error.log');
}
Configure::write('Exception.log', true);
Configure::write('Exception.skipLog', array('Cake\Error\NotFoundException'));
Configure::write('Exception', [
'handler' => 'Cake\Error\ErrorHandler::handleException',
'renderer' => 'Cake\Error\ExceptionRenderer',
'log' => true,
'skipLog' => ['Cake\Error\NotFoundException']
]);
$notFound = new Error\NotFoundException('Kaboom!');
$forbidden = new Error\ForbiddenException('Fooled you!');

Expand Down Expand Up @@ -291,6 +300,10 @@ public function testLoadPluginHandler() {
*/
public function testHandleFatalErrorPage() {
$line = __LINE__;
Configure::write('Exception', [
'handler' => 'Cake\Error\ErrorHandler::handleException',
'renderer' => 'Cake\Error\ExceptionRenderer',
]);

ob_start();
ob_start();
Expand Down Expand Up @@ -320,6 +333,11 @@ public function testHandleFatalErrorLog() {
if (file_exists(LOGS . 'error.log')) {
unlink(LOGS . 'error.log');
}
Configure::write('Exception', [
'handler' => 'Cake\Error\ErrorHandler::handleException',
'renderer' => 'Cake\Error\ExceptionRenderer',
'log' => true
]);

ob_start();
ErrorHandler::handleFatalError(E_ERROR, 'Something wrong', __FILE__, __LINE__);
Expand Down

0 comments on commit f7072eb

Please sign in to comment.