Allow catching PHP errors

This commit is contained in:
Denis Sokolov
2013-10-10 14:11:59 +02:00
parent bc58800db2
commit 8a5a7bd3c2
2 changed files with 28 additions and 5 deletions
+1 -5
View File
@@ -353,11 +353,7 @@ class Run
return true;
}
}
$this->handleException(
new ErrorException(
$message, $level, 0, $file, $line
)
);
throw new ErrorException($message, $level, 0, $file, $line);
}
}
+27
View File
@@ -279,6 +279,33 @@ class RunTest extends TestCase
$this->assertTrue(true);
}
public function testErrorCatching()
{
$run = $this->getRunInstance();
$run->register();
$handler = $this->getHandler();
$run->pushHandler($handler);
$test = $this;
$handler
->shouldReceive('handle')
->andReturnUsing(function () use($test) {
$test->fail('$handler should not be called error should be caught');
})
;
try {
trigger_error(E_USER_NOTICE, 'foo');
$this->fail('Should not continue after error thrown');
} catch (\ErrorException $e) {
// Do nothing
$this->assertTrue(true);
return;
}
$this->fail('Should not continue here, should have been caught.');
}
/**
* Test to make sure that error_reporting is respected.
*/