handler = new HttpErrorHandler(); }); it('handles HttpException', function () { $exception = new HttpException( 'Not Found', Status::NOT_FOUND, headers: ['X-Custom' => 'value'] ); expect($this->handler->canHandle($exception))->toBeTrue(); $result = $this->handler->handle($exception); expect($result->handled)->toBeTrue(); expect($result->message)->toBe('Not Found'); expect($result->statusCode)->toBe(404); expect($result->data['error_type'])->toBe('http'); expect($result->data['headers'])->toBe(['X-Custom' => 'value']); }); it('handles HttpException with no headers', function () { $exception = new HttpException( 'Bad Request', Status::BAD_REQUEST ); $result = $this->handler->handle($exception); expect($result->handled)->toBeTrue(); expect($result->statusCode)->toBe(400); expect($result->data['headers'])->toBe([]); }); it('does not handle non-HttpException', function () { $exception = new \RuntimeException('Some error'); expect($this->handler->canHandle($exception))->toBeFalse(); }); it('has NORMAL priority', function () { expect($this->handler->getPriority())->toBe(ErrorHandlerPriority::NORMAL); }); it('has correct name', function () { expect($this->handler->getName())->toBe('http_error_handler'); }); });