8000 minor #42761 [ErrorHandler] Fix test `fatal_with_nested_handlers` for… · symfony/symfony@2ab40fd · GitHub
[go: up one dir, main page]

Skip to content
< 8000 /div>

Commit 2ab40fd

Browse files
committed
minor #42761 [ErrorHandler] Fix test fatal_with_nested_handlers for PHP 8.1 (derrabus)
This PR was merged into the 4.4 branch. Discussion ---------- [ErrorHandler] Fix test `fatal_with_nested_handlers` for PHP 8.1 | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Part of #41552 | License | MIT | Doc PR | Not needed. PHP 8.1 changes the order in which `print_r()`, `var_dump()` and friends dump properties. This PR creates a new version of one of ErrorHandler's PHPT tests, adapting to this change. Commits ------- a0e8f4f Fix test fatal_with_nested_handlers for PHP 8.1
2 parents ecf55ab + a0e8f4f commit 2ab40fd

File tree

2 files changed

+60
-3
lines changed

2 files changed

+60
-3
lines changed

src/Symfony/Component/ErrorHandler/Tests/phpt/fatal_with_nested_handlers.phpt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
--TEST--
22
Test catching fatal errors when handlers are nested
3+
--SKIPIF--
4+
<?php if (\PHP_VERSION_ID < 80100) echo 'skip' ?>
35
--FILE--
46
<?php
57

@@ -36,6 +38,9 @@ array(1) {
3638
string(37) "Error and exception handlers do match"
3739
}
3840
object(Symfony\Component\ErrorHandler\Error\FatalError)#%d (%d) {
41+
["message":protected]=>
42+
string(186) "Error: Class Symfony\Component\ErrorHandler\Broken contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (JsonSerializable::jsonSerialize)"
43+
%a
3944
["error":"Symfony\Component\ErrorHandler\Error\FatalError":private]=>
4045
array(4) {
4146
["type"]=>
@@ -47,7 +52,4 @@ object(Symfony\Component\ErrorHandler\Error\FatalError)#%d (%d) {
4752
["line"]=>
4853
int(%d)
4954
}
50-
["message":protected]=>
51-
string(186) "Error: Class Symfony\Component\ErrorHandler\Broken contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (JsonSerializable::jsonSerialize)"
52-
%a
5355
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
--TEST--
2+
Test catching fatal errors when handlers are nested
3+
--SKIPIF--
4+
<?php if (\PHP_VERSION_ID >= 80100) echo 'skip' ?>
5+
--FILE--
6+
<?php
7+
8+
namespace Symfony\Component\ErrorHandler;
9+
10+
$vendor = __DIR__;
11+
while (!file_exists($vendor.'/vendor')) {
12+
$vendor = \dirname($vendor);
13+
}
14+
require $vendor.'/vendor/autoload.php';
15+
16+
Debug::enable();
17+
ini_set('display_errors', 0);
18+
19+
$eHandler = set_error_handler('var_dump');
20+
$xHandler = set_exception_handler('var_dump');
21+
22+
var_dump([
23+
$eHandler[0] === $xHandler[0] ? 'Error and exception handlers do match' : 'Error and exception handlers are different',
24+
]);
25+
26+
$eHandler[0]->setExceptionHandler('print_r');
27+
28+
if (true) {
29+
class Broken implements \JsonSerializable
30+
{
31+
}
32+
}
33+
34+
?>
35+
--EXPECTF--
36+
array(1) {
37+
[0]=>
38+
string(37) "Error and exception handlers do match"
39+
}
40+
object(Symfony\Component\ErrorHandler\Error\FatalError)#%d (%d) {
41+
["error":"Symfony\Component\ErrorHandler\Error\FatalError":private]=>
42+
array(4) {
43+
["type"]=>
44+
int(1)
45+
["message"]=>
46+
string(179) "Class Symfony\Component\ErrorHandler\Broken contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (JsonSerializable::jsonSerialize)"
47+
["file"]=>
48+
string(%d) "%s"
49+
["line"]=>
50+
int(%d)
51+
}
52+
["message":protected]=>
53+
string(186) "Error: Class Symfony\Component\ErrorHandler\Broken contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (JsonSerializable::jsonSerialize)"
54+
%a
55+
}

0 commit comments

Comments
 (0)
0