2026-06-14 21:32:07 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
|
|
use App\Casts\OrderEmployeeCast;
|
|
|
|
|
use Domain\Models\ValueObjects\Matricule;
|
|
|
|
|
use Domain\Models\ValueObjects\OrderEmployee;
|
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
|
|
|
|
|
|
it('gets null when value is null', function () {
|
|
|
|
|
// GIVEN
|
|
|
|
|
$cast = new OrderEmployeeCast();
|
|
|
|
|
$model = \Mockery::mock(Model::class);
|
|
|
|
|
|
|
|
|
|
// WHEN
|
|
|
|
|
$employee = $cast->get($model, 'employee', null, []);
|
|
|
|
|
|
|
|
|
|
// THEN
|
|
|
|
|
expect($employee)->toBeNull();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('throws exception when getting invalid value type', function () {
|
|
|
|
|
// GIVEN
|
|
|
|
|
$cast = new OrderEmployeeCast();
|
|
|
|
|
$model = \Mockery::mock(Model::class);
|
|
|
|
|
|
|
|
|
|
// WHEN
|
|
|
|
|
$cast->get($model, 'employee', 123, []);
|
|
|
|
|
|
|
|
|
|
// THEN
|
|
|
|
|
})->throws(
|
|
|
|
|
\InvalidArgumentException::class,
|
|
|
|
|
'The value must be a string.'
|
|
|
|
|
);
|
|
|
|
|
|
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 Domain\Models\ValueObjects\ShopperEstablishmentCode;
|
|
|
|
|
use Domain\Models\ValueObjects\ShopperServiceCode;
|
|
|
|
|
use Domain\Models\ValueObjects\ShopperSiteCode;
|
|
|
|
|
|
2026-06-14 21:32:07 +02:00
|
|
|
it('gets an order employee from json string', function () {
|
|
|
|
|
// GIVEN
|
|
|
|
|
$cast = new OrderEmployeeCast();
|
|
|
|
|
$model = \Mockery::mock(Model::class);
|
|
|
|
|
|
|
|
|
|
$json = json_encode([
|
|
|
|
|
'matricule' => '1234567',
|
|
|
|
|
'firstname' => 'John',
|
|
|
|
|
'lastname' => 'Doe',
|
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
|
|
|
'facility' => 'FAC01',
|
|
|
|
|
'site' => 'SITE',
|
|
|
|
|
'service' => '101',
|
2026-06-14 21:32:07 +02:00
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
// WHEN
|
|
|
|
|
$employee = $cast->get($model, 'employee', $json, []);
|
|
|
|
|
|
|
|
|
|
// THEN
|
|
|
|
|
expect($employee)->toBeInstanceOf(OrderEmployee::class)
|
|
|
|
|
->and($employee->matricule)->toBeInstanceOf(Matricule::class)
|
|
|
|
|
->and($employee->matricule->value)->toBe('1234567')
|
|
|
|
|
->and($employee->firstname)->toBe('John')
|
|
|
|
|
->and($employee->lastname)->toBe('Doe')
|
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
|
|
|
->and($employee->facility)->toBeInstanceOf(ShopperEstablishmentCode::class)
|
|
|
|
|
->and($employee->facility->value)->toBe('FAC01')
|
|
|
|
|
->and($employee->site)->toBeInstanceOf(ShopperSiteCode::class)
|
|
|
|
|
->and($employee->site->value)->toBe('SITE')
|
|
|
|
|
->and($employee->service)->toBeInstanceOf(ShopperServiceCode::class)
|
|
|
|
|
->and($employee->service->value)->toBe('101');
|
2026-06-14 21:32:07 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('sets null when value is null', function () {
|
|
|
|
|
// GIVEN
|
|
|
|
|
$cast = new OrderEmployeeCast();
|
|
|
|
|
$model = \Mockery::mock(Model::class);
|
|
|
|
|
|
|
|
|
|
// WHEN
|
|
|
|
|
$value = $cast->set($model, 'employee', null, []);
|
|
|
|
|
|
|
|
|
|
// THEN
|
|
|
|
|
expect($value)->toBeNull();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('throws exception when setting invalid type', function () {
|
|
|
|
|
// GIVEN
|
|
|
|
|
$cast = new OrderEmployeeCast();
|
|
|
|
|
$model = \Mockery::mock(Model::class);
|
|
|
|
|
|
|
|
|
|
// WHEN
|
|
|
|
|
$cast->set($model, 'employee', 'invalid', []);
|
|
|
|
|
|
|
|
|
|
// THEN
|
|
|
|
|
})->throws(
|
|
|
|
|
\InvalidArgumentException::class,
|
|
|
|
|
'The given value is not an instance of OrderEmployee.'
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
it('sets an order employee', function () {
|
|
|
|
|
// GIVEN
|
|
|
|
|
$cast = new OrderEmployeeCast();
|
|
|
|
|
$model = \Mockery::mock(Model::class);
|
|
|
|
|
$employee = new OrderEmployee(
|
|
|
|
|
matricule: new Matricule('1234567'),
|
|
|
|
|
firstname: 'John',
|
|
|
|
|
lastname: 'Doe',
|
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
|
|
|
facility: new ShopperEstablishmentCode('FAC01'),
|
|
|
|
|
site: new ShopperSiteCode('SITE'),
|
|
|
|
|
service: new ShopperServiceCode('101')
|
2026-06-14 21:32:07 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// WHEN
|
|
|
|
|
$value = $cast->set($model, 'employee', $employee, []);
|
|
|
|
|
|
|
|
|
|
// THEN
|
|
|
|
|
expect($value)->toBeJson()
|
|
|
|
|
->and(json_decode($value, true))->toMatchArray([
|
|
|
|
|
'matricule' => '1234567',
|
|
|
|
|
'firstname' => 'John',
|
|
|
|
|
'lastname' => 'Doe',
|
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
|
|
|
'facility' => 'FAC01',
|
|
|
|
|
'site' => 'SITE',
|
|
|
|
|
'service' => '101',
|
2026-06-14 21:32:07 +02:00
|
|
|
]);
|
|
|
|
|
});
|