minor #9742 ErrorHandlerTest: restore_error_handler() on assertion failure (nicolas-grekas)

This PR was submitted for the 2.4-dev branch but it was merged into the 2.4 branch instead (closes #9742).

Discussion
----------

ErrorHandlerTest: restore_error_handler() on assertion failure

Before the patch, if any test fail in src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php,
phpunit's error handler is not correctly restored.
When running a test batch, this breaks other tests that rely on its behavior (@expectedException PHPUnit_Framework_Error)

Commits
-------

a6ed37c ErrorHandlerTest: restore_error_handler() on assertion failure
This commit is contained in:
Fabien Potencier 2013-12-12 16:53:02 +01:00
commit bb619ba020

View File

@ -90,6 +90,11 @@ PHP
);
} catch (DummyException $e) {
// if an exception is thrown, the test passed
} catch (\Exception $e) {
restore_error_handler();
restore_exception_handler();
throw $e;
}
restore_error_handler();
@ -135,6 +140,10 @@ PHP
self::triggerNotice($this);
} catch (DummyException $e) {
// if an exception is thrown, the test passed
} catch (\Exception $e) {
restore_error_handler();
throw $e;
}
restore_error_handler();
@ -150,6 +159,7 @@ PHP
public function testConstruct()
{
try {
$handler = ErrorHandler::register(3);
$level = new \ReflectionProperty($handler, 'level');
@ -158,10 +168,16 @@ PHP
$this->assertEquals(3, $level->getValue($handler));
restore_error_handler();
} catch (\Exception $e) {
restore_error_handler();
throw $e;
}
}
public function testHandle()
{
try {
$handler = ErrorHandler::register(0);
$this->assertFalse($handler->handle(0, 'foo', 'foo.php', 12, 'foo'));
@ -216,6 +232,11 @@ PHP
$handler->handle(E_USER_DEPRECATED, 'foo', 'foo.php', 12, 'foo');
restore_error_handler();
} catch (\Exception $e) {
restore_error_handler();
throw $e;
}
}
/**