Skip to content

Commit

Permalink
Change PhpWarningJob
Browse files Browse the repository at this point in the history
unserialize() causes only a notice until PHP 8.2 and a warning from
PHP 8.3 on. Change it to get contents of a missing file to consistently
get a PHP warning.
  • Loading branch information
otsch committed Aug 3, 2024
1 parent b1536ee commit ece157d
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 13 deletions.
6 changes: 0 additions & 6 deletions tests/Stubs/ErrorHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,6 @@ class ErrorHandler extends AbstractTestErrorHandler
{
public function boot(): void
{
file_put_contents(
__DIR__ . '/../_testdata/datapath/error-handler-events',
'error reporting: ' . error_reporting(),
FILE_APPEND,
);

$this->registerHandler(function (Throwable $exception) {
$this->logErrorEvent($exception);
});
Expand Down
2 changes: 1 addition & 1 deletion tests/Stubs/PhpWarningJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ class PhpWarningJob extends PpqJob
*/
public function invoke(): void
{
unserialize('foo');
$content = file_get_contents(__DIR__ . '/file-that-does-not-exist');
}
}
9 changes: 3 additions & 6 deletions tests/_integration/ErrorHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,10 @@

$handlerEvents = file_get_contents(helper_testDataPath('error-handler-events'));

helper_dump($handlerEvents);

helper_dump(Logs::getJobLog($job)); // @phpstan-ignore-line

expect($job?->status)->toBe(QueueJobStatus::finished)
->and($handlerEvents)->toContain('PHP Warning: unserialize(): Error at offset 0 of 3 bytes');
})->only();
->and($handlerEvents)->toContain('PHP Warning: file_get_contents(')
->and($handlerEvents)->toContain('Failed to open stream: No such file or directory');
});

it('handles a PHP error', function () {
$job = Dispatcher::queue('default')
Expand Down

0 comments on commit ece157d

Please sign in to comment.