feat : parser SerieBoucles dans EarTagSeriesDto typé

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-22 09:06:51 +02:00
parent 08dbd9a72b
commit c2ed7597ef
4 changed files with 96 additions and 18 deletions

View File

@@ -0,0 +1,49 @@
<?php
declare(strict_types=1);
namespace Malio\EdnotifBundle\Tests\Unit\Bovin\Dto;
use Malio\EdnotifBundle\Bovin\Dto\EarTagSeriesDto;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;
/**
* @internal
*/
#[CoversClass(EarTagSeriesDto::class)]
final class EarTagSeriesDtoTest extends TestCase
{
public function testEndNumberComputesStartPlusQuantityMinusOne(): void
{
$series = new EarTagSeriesDto(
countryCode: 'FR',
startNumber: '0012345678',
quantity: 50,
);
self::assertSame('0012345727', $series->endNumber());
}
public function testEndNumberPreservesLeadingZeroPadding(): void
{
$series = new EarTagSeriesDto(
countryCode: 'FR',
startNumber: '0000000001',
quantity: 5,
);
self::assertSame('0000000005', $series->endNumber());
}
public function testEndNumberWithQuantityOneEqualsStartNumber(): void
{
$series = new EarTagSeriesDto(
countryCode: 'FR',
startNumber: '0012345678',
quantity: 1,
);
self::assertSame('0012345678', $series->endNumber());
}
}

View File

@@ -34,6 +34,9 @@ final class InventoryMapperTest extends TestCase
self::assertCount(2, $inventory->animals);
self::assertCount(1, $inventory->earTagSeries);
self::assertSame('FR123', $inventory->animals[0]->identification?->bovin?->nationalNumber);
self::assertSame('FR', $inventory->earTagSeries[0]->countryCode);
self::assertSame('0012345678', $inventory->earTagSeries[0]->startNumber);
self::assertSame(50, $inventory->earTagSeries[0]->quantity);
}
public function testMapInventoryWithoutMessageZipReturnsEmptyLists(): void
@@ -99,10 +102,15 @@ final class InventoryMapperTest extends TestCase
{
$mapper = new InventoryMapper(new AnimalSummaryMapper(), new StandardResponseMapper());
$serie1 = new stdClass();
$serie1->NumeroSerieDebut = 'A0001';
$serie2 = new stdClass();
$serie2->NumeroSerieDebut = 'B0001';
$serie1 = new stdClass();
$serie1->CodePays = 'FR';
$serie1->DebutSerie = '0012345678';
$serie1->Quantite = 10;
$serie2 = new stdClass();
$serie2->CodePays = 'FR';
$serie2->DebutSerie = '0055500000';
$serie2->Quantite = 25;
$message = new stdClass();
$message->Boucles = new stdClass();
@@ -111,8 +119,10 @@ final class InventoryMapperTest extends TestCase
$inventory = $mapper->map($this->makeSoapResponse(), $message);
self::assertCount(2, $inventory->earTagSeries);
self::assertSame('A0001', $inventory->earTagSeries[0]->rawNode->NumeroSerieDebut);
self::assertSame('B0001', $inventory->earTagSeries[1]->rawNode->NumeroSerieDebut);
self::assertSame('0012345678', $inventory->earTagSeries[0]->startNumber);
self::assertSame(10, $inventory->earTagSeries[0]->quantity);
self::assertSame('0055500000', $inventory->earTagSeries[1]->startNumber);
self::assertSame(25, $inventory->earTagSeries[1]->quantity);
}
public function testMapInventoryWithMissingNbBovinsDefaultsToZero(): void
@@ -153,9 +163,11 @@ final class InventoryMapperTest extends TestCase
$this->makeAnimalNode('FR123'),
$this->makeAnimalNode('FR456'),
];
$message->Boucles = new stdClass();
$message->Boucles->SerieBoucles = new stdClass();
$message->Boucles->SerieBoucles->NumeroSerieDebut = 'A0001';
$message->Boucles = new stdClass();
$message->Boucles->SerieBoucles = new stdClass();
$message->Boucles->SerieBoucles->CodePays = 'FR';
$message->Boucles->SerieBoucles->DebutSerie = '0012345678';
$message->Boucles->SerieBoucles->Quantite = 50;
return $message;
}