2026-06-14 21:32:07 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
|
|
namespace Tests\Unit\Domain\Models\ValueObjects;
|
|
|
|
|
|
2026-11-16 15:49:48 +01:00
|
|
|
use Carbon\Carbon;
|
2026-06-14 21:32:07 +02:00
|
|
|
use Carbon\CarbonImmutable;
|
|
|
|
|
use Domain\Models\ValueObjects\Code;
|
|
|
|
|
use Domain\Models\ValueObjects\EmployeeUpsertData;
|
|
|
|
|
use Domain\Models\ValueObjects\Matricule;
|
2026-10-02 12:14:48 +02:00
|
|
|
use Domain\Models\ValueObjects\ShopperEstablishmentCode;
|
|
|
|
|
use Domain\Models\ValueObjects\ShopperServiceCode;
|
|
|
|
|
use Domain\Models\ValueObjects\ShopperSiteCode;
|
2026-06-14 21:32:07 +02:00
|
|
|
|
2026-11-16 15:49:48 +01:00
|
|
|
beforeEach(function (): void {
|
|
|
|
|
$now = CarbonImmutable::parse('2026-06-15 10:00:00', 'Europe/Paris');
|
|
|
|
|
CarbonImmutable::setTestNow($now);
|
|
|
|
|
Carbon::setTestNow($now);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
afterEach(function (): void {
|
|
|
|
|
CarbonImmutable::setTestNow();
|
|
|
|
|
Carbon::setTestNow();
|
|
|
|
|
});
|
|
|
|
|
|
2026-06-14 21:32:07 +02:00
|
|
|
describe('EmployeeUpsertData', function (): void {
|
|
|
|
|
it('can be instantiated', function (): void {
|
|
|
|
|
// GIVEN
|
2026-10-02 12:14:48 +02:00
|
|
|
$matricule = new Matricule('1234567');
|
|
|
|
|
$code = new Code('ABCDEFGH12');
|
|
|
|
|
$start = CarbonImmutable::now();
|
|
|
|
|
$etablissement = new ShopperEstablishmentCode('ETAB01');
|
|
|
|
|
$service = new ShopperServiceCode('101');
|
|
|
|
|
$site = new ShopperSiteCode('SITEA');
|
|
|
|
|
|
2026-06-14 21:32:07 +02:00
|
|
|
// WHEN
|
|
|
|
|
$data = new EmployeeUpsertData(
|
|
|
|
|
$matricule,
|
|
|
|
|
'Jean',
|
2026-10-02 12:14:48 +02:00
|
|
|
'Dupont',
|
|
|
|
|
$etablissement,
|
|
|
|
|
$service,
|
|
|
|
|
$site,
|
2026-06-14 21:32:07 +02:00
|
|
|
$start,
|
|
|
|
|
null,
|
|
|
|
|
$code
|
|
|
|
|
);
|
2026-10-02 12:14:48 +02:00
|
|
|
|
2026-06-14 21:32:07 +02:00
|
|
|
// THEN
|
|
|
|
|
expect($data->matricule)->toBe($matricule)
|
2026-10-02 12:14:48 +02:00
|
|
|
->and($data->firstname)->toBe('Jean')
|
|
|
|
|
->and($data->lastname)->toBe('Dupont')
|
|
|
|
|
->and($data->etablissement)->toBe($etablissement)
|
|
|
|
|
->and($data->service)->toBe($service)
|
|
|
|
|
->and($data->site)->toBe($site)
|
2026-06-14 21:32:07 +02:00
|
|
|
->and($data->startDate)->toBe($start)
|
|
|
|
|
->and($data->endDate)->toBeNull()
|
|
|
|
|
->and($data->code)->toBe($code);
|
|
|
|
|
});
|
|
|
|
|
});
|