Start 2.0 development

Co-authored-by: Anthony <anthony@infraly.co>
Co-authored-by: Sky Mulley <daniel.mulley@outlook.com>
This commit is contained in:
robert dennis
2026-10-05 18:10:18 -04:00
co-authored by Anthony Sky Mulley
parent 98079a0166
commit 6c0413e39b
2764 changed files with 176950 additions and 72961 deletions
@@ -0,0 +1,40 @@
<?php
declare(strict_types=1);
namespace Pterodactyl\Tests\Pest\Unit\Exceptions\Http\Connection\DaemonConnectionExceptionTest;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Log;
use Monolog\Handler\TestHandler;
use Monolog\Level;
use Monolog\Logger;
use Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException;
use Pterodactyl\Tests\TestCase;
uses(TestCase::class);
test('reports warning with request context for client errors', function () {
$handler = new TestHandler();
Log::swap(new \Illuminate\Log\Logger(new Logger('test', [$handler])));
$previous = Http::failedRequest(['error' => 'bad request'], 400, ['X-Request-Id' => 'request-123']);
(new DaemonConnectionException($previous))->report();
expect($handler->hasRecords(Level::Warning))->toBeTrue();
expect($handler->hasRecords(Level::Error))->toBeFalse();
$records = $handler->getRecords();
expect($records)->toHaveCount(1);
expect($records[0]->message)->toBe($previous->getMessage());
expect($records[0]->context['request_id'])->toBe('request-123');
expect($records[0]->context['exception'])->toBe($previous);
});
test('reports error for server errors', function () {
$handler = new TestHandler();
Log::swap(new \Illuminate\Log\Logger(new Logger('test', [$handler])));
$previous = Http::failedRequest([], 502);
(new DaemonConnectionException($previous))->report();
expect($handler->hasRecords(Level::Error))->toBeTrue();
expect($handler->hasRecords(Level::Warning))->toBeFalse();
$records = $handler->getRecords();
expect($records)->toHaveCount(1);
expect($records[0]->message)->toBe($previous->getMessage());
expect($records[0]->context['exception'])->toBe($previous);
});