ldc-arcadia-api/tests/Feature/Api/V1/Employees/EmployeeShowTest.php
Jérémy Munsch 3080c5dcfe
test(employees): add feature tests for employee retrieval and filtering
- Implement tests for employee show and index endpoints.
- Validate responses against OpenAPI specifications.
2026-08-14 09:59:24 +02:00

38 lines
1.2 KiB
PHP

<?php
declare(strict_types=1);
namespace Tests\Feature\Api\V1\Employees;
use Infra\Database\Models\Employee;
describe('Employee Show Feature API', function (): void {
it('returns 200 OK with employee details for valid employee ID', function (): void {
// GIVEN
/** @var \Tests\TestCase $test */
$test = $this;
$employee = Employee::factory()->create([
'public_employee_number' => (string) fake()->unique()->numberBetween(8000000, 8999999),
'last_name' => 'DUPONT',
'first_name' => 'Jean',
'start_date' => '2024-01-15',
'establishment' => '01',
'site' => 'LDCSER',
'service' => '097',
]);
// WHEN
$response = $test->getJson("/api/v1/employees/{$employee->public_employee_number}");
// THEN
$response->assertStatus(200);
$response->assertJson([
'employee' => [
'id' => $employee->public_employee_number,
'lastName' => 'DUPONT',
'firstName' => 'Jean',
],
]);
});
});