This commit refactors the import statements in various controllers and jobs to improve code organization and readability. Unused imports were removed, and necessary imports were added to ensure proper functionality.
44 lines
1.5 KiB
PHP
44 lines
1.5 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use App\Services\EmployeeCsvImportLine;
|
|
|
|
describe('EmployeeCsvImportLine', function (): void {
|
|
it('parses dates and normalizes service code', function (): void {
|
|
// GIVEN
|
|
$line = new EmployeeCsvImportLine();
|
|
|
|
// WHEN
|
|
$line->setStartDate('01/10/2026');
|
|
$line->setEndDate('');
|
|
$line->setExpectedEndDate('15/10/2026');
|
|
$line->setService('LDCCAV030');
|
|
|
|
// THEN
|
|
expect($line->startDate)->toBeInstanceOf(\DateTimeImmutable::class)
|
|
->and($line->startDate->format('Y-m-d'))->toBe('2026-10-01')
|
|
->and($line->endDate)->toBeNull()
|
|
->and($line->expectedEndDate)->toBeInstanceOf(\DateTimeImmutable::class)
|
|
->and($line->expectedEndDate?->format('Y-m-d'))->toBe('2026-10-15')
|
|
->and($line->service)->toBe('030');
|
|
});
|
|
|
|
it('throws when mandatory start date has invalid format', function (): void {
|
|
// GIVEN
|
|
$line = new EmployeeCsvImportLine();
|
|
|
|
// WHEN + THEN
|
|
expect(fn () => $line->setStartDate('2026-10-01'))
|
|
->toThrow(\InvalidArgumentException::class, 'Invalid date format: 2026-10-01');
|
|
});
|
|
|
|
it('throws when optional end date has invalid format', function (): void {
|
|
// GIVEN
|
|
$line = new EmployeeCsvImportLine();
|
|
|
|
// WHEN + THEN
|
|
expect(fn () => $line->setEndDate('31-12-2026'))
|
|
->toThrow(\InvalidArgumentException::class, 'Invalid date format: 31-12-2026');
|
|
});
|
|
});
|