toHaveKeys([ShouldQueue::class, ShouldBeUnique::class]) ->and($job->uniqueFor)->toBe(3600) ->and($job->uniqueId())->toBe('fetch-and-upsert-arcadia-employees'); }); it('executes SynchronizeEmployeesWithArcadiaApi via Executor in handle', function (): void { // GIVEN /** @var Executor&\Mockery\MockInterface $executor */ $executor = \Mockery::mock(Executor::class); /** @var EmployeeSyncService&\Mockery\MockInterface $syncService */ $syncService = \Mockery::mock(EmployeeSyncService::class); $action = new SynchronizeEmployeesWithArcadiaApi($syncService); $job = new FetchAndUpsertArcadiaEmployees(); $executor->shouldReceive('execute') ->once() ->with($action, \Mockery::type(ActionInputEmpty::class)); // WHEN $job->handle($executor, $action); // THEN expect(\Mockery::getContainer()->mockery_getExpectationCount())->toBeGreaterThan(0); }); it('synchronizes employees via dispatchSync using mocked ArcadiaEmployeeService', function (): void { // GIVEN $setting = Setting::getSingleton(); $setting->employee_sites = ['PA']; $setting->saveOrFail(); $arcadiaEmployee = new ArcadiaEmployee( matricule: new Matricule('9123456'), lastname: 'Martin', firstname: 'Alice', startDate: CarbonImmutable::parse('2026-01-01'), endDate: null, etablissement: new ShopperEstablishmentCode('01'), site: new ShopperSiteCode('PA'), service: new ShopperServiceCode('01'), ); /** @var ArcadiaEmployeeService&\Mockery\MockInterface $arcadiaService */ $arcadiaService = \Mockery::mock(ArcadiaEmployeeService::class); $arcadiaService->shouldReceive('getEmployeesOfSiteSince') ->once() ->with(\Mockery::on(static fn (ShopperSiteCode $s): bool => $s->value === 'PA'), \Mockery::any()) ->andReturn([$arcadiaEmployee]); app()->instance(ArcadiaEmployeeService::class, $arcadiaService); // WHEN FetchAndUpsertArcadiaEmployees::dispatchSync(); // THEN $employee = Employee::query()->where('matricule', '9123456')->first(); expect($employee)->not->toBeNull() ->and($employee?->nom)->toBe('Martin') ->and($employee?->prenom)->toBe('Alice'); }); });