From 8e1390caad55a5692d5b57c2a46c6b3d1a116551 Mon Sep 17 00:00:00 2001 From: Anton Grebnev Date: Thu, 13 Oct 2011 14:10:30 +0400 Subject: [PATCH] ErrorHandlerTest class modified --- tests/exception/ErrorHandlerTest.php | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/tests/exception/ErrorHandlerTest.php b/tests/exception/ErrorHandlerTest.php index 76d9f9f..f4cc82d 100644 --- a/tests/exception/ErrorHandlerTest.php +++ b/tests/exception/ErrorHandlerTest.php @@ -16,14 +16,21 @@ require_once dirname(__FILE__) . '/../../exception/ErrorHandler.php'; class ErrorHandlerTest extends PHPUnit_Framework_TestCase { - + public $old_eh = array('PHPUnit_Util_ErrorHandler', 'handleError'); + + public function setUp() + { + set_error_handler(array('ErrorHandler', 'error_handler')); + ob_start(); + } + public function testErrorHandlerInit() { $my_eh = array('ErrorHandler', 'error_handler'); ErrorHandler::init(); $eh = set_error_handler($my_eh); $this->assertInternalType('array', $eh); - $this->assertEquals($eh, $my_eh); + $this->assertEquals($eh, $my_eh); } /** @@ -37,8 +44,6 @@ class ErrorHandlerTest extends PHPUnit_Framework_TestCase public function testShowDebug() { - ob_start(); - echo PHP_EOL . 'some string' . PHP_EOL . PHP_EOL; try { throw new ErrorException("test error", E_USER_ERROR); } catch (ErrorException $e) { @@ -46,7 +51,13 @@ class ErrorHandlerTest extends PHPUnit_Framework_TestCase $this->assertNotEmpty($result); $this->assertStringStartsWith('', $result); $this->assertStringEndsWith('', $result); - } + } + + } + + public function tearDown() + { + set_error_handler($this->old_eh); } } \ No newline at end of file