2026-08-12 15:45:29 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
|
|
namespace Tests\Feature;
|
|
|
|
|
|
2026-08-13 12:34:32 +02:00
|
|
|
use Symfony\Component\HttpFoundation\Response;
|
|
|
|
|
|
2026-08-12 15:45:29 +02:00
|
|
|
describe('Error Documentation Pages', function (): void {
|
2026-08-13 12:34:32 +02:00
|
|
|
it('renders the documentation view for all valid HTTP error codes', function (int $code): void {
|
2026-08-12 15:45:29 +02:00
|
|
|
// GIVEN
|
|
|
|
|
/** @var \Tests\TestCase $test */
|
2026-08-13 12:34:32 +02:00
|
|
|
$test = $this;
|
|
|
|
|
$expectedTitle = Response::$statusTexts[$code] ?? 'Error';
|
2026-08-12 15:45:29 +02:00
|
|
|
|
|
|
|
|
// WHEN
|
2026-08-12 17:40:18 +02:00
|
|
|
$response = $test->get("/errors/{$code}");
|
2026-08-12 15:45:29 +02:00
|
|
|
|
|
|
|
|
// THEN
|
|
|
|
|
$response->assertStatus(200);
|
2026-08-13 12:34:32 +02:00
|
|
|
$response->assertSee($expectedTitle);
|
|
|
|
|
$response->assertSee((string) $code);
|
|
|
|
|
$response->assertSee('Conforme à la spécification RFC 7807 Problem Details');
|
|
|
|
|
})->with([400, 404, 422, 429, 500, 503]);
|
|
|
|
|
|
|
|
|
|
it('returns a 404 when requesting documentation for an unsupported error code', function (int $code): void {
|
|
|
|
|
// GIVEN
|
|
|
|
|
/** @var \Tests\TestCase $test */
|
|
|
|
|
$test = $this;
|
|
|
|
|
|
|
|
|
|
// WHEN
|
|
|
|
|
$response = $test->get("/errors/{$code}");
|
|
|
|
|
|
|
|
|
|
// THEN
|
|
|
|
|
$response->assertStatus(404);
|
|
|
|
|
})->with([0, 418, 999]);
|
2026-08-12 15:45:29 +02:00
|
|
|
|
2026-08-13 12:34:32 +02:00
|
|
|
it('returns a 404 for a non-numeric error code slug', function (): void {
|
2026-08-12 15:45:29 +02:00
|
|
|
// GIVEN
|
|
|
|
|
/** @var \Tests\TestCase $test */
|
|
|
|
|
$test = $this;
|
|
|
|
|
$invalidSlug = 'non-existing-error-code';
|
|
|
|
|
|
|
|
|
|
// WHEN
|
|
|
|
|
$response = $test->get("/errors/{$invalidSlug}");
|
|
|
|
|
|
|
|
|
|
// THEN
|
|
|
|
|
$response->assertStatus(404);
|
|
|
|
|
});
|
|
|
|
|
});
|