@@ -14,40 +14,38 @@ final class Php82HideDeprecationsErrorHandlerTest extends TestCase
14
14
{
15
15
private int $ originalErrorReporting ;
16
16
17
- /** @var callable|null */
18
- private $ originalErrorHandler ;
19
-
20
17
protected function setUp (): void
21
18
{
22
19
$ this ->originalErrorReporting = error_reporting ();
23
- set_error_handler (
24
- $ this ->originalErrorHandler = set_error_handler (
25
- static function () {}
26
- )
27
- );
28
20
}
29
21
30
22
protected function tearDown (): void
31
23
{
32
24
error_reporting ($ this ->originalErrorReporting );
33
- set_error_handler ( $ this -> originalErrorHandler );
25
+ restore_error_handler ( );
34
26
}
35
27
36
- public function testRegister (): void
28
+ public function testRegisterDebug (): void
37
29
{
38
30
if (PHP_VERSION_ID < 80200 ) {
39
31
$ this ->markTestSkipped ('Does not affect versions below PHP 8.2.0 ' );
40
32
}
41
33
42
- $ errorHandler = new Php82HideDeprecationsErrorHandler ();
34
+ Php82HideDeprecationsErrorHandler::register (true );
35
+ $ errorReporting = error_reporting ();
36
+
37
+ $ this ->assertSame (E_ALL & ~E_DEPRECATED , $ errorReporting );
38
+ }
43
39
44
- $ errorHandler ::register (true );
45
- $ debugErrorReporting = error_reporting ();
40
+ public function testRegisterNoDebug (): void
41
+ {
42
+ if (PHP_VERSION_ID < 80200 ) {
43
+ $ this ->markTestSkipped ('Does not affect versions below PHP 8.2.0 ' );
44
+ }
46
45
47
- $ errorHandler ::register (false );
48
- $ noDebugErrorReporting = error_reporting ();
46
+ Php82HideDeprecationsErrorHandler ::register (false );
47
+ $ errorReporting = error_reporting ();
49
48
50
- $ this ->assertSame (E_ALL & ~E_DEPRECATED , $ debugErrorReporting );
51
- $ this ->assertSame (E_ALL & ~E_DEPRECATED , $ noDebugErrorReporting );
49
+ $ this ->assertSame (E_ALL & ~E_DEPRECATED , $ errorReporting );
52
50
}
53
51
}
0 commit comments