clear(); }); it('executes successfully and returns Output when employee exists', function () use ($directory): void { // GIVEN $employeeId = new SiRhMatricule('01155902'); $employee = Employee::hydrate( publicEmployeeNumber: $employeeId, lastName: 'DOE', firstName: 'John', startDate: new \DateTimeImmutable('2024-01-01'), endDate: null, plannedEndDate: null, establishment: new EstablishmentCode('EST01'), site: new SiteId('LDCSER'), service: new ServiceId('097'), createdAt: new \DateTimeImmutable('2024-01-01'), updatedAt: null, ); $directory->add($employee); $usecase = new FindEmployee($directory); $input = new Input($employeeId); // WHEN $result = $usecase->execute($input); // THEN expect($result)->toBeInstanceOf(Output::class) ->and($result->id)->toBe($employeeId) ->and($result->firstName)->toBe('John') ->and($result->lastName)->toBe('DOE') ->and($result->establishment)->toBe('EST01') ->and($result->site)->toBe('LDCSER') ->and($result->service)->toBe('097'); }); it('throws NotFoundException when employee does not exist', function () use ($directory): void { // GIVEN $employeeId = new SiRhMatricule('01155902'); $usecase = new FindEmployee($directory); $input = new Input($employeeId); // WHEN $execution = fn () => $usecase->execute($input); // THEN expect($execution)->toThrow(EmployeeNotFoundException::class, "Employee '01155902' not found."); }); });