Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit dc7e5a3

Browse filesBrowse files
alexpottnicolas-grekas
authored andcommitted
Ensure that PHPUnit's error handler is still working in isolated tests
1 parent 4365d23 commit dc7e5a3
Copy full SHA for dc7e5a3

File tree

2 files changed

+19
-0
lines changed
Filter options

2 files changed

+19
-0
lines changed

‎src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,12 @@ public static function collectDeprecations($outputFile)
255255
}
256256
$deprecations[] = array(error_reporting(), $msg);
257257
});
258+
// This can be registered before the PHPUnit error handler.
259+
if (!$previousErrorHandler) {
260+
$UtilPrefix = class_exists('PHPUnit_Util_ErrorHandler') ? 'PHPUnit_Util_' : 'PHPUnit\Util\\';
261+
$previousErrorHandler = $UtilPrefix.'ErrorHandler::handleError';
262+
}
263+
258264
register_shutdown_function(function () use ($outputFile, &$deprecations) {
259265
file_put_contents($outputFile, serialize($deprecations));
260266
});

‎src/Symfony/Bridge/PhpUnit/Tests/ProcessIsolationTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/PhpUnit/Tests/ProcessIsolationTest.php
+13Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,17 @@ public function testIsolation()
2121
@trigger_error('Test abc', E_USER_DEPRECATED);
2222
$this->addToAssertionCount(1);
2323
}
24+
25+
public function testCallingOtherErrorHandler()
26+
{
27+
$class = class_exists('PHPUnit\Framework\Exception') ? 'PHPUnit\Framework\Exception' : 'PHPUnit_Framework_Exception';
28+
if (method_exists($this, 'expectException')) {
29+
$this->expectException($class);
30+
$this->expectExceptionMessage('Test that PHPUnit\'s error handler fires.');
31+
} else {
32+
$this->setExpectedException($class, 'Test that PHPUnit\'s error handler fires.');
33+
}
34+
35+
trigger_error('Test that PHPUnit\'s error handler fires.', E_USER_WARNING);
36+
}
2437
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.