diff --git a/tests/Integration/Presentation/Web/WebExceptionRendererTest.php b/tests/Integration/Presentation/Web/WebExceptionRendererTest.php new file mode 100644 index 0000000..71a49bf --- /dev/null +++ b/tests/Integration/Presentation/Web/WebExceptionRendererTest.php @@ -0,0 +1,60 @@ +render($exception, $request); + + // THEN + expect($response)->not->toBeNull() + ->and($response?->getStatusCode())->toBe(404); + }); + + it('returns null for API or JSON requests', function (): void { + // GIVEN + $renderer = new WebExceptionRenderer(); + $exception = new NotFoundException('Resource not found'); + $request = Request::create( + '/api/v1/employees', + 'GET', + [], + [], + [], + ['HTTP_ACCEPT' => 'application/json'] + ); + + // WHEN + $response = $renderer->render($exception, $request); + + // THEN + expect($response)->toBeNull(); + }); + + it('returns null for unhandled exceptions', function (): void { + // GIVEN + $renderer = new WebExceptionRenderer(); + $exception = new \InvalidArgumentException('Invalid argument'); + $request = Request::create('/some-web-page', 'GET'); + + // WHEN + $response = $renderer->render($exception, $request); + + // THEN + expect($response)->toBeNull(); + }); +}); diff --git a/tests/Pest.php b/tests/Pest.php index b982987..21a2b46 100644 --- a/tests/Pest.php +++ b/tests/Pest.php @@ -29,6 +29,10 @@ pest() ->use(RefreshDatabase::class) ->in('Integration/WithApp'); +pest() + ->extend(LaravelTestCase::class) + ->in('Integration/Presentation'); + pest() ->extend(BasePHPUnitTestCase::class) ->in('Integration/Standalones');