Ensure that PHPUnit's error handler is still working in isolated tests
This commit is contained in:
parent
4365d23e38
commit
dc7e5a39fa
@ -255,6 +255,12 @@ class DeprecationErrorHandler
|
||||
}
|
||||
$deprecations[] = array(error_reporting(), $msg);
|
||||
});
|
||||
// This can be registered before the PHPUnit error handler.
|
||||
if (!$previousErrorHandler) {
|
||||
$UtilPrefix = class_exists('PHPUnit_Util_ErrorHandler') ? 'PHPUnit_Util_' : 'PHPUnit\Util\\';
|
||||
$previousErrorHandler = $UtilPrefix.'ErrorHandler::handleError';
|
||||
}
|
||||
|
||||
register_shutdown_function(function () use ($outputFile, &$deprecations) {
|
||||
file_put_contents($outputFile, serialize($deprecations));
|
||||
});
|
||||
|
@ -21,4 +21,17 @@ class ProcessIsolationTest extends TestCase
|
||||
@trigger_error('Test abc', E_USER_DEPRECATED);
|
||||
$this->addToAssertionCount(1);
|
||||
}
|
||||
|
||||
public function testCallingOtherErrorHandler()
|
||||
{
|
||||
$class = class_exists('PHPUnit\Framework\Exception') ? 'PHPUnit\Framework\Exception' : 'PHPUnit_Framework_Exception';
|
||||
if (method_exists($this, 'expectException')) {
|
||||
$this->expectException($class);
|
||||
$this->expectExceptionMessage('Test that PHPUnit\'s error handler fires.');
|
||||
} else {
|
||||
$this->setExpectedException($class, 'Test that PHPUnit\'s error handler fires.');
|
||||
}
|
||||
|
||||
trigger_error('Test that PHPUnit\'s error handler fires.', E_USER_WARNING);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user