ldc-arcadia-api/tests/Unit/Infra/Adapters/Mappers/IncoShortMapperTest.php
Jérémy Munsch cf918ccd30
feat(infra): add mappers and parsers for replicated Arcadia Oracle tables
- Add IncoStringParser, IncoIngredientParser, IncoParser, and IncoCompositionParser
- Add ArcadiaBrandMapper, EmployeeMapper, IncoCompositionMapper, IncoShortMapper, and IncoMapper
- Add complete unit test suites for all parsers and mappers
2026-08-26 17:29:05 +02:00

47 lines
1.6 KiB
PHP

<?php
declare(strict_types=1);
namespace Tests\Unit\Infra\Adapters\Mappers;
use Domain\Models\Entities\Inco\IncoShortSheet;
use Infra\Adapters\Mappers\IncoShortMapper;
use PHPUnit\Framework\TestCase;
covers(IncoShortMapper::class);
uses(TestCase::class);
describe('IncoShortMapper', function (): void {
it('maps an array row to IncoShortSheet entity', function (): void {
$row = [
'NO_ART' => 1000101,
'DENOM_LEG' => 'Poulet Rôti 1kg',
'DESCRIPTIF' => 'Délicieux poulet rôti cuit au four',
'DAT_CRE' => '2024-01-15',
'DAT_MAJ' => '2024-06-20',
];
$entity = IncoShortMapper::toDomain($row);
expect($entity)->toBeInstanceOf(IncoShortSheet::class)
->and((string) $entity->id->value)->toBe('1000101')
->and($entity->name)->toBe('Délicieux poulet rôti cuit au four.')
->and($entity->label)->toBe('Poulet Rôti 1Kg')
->and($entity->createdAt?->format('Y-m-d'))->toBe('2024-01-15')
->and($entity->updatedAt?->format('Y-m-d'))->toBe('2024-06-20');
});
it('maps an object row and derives name when descriptif is missing', function (): void {
$row = (object) [
'no_art' => '1000102',
'denom_leg' => 'Salade Niçoise au Thon',
];
$entity = IncoShortMapper::toDomain($row);
expect($entity)->toBeInstanceOf(IncoShortSheet::class)
->and((string) $entity->id->value)->toBe('1000102')
->and($entity->label)->toBe('Salade Niçoise Au Thon');
});
});