Skip to content

Commit 5b4fafe

Browse files
committed
Wrap handler test in a try-finally
1 parent f7c69c2 commit 5b4fafe

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

tests/Php85/Php85Test.php

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,11 @@ class Php85Test extends TestCase
2121
public function testGetErrorHandler($expected, $handler): void
2222
{
2323
set_error_handler($handler);
24-
$result = get_error_handler();
25-
restore_error_handler();
26-
restore_error_handler();
24+
try {
25+
$result = get_error_handler();
26+
} finally {
27+
restore_error_handler();
28+
}
2729

2830
$this->assertSame($expected, $result);
2931
}
@@ -39,15 +41,19 @@ public function testErrorStableReturnValue(): void
3941
public function testGetExceptionHandler($expected, $handler): void
4042
{
4143
set_exception_handler($handler);
42-
$result = get_exception_handler();
43-
restore_exception_handler();
44+
try {
45+
$result = get_exception_handler();
46+
} finally {
47+
restore_exception_handler();
48+
}
4449

4550
$this->assertSame($expected, $result);
4651
}
4752

4853
public function testExceptionStableReturnValue(): void
4954
{
5055
$this->assertSame(get_exception_handler(), get_exception_handler());
56+
5157
}
5258

5359
public static function provideHandler()

0 commit comments

Comments
 (0)