ldc-arcadia-api/tests/Feature/Api/V1/Employees/EmployeeShowTest.php

43 lines
1.3 KiB
PHP

<?php
declare(strict_types=1);
namespace Tests\Feature\Api\V1\Employees;
use Database\ArcadiaReplicate\Factories\Refp\RuPersonneSirhFactory;
describe('Employee Show Feature API', function (): void {
beforeEach(function (): void {
RuPersonneSirhFactory::truncate();
});
it('returns 200 OK with employee details for valid employee ID', function (): void {
// GIVEN
/** @var \Tests\TestCase $test */
$test = $this;
$employeeNumber = (string) fake()->unique()->numberBetween(8000000, 8999999);
RuPersonneSirhFactory::new()->create([
'MATRICULE_FIC' => $employeeNumber,
'NOM_FIC' => 'DUPONT',
'PRENOM_FIC' => 'Jean',
'DATE_DEB_FIC' => '2024-01-15',
'ETAB_FIC' => '01',
'SITE_FIC' => 'LDCSER',
'SERVICE_FIC' => '097',
]);
// WHEN
$response = $test->getJson("/api/v1/employees/{$employeeNumber}");
// THEN
$response->assertStatus(200);
$response->assertJson([
'employee' => [
'matricule' => $employeeNumber,
'lastName' => 'DUPONT',
'firstName' => 'Jean',
],
]);
});
});