Skip to content

Commit

Permalink
TestCase: use PHP 5.4 features
Browse files Browse the repository at this point in the history
  • Loading branch information
milo committed Apr 20, 2016
1 parent cb1a877 commit 008de64
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions src/Framework/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,22 +114,16 @@ public function runTest($method, array $args = NULL)


if ($this->prevErrorHandler === FALSE) {
$me = $this;
$handleErrors = & $this->handleErrors;
$prev = & $this->prevErrorHandler;

$prev = set_error_handler(function ($severity) use ($me, & $prev, & $handleErrors) {
if ($handleErrors && ($severity & error_reporting()) === $severity) {
$handleErrors = FALSE;
$rm = new \ReflectionMethod($me, 'tearDown');
$rm->setAccessible(TRUE);
$this->prevErrorHandler = set_error_handler(function ($severity) {
if ($this->handleErrors && ($severity & error_reporting()) === $severity) {
$this->handleErrors = FALSE;

set_error_handler(function() {}); // mute all errors
$rm->invoke($me);
$this->tearDown();
restore_error_handler();
}

return $prev ? call_user_func_array($prev, func_get_args()) : FALSE;
return $this->prevErrorHandler ? call_user_func_array($this->prevErrorHandler, func_get_args()) : FALSE;
});
}

Expand Down

0 comments on commit 008de64

Please sign in to comment.