From f7072eb10a270ed05077fbad9aa42e477e45686a Mon Sep 17 00:00:00 2001 From: Jose Lorenzo Rodriguez Date: Tue, 18 Jun 2013 10:01:56 +0200 Subject: [PATCH] Fixing error handler tests for real --- .../Test/TestCase/Error/ErrorHandlerTest.php | 34 ++++++++++++++----- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/lib/Cake/Test/TestCase/Error/ErrorHandlerTest.php b/lib/Cake/Test/TestCase/Error/ErrorHandlerTest.php index b7a2b0978e8..6afcdf3e6ce 100644 --- a/lib/Cake/Test/TestCase/Error/ErrorHandlerTest.php +++ b/lib/Cake/Test/TestCase/Error/ErrorHandlerTest.php @@ -57,9 +57,6 @@ public function setUp() { $request->base = ''; Router::setRequestInfo($request); Configure::write('debug', 2); - - Log::disable('stdout'); - Log::disable('stderr'); } /** @@ -72,8 +69,6 @@ public function tearDown() { if ($this->_restoreError) { restore_error_handler(); } - Log::enable('stdout'); - Log::enable('stderr'); } /** @@ -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(); @@ -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(); @@ -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!'); @@ -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(); @@ -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__);