feat(employees): automated sync with Arcadia API, BO settings, Shopper value objects, and pagination migration
- Implement automated synchronization of employees via Arcadia API (EmployeeSyncService, SynchronizeEmployeesWithArcadiaApi, FetchAndUpsertArcadiaEmployees)
- Add Back-Office application settings for employee sites (Setting singleton, GetSettingsQuery, UpdateSettings, SettingsController, EmployeeSitesInputComponent.vue)
- Strongly type Employee attributes using Domain Value Objects (ShopperEstablishmentCode, ShopperSiteCode, ShopperServiceCode) and Eloquent Casts
- Migrate pagination from Domain to Shared\Pagination namespace across queries and inputs
- Remove legacy and dead CSV employee import/export code
- Restore Domain\Ports\Services\CsvGenerator interface for Regate order generation
- Add comprehensive Pest unit, integration, and feature test coverage
2026-10-01 17:26:30 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
|
|
use App\Models\Setting;
|
|
|
|
|
use App\Queries\Settings\GetSettingsQuery;
|
|
|
|
|
use App\Services\ArcadiaEmployee;
|
|
|
|
|
use App\Services\ArcadiaEmployeeService;
|
2026-10-02 14:35:20 +02:00
|
|
|
use App\Services\CodeGenerationService;
|
feat(employees): automated sync with Arcadia API, BO settings, Shopper value objects, and pagination migration
- Implement automated synchronization of employees via Arcadia API (EmployeeSyncService, SynchronizeEmployeesWithArcadiaApi, FetchAndUpsertArcadiaEmployees)
- Add Back-Office application settings for employee sites (Setting singleton, GetSettingsQuery, UpdateSettings, SettingsController, EmployeeSitesInputComponent.vue)
- Strongly type Employee attributes using Domain Value Objects (ShopperEstablishmentCode, ShopperSiteCode, ShopperServiceCode) and Eloquent Casts
- Migrate pagination from Domain to Shared\Pagination namespace across queries and inputs
- Remove legacy and dead CSV employee import/export code
- Restore Domain\Ports\Services\CsvGenerator interface for Regate order generation
- Add comprehensive Pest unit, integration, and feature test coverage
2026-10-01 17:26:30 +02:00
|
|
|
use App\Services\EmployeeSyncService;
|
|
|
|
|
use Carbon\CarbonImmutable;
|
|
|
|
|
use Domain\Models\ValueObjects\Matricule;
|
|
|
|
|
use Domain\Models\ValueObjects\ShopperEstablishmentCode;
|
|
|
|
|
use Domain\Models\ValueObjects\ShopperServiceCode;
|
|
|
|
|
use Domain\Models\ValueObjects\ShopperSiteCode;
|
|
|
|
|
use Domain\Ports\Services\EmployeeImportStorageService;
|
|
|
|
|
use Illuminate\Contracts\Cache\Repository as CacheRepository;
|
|
|
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
2026-10-06 17:05:43 +02:00
|
|
|
use Psr\Log\LoggerInterface;
|
feat(employees): automated sync with Arcadia API, BO settings, Shopper value objects, and pagination migration
- Implement automated synchronization of employees via Arcadia API (EmployeeSyncService, SynchronizeEmployeesWithArcadiaApi, FetchAndUpsertArcadiaEmployees)
- Add Back-Office application settings for employee sites (Setting singleton, GetSettingsQuery, UpdateSettings, SettingsController, EmployeeSitesInputComponent.vue)
- Strongly type Employee attributes using Domain Value Objects (ShopperEstablishmentCode, ShopperSiteCode, ShopperServiceCode) and Eloquent Casts
- Migrate pagination from Domain to Shared\Pagination namespace across queries and inputs
- Remove legacy and dead CSV employee import/export code
- Restore Domain\Ports\Services\CsvGenerator interface for Regate order generation
- Add comprehensive Pest unit, integration, and feature test coverage
2026-10-01 17:26:30 +02:00
|
|
|
|
|
|
|
|
uses(RefreshDatabase::class);
|
|
|
|
|
|
|
|
|
|
afterEach(function (): void {
|
|
|
|
|
\Mockery::close();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
describe('EmployeeSyncService', function (): void {
|
|
|
|
|
it('fetches employees for sites configured in settings when sites parameter is null and upserts them', function (): void {
|
|
|
|
|
// GIVEN
|
|
|
|
|
$setting = Setting::getSingleton();
|
|
|
|
|
$setting->employee_sites = ['PA', 'LY'];
|
|
|
|
|
$setting->saveOrFail();
|
|
|
|
|
|
2026-10-06 17:05:43 +02:00
|
|
|
$logger = app(LoggerInterface::class);
|
feat(employees): automated sync with Arcadia API, BO settings, Shopper value objects, and pagination migration
- Implement automated synchronization of employees via Arcadia API (EmployeeSyncService, SynchronizeEmployeesWithArcadiaApi, FetchAndUpsertArcadiaEmployees)
- Add Back-Office application settings for employee sites (Setting singleton, GetSettingsQuery, UpdateSettings, SettingsController, EmployeeSitesInputComponent.vue)
- Strongly type Employee attributes using Domain Value Objects (ShopperEstablishmentCode, ShopperSiteCode, ShopperServiceCode) and Eloquent Casts
- Migrate pagination from Domain to Shared\Pagination namespace across queries and inputs
- Remove legacy and dead CSV employee import/export code
- Restore Domain\Ports\Services\CsvGenerator interface for Regate order generation
- Add comprehensive Pest unit, integration, and feature test coverage
2026-10-01 17:26:30 +02:00
|
|
|
$cache = app(CacheRepository::class);
|
|
|
|
|
$codeService = app(CodeGenerationService::class);
|
|
|
|
|
$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 && $data[0]->matricule->value === '1234567';
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
$storageService->shouldReceive('getImportedAfter')
|
|
|
|
|
->once()
|
|
|
|
|
->andReturn((object) [
|
|
|
|
|
'insertedCount' => 1,
|
|
|
|
|
'updatedCount' => 0,
|
|
|
|
|
'matriculesInserted' => [new Matricule('1234567')],
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$arcadiaService = \Mockery::mock(ArcadiaEmployeeService::class);
|
|
|
|
|
$arcadiaService->shouldReceive('getEmployeesOfSiteSince')
|
|
|
|
|
->once()
|
|
|
|
|
->with(\Mockery::on(static fn (ShopperSiteCode $code): bool => $code->value === 'PA'), \Mockery::any())
|
|
|
|
|
->andReturn([$employee]);
|
|
|
|
|
$arcadiaService->shouldReceive('getEmployeesOfSiteSince')
|
|
|
|
|
->once()
|
|
|
|
|
->with(\Mockery::on(static fn (ShopperSiteCode $code): bool => $code->value === 'LY'), \Mockery::any())
|
|
|
|
|
->andReturn([]);
|
|
|
|
|
|
|
|
|
|
$service = new EmployeeSyncService(
|
2026-10-06 17:05:43 +02:00
|
|
|
$logger,
|
feat(employees): automated sync with Arcadia API, BO settings, Shopper value objects, and pagination migration
- Implement automated synchronization of employees via Arcadia API (EmployeeSyncService, SynchronizeEmployeesWithArcadiaApi, FetchAndUpsertArcadiaEmployees)
- Add Back-Office application settings for employee sites (Setting singleton, GetSettingsQuery, UpdateSettings, SettingsController, EmployeeSitesInputComponent.vue)
- Strongly type Employee attributes using Domain Value Objects (ShopperEstablishmentCode, ShopperSiteCode, ShopperServiceCode) and Eloquent Casts
- Migrate pagination from Domain to Shared\Pagination namespace across queries and inputs
- Remove legacy and dead CSV employee import/export code
- Restore Domain\Ports\Services\CsvGenerator interface for Regate order generation
- Add comprehensive Pest unit, integration, and feature test coverage
2026-10-01 17:26:30 +02:00
|
|
|
$cache,
|
|
|
|
|
$arcadiaService,
|
|
|
|
|
$codeService,
|
|
|
|
|
$storageService,
|
|
|
|
|
app(GetSettingsQuery::class)
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// WHEN
|
|
|
|
|
$service->synchronize();
|
|
|
|
|
|
|
|
|
|
// THEN
|
|
|
|
|
expect($service->getLastSync())->not->toBeNull();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('can use explicitly provided sites instead of settings', function (): void {
|
|
|
|
|
// GIVEN
|
2026-10-06 17:05:43 +02:00
|
|
|
$logger = app(LoggerInterface::class);
|
feat(employees): automated sync with Arcadia API, BO settings, Shopper value objects, and pagination migration
- Implement automated synchronization of employees via Arcadia API (EmployeeSyncService, SynchronizeEmployeesWithArcadiaApi, FetchAndUpsertArcadiaEmployees)
- Add Back-Office application settings for employee sites (Setting singleton, GetSettingsQuery, UpdateSettings, SettingsController, EmployeeSitesInputComponent.vue)
- Strongly type Employee attributes using Domain Value Objects (ShopperEstablishmentCode, ShopperSiteCode, ShopperServiceCode) and Eloquent Casts
- Migrate pagination from Domain to Shared\Pagination namespace across queries and inputs
- Remove legacy and dead CSV employee import/export code
- Restore Domain\Ports\Services\CsvGenerator interface for Regate order generation
- Add comprehensive Pest unit, integration, and feature test coverage
2026-10-01 17:26:30 +02:00
|
|
|
$cache = app(CacheRepository::class);
|
|
|
|
|
$codeService = app(CodeGenerationService::class);
|
|
|
|
|
$storageService = \Mockery::mock(EmployeeImportStorageService::class);
|
|
|
|
|
|
|
|
|
|
$arcadiaService = \Mockery::mock(ArcadiaEmployeeService::class);
|
|
|
|
|
$arcadiaService->shouldReceive('getEmployeesOfSiteSince')
|
|
|
|
|
->once()
|
|
|
|
|
->with(\Mockery::on(static fn (ShopperSiteCode $code): bool => $code->value === 'BO'), \Mockery::any())
|
|
|
|
|
->andReturn([]);
|
|
|
|
|
|
|
|
|
|
$service = new EmployeeSyncService(
|
2026-10-06 17:05:43 +02:00
|
|
|
$logger,
|
feat(employees): automated sync with Arcadia API, BO settings, Shopper value objects, and pagination migration
- Implement automated synchronization of employees via Arcadia API (EmployeeSyncService, SynchronizeEmployeesWithArcadiaApi, FetchAndUpsertArcadiaEmployees)
- Add Back-Office application settings for employee sites (Setting singleton, GetSettingsQuery, UpdateSettings, SettingsController, EmployeeSitesInputComponent.vue)
- Strongly type Employee attributes using Domain Value Objects (ShopperEstablishmentCode, ShopperSiteCode, ShopperServiceCode) and Eloquent Casts
- Migrate pagination from Domain to Shared\Pagination namespace across queries and inputs
- Remove legacy and dead CSV employee import/export code
- Restore Domain\Ports\Services\CsvGenerator interface for Regate order generation
- Add comprehensive Pest unit, integration, and feature test coverage
2026-10-01 17:26:30 +02:00
|
|
|
$cache,
|
|
|
|
|
$arcadiaService,
|
|
|
|
|
$codeService,
|
|
|
|
|
$storageService,
|
|
|
|
|
app(GetSettingsQuery::class)
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// WHEN
|
|
|
|
|
$service->synchronize(sites: [new ShopperSiteCode('BO')]);
|
|
|
|
|
|
|
|
|
|
// THEN
|
|
|
|
|
expect($service->getLastSync())->not->toBeNull();
|
|
|
|
|
});
|
|
|
|
|
});
|