Changed the response status and title for ValidationException from 400 to 422 to align with HTTP standards.
50 lines
1.4 KiB
PHP
50 lines
1.4 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Tests\Feature;
|
|
|
|
use Symfony\Component\HttpFoundation\Response;
|
|
|
|
describe('Error Documentation Pages', function (): void {
|
|
it('renders the documentation view for all valid HTTP error codes', function (int $code): void {
|
|
// GIVEN
|
|
/** @var \Tests\TestCase $test */
|
|
$test = $this;
|
|
$expectedTitle = Response::$statusTexts[$code] ?? 'Error';
|
|
|
|
// WHEN
|
|
$response = $test->get("/errors/{$code}");
|
|
|
|
// THEN
|
|
$response->assertStatus(200);
|
|
$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]);
|
|
|
|
it('returns a 404 for a non-numeric error code slug', function (): void {
|
|
// GIVEN
|
|
/** @var \Tests\TestCase $test */
|
|
$test = $this;
|
|
$invalidSlug = 'non-existing-error-code';
|
|
|
|
// WHEN
|
|
$response = $test->get("/errors/{$invalidSlug}");
|
|
|
|
// THEN
|
|
$response->assertStatus(404);
|
|
});
|
|
});
|