Skip to content

Commit 45f8845

Browse files
committed
fix: Split test into separate cases
1 parent 2090bf9 commit 45f8845

File tree

1 file changed

+15
-17
lines changed

1 file changed

+15
-17
lines changed

tests/lib/MVC/Symfony/ErrorHandler/Php82HideDeprecationsErrorHandlerTest.php

+15-17
Original file line numberDiff line numberDiff line change
@@ -14,40 +14,38 @@ final class Php82HideDeprecationsErrorHandlerTest extends TestCase
1414
{
1515
private int $originalErrorReporting;
1616

17-
/** @var callable|null */
18-
private $originalErrorHandler;
19-
2017
protected function setUp(): void
2118
{
2219
$this->originalErrorReporting = error_reporting();
23-
set_error_handler(
24-
$this->originalErrorHandler = set_error_handler(
25-
static function () {}
26-
)
27-
);
2820
}
2921

3022
protected function tearDown(): void
3123
{
3224
error_reporting($this->originalErrorReporting);
33-
set_error_handler($this->originalErrorHandler);
25+
restore_error_handler();
3426
}
3527

36-
public function testRegister(): void
28+
public function testRegisterDebug(): void
3729
{
3830
if (PHP_VERSION_ID < 80200) {
3931
$this->markTestSkipped('Does not affect versions below PHP 8.2.0');
4032
}
4133

42-
$errorHandler = new Php82HideDeprecationsErrorHandler();
34+
Php82HideDeprecationsErrorHandler::register(true);
35+
$errorReporting = error_reporting();
36+
37+
$this->assertSame(E_ALL & ~E_DEPRECATED, $errorReporting);
38+
}
4339

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+
}
4645

47-
$errorHandler::register(false);
48-
$noDebugErrorReporting = error_reporting();
46+
Php82HideDeprecationsErrorHandler::register(false);
47+
$errorReporting = error_reporting();
4948

50-
$this->assertSame(E_ALL & ~E_DEPRECATED, $debugErrorReporting);
51-
$this->assertSame(E_ALL & ~E_DEPRECATED, $noDebugErrorReporting);
49+
$this->assertSame(E_ALL & ~E_DEPRECATED, $errorReporting);
5250
}
5351
}

0 commit comments

Comments
 (0)