employee_sites = ['PA', 'LY']; $setting->saveOrFail(); $logger = new NullLogger(); $codeService = new CodeGenerationService(new SerialCasterBuilder(new NativeBaseConverter())); $storageService = \Mockery::mock(EmployeeImportStorageService::class); $employee = new ArcadiaEmployee( matricule: new Matricule('1234567'), lastname: 'Dupont', firstname: 'Jean', startDate: CarbonImmutable::parse('2026-01-01'), endDate: null, etablissement: new ShopperEstablishmentCode('ETAB'), site: new ShopperSiteCode('PA'), service: new ShopperServiceCode('101') ); $storageService->shouldReceive('upsertEmployees') ->once() ->with(\Mockery::on(static function (array $data): bool { return count($data) === 1 && is_object($data[0]) && isset($data[0]->matricule) && $data[0]->matricule instanceof Matricule && $data[0]->matricule->value === '1234567'; })); $storageService->shouldReceive('getImportedAfter') ->once() ->andReturn((object) [ 'insertedCount' => 1, 'updatedCount' => 0, 'matriculesInserted' => [new Matricule('1234567')], ]); $service = new EmployeeUpsertService( $logger, $codeService, $storageService, ); // WHEN $result = $service->upsertEmployees([$employee]); // THEN expect($result->insertedCount)->toBe(1) ->and($result->updatedCount)->toBe(0); }); });