14
14
use function set_error_handler ;
15
15
use function set_exception_handler ;
16
16
use PHPUnit \Framework \TestCase ;
17
+ use PHPUnit \Runner \ErrorHandler ;
18
+ use Throwable ;
17
19
18
20
class Issue5592Test extends TestCase
19
21
{
20
22
public function testAddedAndRemovedErrorHandler (): void
21
23
{
22
- set_error_handler ( static fn () => false );
24
+ $ previous = set_error_handler ([ $ this , ' addedAndRemovedErrorHandler ' ] );
23
25
restore_error_handler ();
26
+
27
+ $ this ->assertInstanceOf (ErrorHandler::class, $ previous );
24
28
$ this ->assertTrue (true );
25
29
}
26
30
27
31
public function testAddedErrorHandler (): void
28
32
{
29
- set_error_handler (static fn () => false );
33
+ $ previous = set_error_handler ([$ this , 'addedErrorHandler ' ]);
34
+
35
+ $ this ->assertInstanceOf (ErrorHandler::class, $ previous );
30
36
$ this ->assertTrue (false );
31
37
}
32
38
@@ -38,14 +44,18 @@ public function testRemovedErrorHandler(): void
38
44
39
45
public function testAddedAndRemovedExceptionHandler (): void
40
46
{
41
- set_exception_handler ( static fn () => null );
47
+ $ previous = set_exception_handler ([ $ this , ' addedAndRemovedExceptionHandler ' ] );
42
48
restore_exception_handler ();
49
+
50
+ $ this ->assertNull ($ previous );
43
51
$ this ->assertTrue (true );
44
52
}
45
53
46
54
public function testAddedExceptionHandler (): void
47
55
{
48
- set_exception_handler (static fn () => null );
56
+ $ previous = set_exception_handler ([$ this , 'addedExceptionHandler ' ]);
57
+
58
+ $ this ->assertNull ($ previous );
49
59
$ this ->assertTrue (false );
50
60
}
51
61
@@ -54,4 +64,20 @@ public function testRemovedExceptionHandler(): void
54
64
restore_exception_handler ();
55
65
$ this ->assertTrue (false );
56
66
}
67
+
68
+ public function addedAndRemovedErrorHandler ($ errno , $ errstr , $ errfile , $ errline ): void
69
+ {
70
+ }
71
+
72
+ public function addedErrorHandler ($ errno , $ errstr , $ errfile , $ errline ): void
73
+ {
74
+ }
75
+
76
+ public function addedAndRemovedExceptionHandler (Throwable $ exception ): void
77
+ {
78
+ }
79
+
80
+ public function addedExceptionHandler (Throwable $ exception ): void
81
+ {
82
+ }
57
83
}
0 commit comments