Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .coderabbit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# CodeRabbit reviews pull requests into the default branch only, unless more branches are listed here.
# Also review the pull requests into the maintenance branches (3.1.x, 3.2.x, ...), so a change is
# reviewed in its own pull request and not only in the merge of the branch into master.
reviews:
auto_review:
base_branches:
- '^\d+\.\d+\.x$'
2 changes: 2 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
colors="true"
stderr="true"
stopOnFailure="false"
failOnWarning="true"
failOnRisky="true"
cacheDirectory=".phpunit.cache"
>
<php>
Expand Down
49 changes: 26 additions & 23 deletions tests/Unit/Tracer/ErrorHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,30 +27,28 @@ public function setUp(): void
$this->errorHandler = new ErrorHandler();
}

public function tearDown(): void
{
restore_error_handler();
restore_exception_handler();
parent::tearDown();
}

public function testSetupRegistersErrorHandler(): void
{
$logger = Mockery::mock(Logger::class);

$this->errorHandler->setup($logger);

$currentHandler = set_error_handler(function () {
});
restore_error_handler();
try {
$currentHandler = set_error_handler(function () {
});
restore_error_handler();

$this->assertNotNull($currentHandler);
$this->assertInstanceOf(Closure::class, $currentHandler);
$this->assertNotNull($currentHandler);
$this->assertInstanceOf(Closure::class, $currentHandler);

$reflection = new ReflectionFunction($currentHandler);
$reflection = new ReflectionFunction($currentHandler);

$this->assertInstanceOf(ErrorHandler::class, $reflection->getClosureThis());
$this->assertEquals('handleError', $reflection->getName());
$this->assertInstanceOf(ErrorHandler::class, $reflection->getClosureThis());
$this->assertEquals('handleError', $reflection->getName());
} finally {
restore_error_handler();
restore_exception_handler();
}
}

public function testSetupRegistersExceptionHandler(): void
Expand All @@ -59,17 +57,22 @@ public function testSetupRegistersExceptionHandler(): void

$this->errorHandler->setup($logger);

$currentHandler = set_exception_handler(function () {
});
restore_exception_handler();
try {
$currentHandler = set_exception_handler(function () {
});
restore_exception_handler();

$this->assertNotNull($currentHandler);
$this->assertInstanceOf(Closure::class, $currentHandler);
$this->assertNotNull($currentHandler);
$this->assertInstanceOf(Closure::class, $currentHandler);

$reflection = new ReflectionFunction($currentHandler);
$reflection = new ReflectionFunction($currentHandler);

$this->assertInstanceOf(ErrorHandler::class, $reflection->getClosureThis());
$this->assertEquals('handleException', $reflection->getName());
$this->assertInstanceOf(ErrorHandler::class, $reflection->getClosureThis());
$this->assertEquals('handleException', $reflection->getName());
} finally {
restore_error_handler();
restore_exception_handler();
}
}

public function testHandleErrorThrowsErrorException(): void
Expand Down
Loading