diff --git a/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php b/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php index 011c28e948f2e..9397af1f22799 100644 --- a/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php +++ b/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php @@ -255,6 +255,12 @@ public static function collectDeprecations($outputFile) } $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)); }); diff --git a/src/Symfony/Bridge/PhpUnit/Tests/ProcessIsolationTest.php b/src/Symfony/Bridge/PhpUnit/Tests/ProcessIsolationTest.php index 0cfbe515ee9e4..ec8f124a5f2c1 100644 --- a/src/Symfony/Bridge/PhpUnit/Tests/ProcessIsolationTest.php +++ b/src/Symfony/Bridge/PhpUnit/Tests/ProcessIsolationTest.php @@ -21,4 +21,17 @@ public function testIsolation() @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); + } }
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: