Skip to content

Commit 2fdbdb6

Browse files
committed
fix
1 parent 372cf97 commit 2fdbdb6

2 files changed

Lines changed: 12 additions & 50 deletions

tests/phpt/error_handler_does_not_capture_memory_limit_increase_warning_during_out_of_memory_handling.phpt

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,7 @@ namespace Sentry {
2929
}
3030

3131
namespace Sentry\Tests {
32-
use Sentry\Event;
33-
use Sentry\Transport\Result;
34-
use Sentry\Transport\ResultStatus;
35-
use Sentry\Transport\TransportInterface;
32+
use Sentry\ErrorHandler;
3633

3734
$vendor = __DIR__;
3835

@@ -56,28 +53,12 @@ namespace Sentry\Tests {
5653
return true;
5754
});
5855

59-
$transport = new class implements TransportInterface {
60-
public function send(Event $event): Result
61-
{
62-
$GLOBALS['sentry_test_transport_calls'] = ($GLOBALS['sentry_test_transport_calls'] ?? 0) + 1;
63-
64-
return new Result(ResultStatus::success());
65-
}
66-
67-
public function close(?int $timeout = null): Result
68-
{
69-
return new Result(ResultStatus::success());
70-
}
71-
};
72-
73-
\Sentry\init([
74-
'dsn' => 'http://public@example.com/sentry/1',
75-
'transport' => $transport,
76-
'capture_silenced_errors' => true,
77-
]);
56+
$errorHandler = ErrorHandler::registerOnceFatalErrorHandler();
57+
$errorHandler->addFatalErrorHandlerListener(static function (): void {
58+
echo 'Fatal error listener called' . \PHP_EOL;
59+
});
7860

7961
register_shutdown_function(static function (): void {
80-
echo 'Transport calls: ' . ($GLOBALS['sentry_test_transport_calls'] ?? 0) . \PHP_EOL;
8162
echo 'Memory limit increase attempts: ' . ($GLOBALS['sentry_test_ini_set_calls'] ?? 0) . \PHP_EOL;
8263
echo 'Warning handler calls: ' . ($GLOBALS['sentry_test_warning_handler_calls'] ?? 0) . \PHP_EOL;
8364
});
@@ -87,6 +68,6 @@ namespace Sentry\Tests {
8768
?>
8869
--EXPECTF--
8970
%A
90-
Transport calls: 1
71+
Fatal error listener called
9172
Memory limit increase attempts: 1
9273
Warning handler calls: 0

tests/phpt/error_handler_skips_impossible_memory_limit_increase_during_out_of_memory_handling.phpt

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,7 @@ namespace Sentry {
2929
}
3030

3131
namespace Sentry\Tests {
32-
use Sentry\Event;
33-
use Sentry\Transport\Result;
34-
use Sentry\Transport\ResultStatus;
35-
use Sentry\Transport\TransportInterface;
32+
use Sentry\ErrorHandler;
3633

3734
$vendor = __DIR__;
3835

@@ -56,28 +53,12 @@ namespace Sentry\Tests {
5653
return true;
5754
});
5855

59-
$transport = new class implements TransportInterface {
60-
public function send(Event $event): Result
61-
{
62-
$GLOBALS['sentry_test_transport_calls'] = ($GLOBALS['sentry_test_transport_calls'] ?? 0) + 1;
63-
64-
return new Result(ResultStatus::success());
65-
}
66-
67-
public function close(?int $timeout = null): Result
68-
{
69-
return new Result(ResultStatus::success());
70-
}
71-
};
72-
73-
\Sentry\init([
74-
'dsn' => 'http://public@example.com/sentry/1',
75-
'transport' => $transport,
76-
'capture_silenced_errors' => true,
77-
]);
56+
$errorHandler = ErrorHandler::registerOnceFatalErrorHandler();
57+
$errorHandler->addFatalErrorHandlerListener(static function (): void {
58+
echo 'Fatal error listener called' . \PHP_EOL;
59+
});
7860

7961
register_shutdown_function(static function (): void {
80-
echo 'Transport calls: ' . ($GLOBALS['sentry_test_transport_calls'] ?? 0) . \PHP_EOL;
8162
echo 'Memory limit increase attempts: ' . ($GLOBALS['sentry_test_ini_set_calls'] ?? 0) . \PHP_EOL;
8263
echo 'Warning handler calls: ' . ($GLOBALS['sentry_test_warning_handler_calls'] ?? 0) . \PHP_EOL;
8364
});
@@ -87,6 +68,6 @@ namespace Sentry\Tests {
8768
?>
8869
--EXPECTF--
8970
%A
90-
Transport calls: 1
71+
Fatal error listener called
9172
Memory limit increase attempts: 0
9273
Warning handler calls: 0

0 commit comments

Comments
 (0)