feat(employees): rename ArcadiaEmployeeId to SiRhMatricule and expose matricule in api responses
This commit is contained in:
parent
2606ac882e
commit
7312289811
28 changed files with 83 additions and 83 deletions
|
|
@ -36,7 +36,7 @@ Arcadia API combine 3 paradigmes éprouvés pour créer une base de code hauteme
|
|||
- **Dépendance** : Ne dépend de **RIEN** (sauf `Shared\`). **Aucun import Laravel / Eloquent / HTTP n'est toléré**.
|
||||
- **Contenu** :
|
||||
- **`Models/Entities/`** : Entités riches, `final readonly`, immutables, implémentant `Shared\DDD\Model\Entity` ou `Shared\DDD\Model\AggregateRoot` (modèles d'écriture) et/ou `Shared\DDD\Model\ReadModel` (modèles de lecture).
|
||||
- **`Models/ValueObjects/`** : Objets-valeurs typés et auto-validants (ex: `ArcadiaEmployeeId`, `NutriScore`, `BrandCode`).
|
||||
- **`Models/ValueObjects/`** : Objets-valeurs typés et auto-validants (ex: `SiRhMatricule`, `NutriScore`, `BrandCode`).
|
||||
- **`Ports/`** : Interfaces des opérations externes :
|
||||
- `Directories/` : Ports de lecture seule pour modèles de lecture purs (`Directory<TId, TReadModel of ReadModel>`).
|
||||
- `Repositories/` : Ports de cycle de vie et requêtes d'agrégats racines (`Repository<TId, TAggregate of AggregateRoot>`).
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ flowchart TD
|
|||
Request --> Controller["EmployeeShowController (__invoke)"]
|
||||
|
||||
subgraph Presentation Couche
|
||||
Controller -->|"Instancie"| Input["Input(ArcadiaEmployeeId)"]
|
||||
Controller -->|"Instancie"| Input["Input(SiRhMatricule)"]
|
||||
Controller -->|"Lance"| Builder["UsecaseBuilder::using(executor)"]
|
||||
end
|
||||
|
||||
|
|
@ -78,7 +78,7 @@ final readonly class EmployeeShowController
|
|||
|
||||
public function __invoke(EmployeeShowRequest $request, string $identifier): JsonResponse
|
||||
{
|
||||
$input = new Input(new ArcadiaEmployeeId($identifier));
|
||||
$input = new Input(new SiRhMatricule($identifier));
|
||||
|
||||
/** @var EmployeeShowView $view */
|
||||
$view = UsecaseBuilder::using($this->executor)
|
||||
|
|
|
|||
|
|
@ -767,7 +767,7 @@ components:
|
|||
type: object
|
||||
description: Représentation canonique d'un employé dans le métamodèle Arcadia.
|
||||
required:
|
||||
- id
|
||||
- matricule
|
||||
- firstName
|
||||
- lastName
|
||||
- establishment
|
||||
|
|
@ -775,10 +775,10 @@ components:
|
|||
- service
|
||||
- startDate
|
||||
properties:
|
||||
id:
|
||||
matricule:
|
||||
type: string
|
||||
pattern: '^\d{7,8}$'
|
||||
description: Matricule public unique de l'employé.
|
||||
description: Matricule public unique de l'employé (SIRH).
|
||||
example: "01155902"
|
||||
firstName:
|
||||
type: string
|
||||
|
|
|
|||
|
|
@ -4,12 +4,12 @@ declare(strict_types=1);
|
|||
|
||||
namespace Application\Arcadia\Exceptions;
|
||||
|
||||
use Domain\Models\ValueObjects\Employees\ArcadiaEmployeeId;
|
||||
use Domain\Models\ValueObjects\Employees\SiRhMatricule;
|
||||
use Shared\DDD\Exception\NotFoundException;
|
||||
|
||||
final class EmployeeNotFoundException extends NotFoundException
|
||||
{
|
||||
public static function forEmployee(ArcadiaEmployeeId | string $id): self
|
||||
public static function forEmployee(SiRhMatricule | string $id): self
|
||||
{
|
||||
return new self("Employee '{$id}' not found.");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,13 +4,13 @@ declare(strict_types=1);
|
|||
|
||||
namespace Application\Arcadia\Usecase\Employees\Find;
|
||||
|
||||
use Domain\Models\ValueObjects\Employees\ArcadiaEmployeeId;
|
||||
use Domain\Models\ValueObjects\Employees\SiRhMatricule;
|
||||
use Shared\DDD\Usecase\Input as UsecaseInput;
|
||||
|
||||
final readonly class Input implements UsecaseInput
|
||||
{
|
||||
public function __construct(
|
||||
public ArcadiaEmployeeId $id,
|
||||
public SiRhMatricule $id,
|
||||
) {
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,13 +4,13 @@ declare(strict_types=1);
|
|||
|
||||
namespace Application\Arcadia\Usecase\Employees\Find;
|
||||
|
||||
use Domain\Models\ValueObjects\Employees\ArcadiaEmployeeId;
|
||||
use Domain\Models\ValueObjects\Employees\SiRhMatricule;
|
||||
use Shared\DDD\Usecase\Output as UsecaseOutput;
|
||||
|
||||
final readonly class Output implements UsecaseOutput
|
||||
{
|
||||
public function __construct(
|
||||
public ArcadiaEmployeeId $id,
|
||||
public SiRhMatricule $id,
|
||||
public string $firstName,
|
||||
public string $lastName,
|
||||
public string $establishment,
|
||||
|
|
|
|||
|
|
@ -5,13 +5,13 @@ declare(strict_types=1);
|
|||
namespace Application\Arcadia\Usecase\Employees\FindAll;
|
||||
|
||||
use Domain\Models\Entities\Employee;
|
||||
use Domain\Models\ValueObjects\Employees\ArcadiaEmployeeId;
|
||||
use Domain\Models\ValueObjects\Employees\SiRhMatricule;
|
||||
use Shared\DDD\Usecase\Output as UsecaseOutput;
|
||||
|
||||
final readonly class PaginatedEmployee implements UsecaseOutput
|
||||
{
|
||||
public function __construct(
|
||||
public ArcadiaEmployeeId $id,
|
||||
public SiRhMatricule $id,
|
||||
public string $firstName,
|
||||
public string $lastName,
|
||||
public string $establishment,
|
||||
|
|
|
|||
|
|
@ -4,17 +4,17 @@ declare(strict_types=1);
|
|||
|
||||
namespace Domain\Models\Entities;
|
||||
|
||||
use Domain\Models\ValueObjects\Employees\ArcadiaEmployeeId;
|
||||
use Domain\Models\ValueObjects\Employees\SiRhMatricule;
|
||||
use Domain\Models\ValueObjects\EstablishmentCode;
|
||||
use Domain\Models\ValueObjects\ServiceId;
|
||||
use Domain\Models\ValueObjects\SiteId;
|
||||
use Shared\DDD\Model\ReadModel;
|
||||
|
||||
/** @implements ReadModel<ArcadiaEmployeeId> */
|
||||
/** @implements ReadModel<SiRhMatricule> */
|
||||
final readonly class Employee implements ReadModel
|
||||
{
|
||||
private function __construct(
|
||||
public ArcadiaEmployeeId $publicEmployeeNumber,
|
||||
public SiRhMatricule $publicEmployeeNumber,
|
||||
public string $lastName,
|
||||
public string $firstName,
|
||||
public \DateTimeInterface $startDate,
|
||||
|
|
@ -29,13 +29,13 @@ final readonly class Employee implements ReadModel
|
|||
}
|
||||
|
||||
#[\Override]
|
||||
public function id(): ArcadiaEmployeeId
|
||||
public function id(): SiRhMatricule
|
||||
{
|
||||
return $this->publicEmployeeNumber;
|
||||
}
|
||||
|
||||
public static function hydrate(
|
||||
ArcadiaEmployeeId $publicEmployeeNumber,
|
||||
SiRhMatricule $publicEmployeeNumber,
|
||||
string $lastName,
|
||||
string $firstName,
|
||||
\DateTimeInterface $startDate,
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ namespace Domain\Models\ValueObjects\Employees;
|
|||
|
||||
use Shared\DDD\Model\EntityId;
|
||||
|
||||
final readonly class ArcadiaEmployeeId extends EntityId
|
||||
final readonly class SiRhMatricule extends EntityId
|
||||
{
|
||||
private const string PATTERN = '/^\d{7,8}$/';
|
||||
|
||||
|
|
@ -5,14 +5,14 @@ declare(strict_types=1);
|
|||
namespace Domain\Ports\Directories;
|
||||
|
||||
use Domain\Models\Entities\Employee;
|
||||
use Domain\Models\ValueObjects\Employees\ArcadiaEmployeeId;
|
||||
use Domain\Models\ValueObjects\Employees\SiRhMatricule;
|
||||
use Domain\Models\ValueObjects\Employees\EmployeeFilter;
|
||||
use Domain\Models\ValueObjects\Employees\EmployeeSorter;
|
||||
use Shared\DDD\Port\Directory;
|
||||
use Shared\Paginated;
|
||||
use Shared\Pagination;
|
||||
|
||||
/** @extends Directory<ArcadiaEmployeeId, Employee> */
|
||||
/** @extends Directory<SiRhMatricule, Employee> */
|
||||
interface EmployeeDirectory extends Directory
|
||||
{
|
||||
/** @return Paginated<Employee> */
|
||||
|
|
@ -22,5 +22,5 @@ interface EmployeeDirectory extends Directory
|
|||
?EmployeeFilter $filter = null,
|
||||
): Paginated;
|
||||
|
||||
public function find(ArcadiaEmployeeId $id): ?Employee;
|
||||
public function find(SiRhMatricule $id): ?Employee;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ namespace Infra\Adapters\Directories;
|
|||
|
||||
use Database\ArcadiaReplicate\Tables\Refp\RuPersonneSirhTable;
|
||||
use Domain\Models\Entities\Employee;
|
||||
use Domain\Models\ValueObjects\Employees\ArcadiaEmployeeId;
|
||||
use Domain\Models\ValueObjects\Employees\SiRhMatricule;
|
||||
use Domain\Models\ValueObjects\Employees\EmployeeFilter;
|
||||
use Domain\Models\ValueObjects\Employees\EmployeeSortColumn;
|
||||
use Domain\Models\ValueObjects\Employees\EmployeeSorter;
|
||||
|
|
@ -81,7 +81,7 @@ final class ArcadiaEmployeeDirectory implements EmployeeDirectory
|
|||
}
|
||||
|
||||
#[\Override]
|
||||
public function find(ArcadiaEmployeeId $id): ?Employee
|
||||
public function find(SiRhMatricule $id): ?Employee
|
||||
{
|
||||
$query = $this->connection
|
||||
->table(RuPersonneSirhTable::table($this->connection))
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ declare(strict_types=1);
|
|||
namespace Infra\Adapters\Directories;
|
||||
|
||||
use Domain\Models\Entities\Employee;
|
||||
use Domain\Models\ValueObjects\Employees\ArcadiaEmployeeId;
|
||||
use Domain\Models\ValueObjects\Employees\SiRhMatricule;
|
||||
use Domain\Models\ValueObjects\Employees\EmployeeFilter;
|
||||
use Domain\Models\ValueObjects\Employees\EmployeeSortColumn;
|
||||
use Domain\Models\ValueObjects\Employees\EmployeeSorter;
|
||||
|
|
@ -33,7 +33,7 @@ final class InMemoryEmployeeDirectory implements EmployeeDirectory
|
|||
}
|
||||
|
||||
#[\Override]
|
||||
public function find(ArcadiaEmployeeId $id): ?Employee
|
||||
public function find(SiRhMatricule $id): ?Employee
|
||||
{
|
||||
return $this->employees[$id->value] ?? null;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ declare(strict_types=1);
|
|||
namespace Infra\Adapters\Mappers;
|
||||
|
||||
use Domain\Models\Entities\Employee;
|
||||
use Domain\Models\ValueObjects\Employees\ArcadiaEmployeeId;
|
||||
use Domain\Models\ValueObjects\Employees\SiRhMatricule;
|
||||
use Domain\Models\ValueObjects\EstablishmentCode;
|
||||
use Domain\Models\ValueObjects\ServiceId;
|
||||
use Domain\Models\ValueObjects\SiteId;
|
||||
|
|
@ -39,7 +39,7 @@ final readonly class EmployeeMapper
|
|||
$data['MATRICULE_FIC'] ?? $data['matricule_fic'] ?? $data['public_employee_number'] ?? null,
|
||||
''
|
||||
));
|
||||
// Garantir un format 7 ou 8 chiffres pour ArcadiaEmployeeId
|
||||
// Garantir un format 7 ou 8 chiffres pour SiRhMatricule
|
||||
if (is_numeric($rawMatricule) && strlen($rawMatricule) < 7) {
|
||||
$rawMatricule = str_pad($rawMatricule, 7, '0', STR_PAD_LEFT);
|
||||
}
|
||||
|
|
@ -61,7 +61,7 @@ final readonly class EmployeeMapper
|
|||
$updatedAt = self::parseDate($data['DAT_MAJ'] ?? $data['dat_maj'] ?? $data['updated_at'] ?? null);
|
||||
|
||||
return Employee::hydrate(
|
||||
publicEmployeeNumber: new ArcadiaEmployeeId($rawMatricule),
|
||||
publicEmployeeNumber: new SiRhMatricule($rawMatricule),
|
||||
lastName: $lastName,
|
||||
firstName: $firstName,
|
||||
startDate: $startDate,
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ use Presentation\Api\V1\Presenters\Employees\EmployeeShowView;
|
|||
final readonly class EmployeeDto implements ApiResponseDto
|
||||
{
|
||||
public function __construct(
|
||||
public string $id,
|
||||
public string $matricule,
|
||||
public string $firstName,
|
||||
public string $lastName,
|
||||
public string $establishment,
|
||||
|
|
@ -25,7 +25,7 @@ final readonly class EmployeeDto implements ApiResponseDto
|
|||
public static function fromView(EmployeeShowView $view): self
|
||||
{
|
||||
return new self(
|
||||
id: (string) $view->id,
|
||||
matricule: (string) $view->id,
|
||||
firstName: $view->firstName,
|
||||
lastName: $view->lastName,
|
||||
establishment: $view->establishment,
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ use Presentation\Api\V1\Contracts\ApiResponseDto;
|
|||
final readonly class PaginatedEmployee implements ApiResponseDto
|
||||
{
|
||||
public function __construct(
|
||||
public string $id,
|
||||
public string $matricule,
|
||||
public string $firstName,
|
||||
public string $lastName,
|
||||
public string $establishment,
|
||||
|
|
@ -25,7 +25,7 @@ final readonly class PaginatedEmployee implements ApiResponseDto
|
|||
public static function fromUsecase(UsecasePaginatedEmployee $employee): self
|
||||
{
|
||||
return new self(
|
||||
id: (string) $employee->id,
|
||||
matricule: (string) $employee->id,
|
||||
firstName: $employee->firstName,
|
||||
lastName: $employee->lastName,
|
||||
establishment: $employee->establishment,
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace Presentation\Api\V1\Http\Requests\Employees;
|
||||
|
||||
use Domain\Models\ValueObjects\Employees\ArcadiaEmployeeId;
|
||||
use Domain\Models\ValueObjects\Employees\SiRhMatricule;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
final class EmployeeShowRequest extends FormRequest
|
||||
|
|
@ -24,8 +24,8 @@ final class EmployeeShowRequest extends FormRequest
|
|||
]);
|
||||
}
|
||||
|
||||
public function employeeId(): ArcadiaEmployeeId
|
||||
public function employeeId(): SiRhMatricule
|
||||
{
|
||||
return new ArcadiaEmployeeId($this->string('employeeId')->value());
|
||||
return new SiRhMatricule($this->string('employeeId')->value());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,12 +4,12 @@ declare(strict_types=1);
|
|||
|
||||
namespace Presentation\Api\V1\Presenters\Employees;
|
||||
|
||||
use Domain\Models\ValueObjects\Employees\ArcadiaEmployeeId;
|
||||
use Domain\Models\ValueObjects\Employees\SiRhMatricule;
|
||||
|
||||
final readonly class EmployeeShowView
|
||||
{
|
||||
public function __construct(
|
||||
public ArcadiaEmployeeId $id,
|
||||
public SiRhMatricule $id,
|
||||
public string $firstName,
|
||||
public string $lastName,
|
||||
public string $establishment,
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ describe('Employee Show Feature API', function (): void {
|
|||
$response->assertStatus(200);
|
||||
$response->assertJson([
|
||||
'employee' => [
|
||||
'id' => $employeeNumber,
|
||||
'matricule' => $employeeNumber,
|
||||
'lastName' => 'DUPONT',
|
||||
'firstName' => 'Jean',
|
||||
],
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ describe('Employees Index Feature API', function (): void {
|
|||
// THEN
|
||||
$response->assertStatus(200);
|
||||
$response->assertJsonCount(1, 'employees');
|
||||
$response->assertJsonPath('employees.0.id', '01155902');
|
||||
$response->assertJsonPath('employees.0.matricule', '01155902');
|
||||
});
|
||||
|
||||
it('returns 200 OK and filters results for siteIds array query filter', function (): void {
|
||||
|
|
@ -185,7 +185,7 @@ describe('Employees Index Feature API', function (): void {
|
|||
// THEN
|
||||
$response->assertStatus(200);
|
||||
$response->assertJsonCount(1, 'employees');
|
||||
$response->assertJsonPath('employees.0.id', '01155902');
|
||||
$response->assertJsonPath('employees.0.matricule', '01155902');
|
||||
$response->assertJsonPath('pagination.totalItems', 1);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ declare(strict_types=1);
|
|||
namespace Tests\Support\Mothers;
|
||||
|
||||
use Domain\Models\Entities\Employee;
|
||||
use Domain\Models\ValueObjects\Employees\ArcadiaEmployeeId;
|
||||
use Domain\Models\ValueObjects\Employees\SiRhMatricule;
|
||||
use Domain\Models\ValueObjects\EstablishmentCode;
|
||||
use Domain\Models\ValueObjects\ServiceId;
|
||||
use Domain\Models\ValueObjects\SiteId;
|
||||
|
|
@ -18,7 +18,7 @@ final class EmployeeMother
|
|||
?string $firstName = null,
|
||||
): Employee {
|
||||
return Employee::hydrate(
|
||||
publicEmployeeNumber: new ArcadiaEmployeeId($employeeNumber ?? '1234567'),
|
||||
publicEmployeeNumber: new SiRhMatricule($employeeNumber ?? '1234567'),
|
||||
lastName: $lastName ?? 'Dupont',
|
||||
firstName: $firstName ?? 'Jean',
|
||||
startDate: new \DateTimeImmutable('2024-01-01'),
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ declare(strict_types=1);
|
|||
namespace Tests\Unit\Application\Arcadia\Exceptions;
|
||||
|
||||
use Application\Arcadia\Exceptions\EmployeeNotFoundException;
|
||||
use Domain\Models\ValueObjects\Employees\ArcadiaEmployeeId;
|
||||
use Domain\Models\ValueObjects\Employees\SiRhMatricule;
|
||||
use Shared\DDD\Exception\NotFoundException;
|
||||
|
||||
covers(EmployeeNotFoundException::class);
|
||||
|
|
@ -13,7 +13,7 @@ covers(EmployeeNotFoundException::class);
|
|||
describe('EmployeeNotFoundException Unit Tests', function (): void {
|
||||
it('creates exception from value object', function (): void {
|
||||
// GIVEN
|
||||
$id = new ArcadiaEmployeeId('01155902');
|
||||
$id = new SiRhMatricule('01155902');
|
||||
|
||||
// WHEN
|
||||
$exception = EmployeeNotFoundException::forEmployee($id);
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ use Application\Arcadia\Usecase\Employees\FindAll\Input;
|
|||
use Application\Arcadia\Usecase\Employees\FindAll\Output;
|
||||
use Application\Arcadia\Usecase\Employees\FindAll\PaginatedEmployee;
|
||||
use Domain\Models\Entities\Employee;
|
||||
use Domain\Models\ValueObjects\Employees\ArcadiaEmployeeId;
|
||||
use Domain\Models\ValueObjects\Employees\SiRhMatricule;
|
||||
use Domain\Models\ValueObjects\Employees\EmployeeSortColumn;
|
||||
use Domain\Models\ValueObjects\Employees\EmployeeSorter;
|
||||
use Domain\Models\ValueObjects\EstablishmentCode;
|
||||
|
|
@ -34,7 +34,7 @@ describe('FindAllEmployees Usecase Unit Tests', function (): void {
|
|||
|
||||
it('executes successfully and returns paginated output DTO', function () use ($directory): void {
|
||||
// GIVEN
|
||||
$employeeId = new ArcadiaEmployeeId('01155902');
|
||||
$employeeId = new SiRhMatricule('01155902');
|
||||
$employee = Employee::hydrate(
|
||||
publicEmployeeNumber: $employeeId,
|
||||
lastName: 'DOE',
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ use Application\Arcadia\Usecase\Employees\Find\FindEmployee;
|
|||
use Application\Arcadia\Usecase\Employees\Find\Input;
|
||||
use Application\Arcadia\Usecase\Employees\Find\Output;
|
||||
use Domain\Models\Entities\Employee;
|
||||
use Domain\Models\ValueObjects\Employees\ArcadiaEmployeeId;
|
||||
use Domain\Models\ValueObjects\Employees\SiRhMatricule;
|
||||
use Domain\Models\ValueObjects\EstablishmentCode;
|
||||
use Domain\Models\ValueObjects\ServiceId;
|
||||
use Domain\Models\ValueObjects\SiteId;
|
||||
|
|
@ -30,7 +30,7 @@ describe('FindEmployee Usecase Unit Tests', function (): void {
|
|||
|
||||
it('executes successfully and returns Output when employee exists', function () use ($directory): void {
|
||||
// GIVEN
|
||||
$employeeId = new ArcadiaEmployeeId('01155902');
|
||||
$employeeId = new SiRhMatricule('01155902');
|
||||
$employee = Employee::hydrate(
|
||||
publicEmployeeNumber: $employeeId,
|
||||
lastName: 'DOE',
|
||||
|
|
@ -64,7 +64,7 @@ describe('FindEmployee Usecase Unit Tests', function (): void {
|
|||
|
||||
it('throws NotFoundException when employee does not exist', function () use ($directory): void {
|
||||
// GIVEN
|
||||
$employeeId = new ArcadiaEmployeeId('01155902');
|
||||
$employeeId = new SiRhMatricule('01155902');
|
||||
$usecase = new FindEmployee($directory);
|
||||
$input = new Input($employeeId);
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ declare(strict_types=1);
|
|||
namespace Tests\Unit\Domain\Entities;
|
||||
|
||||
use Domain\Models\Entities\Employee;
|
||||
use Domain\Models\ValueObjects\Employees\ArcadiaEmployeeId;
|
||||
use Domain\Models\ValueObjects\Employees\SiRhMatricule;
|
||||
use Domain\Models\ValueObjects\EstablishmentCode;
|
||||
use Domain\Models\ValueObjects\ServiceId;
|
||||
use Domain\Models\ValueObjects\SiteId;
|
||||
|
|
@ -15,7 +15,7 @@ covers(Employee::class);
|
|||
describe('Employee Entity', function (): void {
|
||||
it('can be instantiated and exposes its id', function (): void {
|
||||
// GIVEN
|
||||
$id = new ArcadiaEmployeeId('12345678');
|
||||
$id = new SiRhMatricule('12345678');
|
||||
$now = new \DateTimeImmutable();
|
||||
|
||||
// WHEN
|
||||
|
|
|
|||
|
|
@ -4,22 +4,22 @@ declare(strict_types=1);
|
|||
|
||||
namespace Tests\Unit\Domain;
|
||||
|
||||
use Domain\Models\ValueObjects\Employees\ArcadiaEmployeeId;
|
||||
use Domain\Models\ValueObjects\Employees\SiRhMatricule;
|
||||
|
||||
covers(ArcadiaEmployeeId::class);
|
||||
covers(SiRhMatricule::class);
|
||||
|
||||
describe('ArcadiaEmployeeId Value Object Instantiation', function (): void {
|
||||
describe('SiRhMatricule Value Object Instantiation', function (): void {
|
||||
it('instantiates successfully with a valid 7-digit matricule', function (): void {
|
||||
// GIVEN
|
||||
$validMatricule = '0115590';
|
||||
|
||||
// WHEN
|
||||
$employeeId = new ArcadiaEmployeeId($validMatricule);
|
||||
$matricule = new SiRhMatricule($validMatricule);
|
||||
|
||||
// THEN
|
||||
expect($employeeId->value)
|
||||
expect($matricule->value)
|
||||
->toBe('0115590')
|
||||
->and((string) $employeeId)->toBe('0115590');
|
||||
->and((string) $matricule)->toBe('0115590');
|
||||
});
|
||||
|
||||
it('instantiates successfully with a valid 8-digit matricule', function (): void {
|
||||
|
|
@ -27,19 +27,19 @@ describe('ArcadiaEmployeeId Value Object Instantiation', function (): void {
|
|||
$validMatricule = '01155902';
|
||||
|
||||
// WHEN
|
||||
$employeeId = new ArcadiaEmployeeId($validMatricule);
|
||||
$matricule = new SiRhMatricule($validMatricule);
|
||||
|
||||
// THEN
|
||||
expect($employeeId->value)
|
||||
expect($matricule->value)
|
||||
->toBe('01155902')
|
||||
->and((string) $employeeId)->toBe('01155902');
|
||||
->and((string) $matricule)->toBe('01155902');
|
||||
});
|
||||
|
||||
it('supports equality check with another ArcadiaEmployeeId instance', function (): void {
|
||||
it('supports equality check with another SiRhMatricule instance', function (): void {
|
||||
// GIVEN
|
||||
$firstId = new ArcadiaEmployeeId('01155902');
|
||||
$sameId = new ArcadiaEmployeeId('01155902');
|
||||
$differentId = new ArcadiaEmployeeId('01155901');
|
||||
$firstId = new SiRhMatricule('01155902');
|
||||
$sameId = new SiRhMatricule('01155902');
|
||||
$differentId = new SiRhMatricule('01155901');
|
||||
|
||||
// WHEN & THEN
|
||||
expect($firstId->equals($sameId))
|
||||
|
|
@ -50,19 +50,19 @@ describe('ArcadiaEmployeeId Value Object Instantiation', function (): void {
|
|||
|
||||
it('can be converted to a string representation', function (): void {
|
||||
// GIVEN
|
||||
$employeeId = new ArcadiaEmployeeId('01155902');
|
||||
$matricule = new SiRhMatricule('01155902');
|
||||
|
||||
// WHEN
|
||||
$stringRepresentation = (string) $employeeId;
|
||||
$stringRepresentation = (string) $matricule;
|
||||
|
||||
// THEN
|
||||
expect($stringRepresentation)->toBe('01155902');
|
||||
});
|
||||
});
|
||||
|
||||
describe('ArcadiaEmployeeId Value Object Domain Rules', function (): void {
|
||||
describe('SiRhMatricule Value Object Domain Rules', function (): void {
|
||||
it('throws a DomainException when given an invalid matricule pattern', function (string $invalidMatricule): void {
|
||||
expect(fn () => new ArcadiaEmployeeId($invalidMatricule))
|
||||
expect(fn () => new SiRhMatricule($invalidMatricule))
|
||||
->toThrow(\DomainException::class);
|
||||
})->with([
|
||||
'too short' => '12345',
|
||||
|
|
@ -5,7 +5,7 @@ declare(strict_types=1);
|
|||
namespace Tests\Unit\Infra\Adapters\Directories;
|
||||
|
||||
use Domain\Models\Entities\Employee;
|
||||
use Domain\Models\ValueObjects\Employees\ArcadiaEmployeeId;
|
||||
use Domain\Models\ValueObjects\Employees\SiRhMatricule;
|
||||
use Domain\Models\ValueObjects\Employees\EmployeeFilter;
|
||||
use Domain\Models\ValueObjects\Employees\EmployeeSortColumn;
|
||||
use Domain\Models\ValueObjects\Employees\EmployeeSorter;
|
||||
|
|
@ -21,7 +21,7 @@ describe('InMemoryEmployeeDirectory Unit Tests', function (): void {
|
|||
it('finds an employee by id or returns null if not found', function (): void {
|
||||
// GIVEN
|
||||
$directory = new InMemoryEmployeeDirectory();
|
||||
$employeeId = new ArcadiaEmployeeId('01155902');
|
||||
$employeeId = new SiRhMatricule('01155902');
|
||||
$employee = Employee::hydrate(
|
||||
publicEmployeeNumber: $employeeId,
|
||||
lastName: 'DOE',
|
||||
|
|
@ -40,7 +40,7 @@ describe('InMemoryEmployeeDirectory Unit Tests', function (): void {
|
|||
|
||||
// WHEN
|
||||
$found = $directory->find($employeeId);
|
||||
$missing = $directory->find(new ArcadiaEmployeeId('99999999'));
|
||||
$missing = $directory->find(new SiRhMatricule('99999999'));
|
||||
|
||||
// THEN
|
||||
expect($found)->toBe($employee)
|
||||
|
|
@ -52,7 +52,7 @@ describe('InMemoryEmployeeDirectory Unit Tests', function (): void {
|
|||
$directory = new InMemoryEmployeeDirectory();
|
||||
|
||||
$emp1 = Employee::hydrate(
|
||||
publicEmployeeNumber: new ArcadiaEmployeeId('00000001'),
|
||||
publicEmployeeNumber: new SiRhMatricule('00000001'),
|
||||
lastName: 'ALICE',
|
||||
firstName: 'A',
|
||||
startDate: new \DateTimeImmutable('2024-01-01'),
|
||||
|
|
@ -66,7 +66,7 @@ describe('InMemoryEmployeeDirectory Unit Tests', function (): void {
|
|||
);
|
||||
|
||||
$emp2 = Employee::hydrate(
|
||||
publicEmployeeNumber: new ArcadiaEmployeeId('00000002'),
|
||||
publicEmployeeNumber: new SiRhMatricule('00000002'),
|
||||
lastName: 'BOB',
|
||||
firstName: 'B',
|
||||
startDate: new \DateTimeImmutable('2024-02-01'),
|
||||
|
|
@ -99,7 +99,7 @@ describe('InMemoryEmployeeDirectory Unit Tests', function (): void {
|
|||
$directory = new InMemoryEmployeeDirectory();
|
||||
|
||||
$emp1 = Employee::hydrate(
|
||||
publicEmployeeNumber: new ArcadiaEmployeeId('00000001'),
|
||||
publicEmployeeNumber: new SiRhMatricule('00000001'),
|
||||
lastName: 'ALICE',
|
||||
firstName: 'A',
|
||||
startDate: new \DateTimeImmutable('2023-01-01'),
|
||||
|
|
@ -113,7 +113,7 @@ describe('InMemoryEmployeeDirectory Unit Tests', function (): void {
|
|||
);
|
||||
|
||||
$emp2 = Employee::hydrate(
|
||||
publicEmployeeNumber: new ArcadiaEmployeeId('00000002'),
|
||||
publicEmployeeNumber: new SiRhMatricule('00000002'),
|
||||
lastName: 'BOB',
|
||||
firstName: 'B',
|
||||
startDate: new \DateTimeImmutable('2023-01-01'),
|
||||
|
|
@ -127,7 +127,7 @@ describe('InMemoryEmployeeDirectory Unit Tests', function (): void {
|
|||
);
|
||||
|
||||
$emp3 = Employee::hydrate(
|
||||
publicEmployeeNumber: new ArcadiaEmployeeId('00000003'),
|
||||
publicEmployeeNumber: new SiRhMatricule('00000003'),
|
||||
lastName: 'CHARLIE',
|
||||
firstName: 'C',
|
||||
startDate: new \DateTimeImmutable('2024-06-01'),
|
||||
|
|
@ -159,7 +159,7 @@ describe('InMemoryEmployeeDirectory Unit Tests', function (): void {
|
|||
it('clears all stored employees', function (): void {
|
||||
// GIVEN
|
||||
$directory = new InMemoryEmployeeDirectory();
|
||||
$employeeId = new ArcadiaEmployeeId('01155902');
|
||||
$employeeId = new SiRhMatricule('01155902');
|
||||
$employee = Employee::hydrate(
|
||||
publicEmployeeNumber: $employeeId,
|
||||
lastName: 'DOE',
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ declare(strict_types=1);
|
|||
namespace Tests\Unit\Presentation\Api\V1\Presenters\Employees;
|
||||
|
||||
use Application\Arcadia\Usecase\Employees\Find\Output;
|
||||
use Domain\Models\ValueObjects\Employees\ArcadiaEmployeeId;
|
||||
use Domain\Models\ValueObjects\Employees\SiRhMatricule;
|
||||
use Presentation\Api\V1\Presenters\Employees\EmployeeShowPresenter;
|
||||
use Presentation\Api\V1\Presenters\Employees\EmployeeShowView;
|
||||
|
||||
|
|
@ -17,7 +17,7 @@ covers(
|
|||
describe('EmployeeShowPresenter Unit Tests', function (): void {
|
||||
it('transforms Output into EmployeeShowView', function (): void {
|
||||
// GIVEN
|
||||
$id = new ArcadiaEmployeeId('1234567');
|
||||
$id = new SiRhMatricule('1234567');
|
||||
$startDate = new \DateTimeImmutable('2024-01-01');
|
||||
$endDate = new \DateTimeImmutable('2024-12-31');
|
||||
$plannedEndDate = new \DateTimeImmutable('2025-06-30');
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ namespace Tests\Unit\Presentation\Api\V1\Presenters\Employees;
|
|||
|
||||
use Application\Arcadia\Usecase\Employees\FindAll\Output;
|
||||
use Application\Arcadia\Usecase\Employees\FindAll\PaginatedEmployee;
|
||||
use Domain\Models\ValueObjects\Employees\ArcadiaEmployeeId;
|
||||
use Domain\Models\ValueObjects\Employees\SiRhMatricule;
|
||||
use Presentation\Api\V1\Presenters\Employees\EmployeesIndexPresenter;
|
||||
use Presentation\Api\V1\Presenters\Employees\EmployeesIndexView;
|
||||
|
||||
|
|
@ -19,7 +19,7 @@ describe('EmployeesIndexPresenter Unit Tests', function (): void {
|
|||
it('transforms Output into EmployeesIndexView', function (): void {
|
||||
// GIVEN
|
||||
$employee = new PaginatedEmployee(
|
||||
id: new ArcadiaEmployeeId('1234567'),
|
||||
id: new SiRhMatricule('1234567'),
|
||||
firstName: 'Jean',
|
||||
lastName: 'DUPONT',
|
||||
establishment: '01',
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue