test : tests adversariaux InventoryMapper + docblock EarTagSeriesDto (#3)
Some checks failed
Auto Tag Develop / tag (push) Failing after 16s

| Numéro du ticket | Titre du ticket |
|------------------|-----------------|
|                  |                 |

## Description de la PR

## Modification du .env

## Check list

- [ ] Pas de régression
- [ ] TU/TI/TF rédigée
- [ ] TU/TI/TF OK
- [ ] CHANGELOG modifié

Reviewed-on: #3
Co-authored-by: tristan <tristan@yuno.malio.fr>
Co-committed-by: tristan <tristan@yuno.malio.fr>
This commit was merged in pull request #3.
This commit is contained in:
2026-04-21 15:52:24 +00:00
committed by Autin
parent f757822f36
commit 366143ce36
4 changed files with 651 additions and 0 deletions

View File

@@ -54,6 +54,82 @@ final class InventoryMapperTest extends TestCase
self::assertNull($inventory->startDate);
}
public function testMapInventoryWithStockBouclesAbsentYieldsNullFlag(): void
{
$mapper = new InventoryMapper(new AnimalSummaryMapper(), new StandardResponseMapper());
$message = new stdClass();
$message->InformationsMessage = new stdClass();
$message->InformationsMessage->DateDebut = '2026-01-01';
// StockBoucles deliberately omitted
$inventory = $mapper->map($this->makeSoapResponse(), $message);
self::assertNull($inventory->includesEarTagStock);
}
public function testMapInventoryWithStockBouclesZeroYieldsFalseFlag(): void
{
$mapper = new InventoryMapper(new AnimalSummaryMapper(), new StandardResponseMapper());
$message = new stdClass();
$message->InformationsMessage = new stdClass();
$message->InformationsMessage->StockBoucles = '0';
$inventory = $mapper->map($this->makeSoapResponse(), $message);
self::assertFalse($inventory->includesEarTagStock);
}
public function testMapInventoryWithDateFinAbsentYieldsNullEndDate(): void
{
$mapper = new InventoryMapper(new AnimalSummaryMapper(), new StandardResponseMapper());
$message = new stdClass();
$message->InformationsMessage = new stdClass();
$message->InformationsMessage->DateDebut = '2026-01-01';
// DateFin deliberately omitted
$inventory = $mapper->map($this->makeSoapResponse(), $message);
self::assertNull($inventory->endDate);
}
public function testMapInventoryWithSerieBouclesAsListPreservesAllEntries(): void
{
$mapper = new InventoryMapper(new AnimalSummaryMapper(), new StandardResponseMapper());
$serie1 = new stdClass();
$serie1->NumeroSerieDebut = 'A0001';
$serie2 = new stdClass();
$serie2->NumeroSerieDebut = 'B0001';
$message = new stdClass();
$message->Boucles = new stdClass();
$message->Boucles->SerieBoucles = [$serie1, $serie2];
$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);
}
public function testMapInventoryWithMissingNbBovinsDefaultsToZero(): void
{
$mapper = new InventoryMapper(new AnimalSummaryMapper(), new StandardResponseMapper());
$soapResponse = new stdClass();
$soapResponse->ReponseStandard = new stdClass();
$soapResponse->ReponseStandard->Resultat = true;
$soapResponse->ReponseSpecifique = new stdClass();
// NbBovins deliberately omitted
$inventory = $mapper->map($soapResponse, null);
self::assertSame(0, $inventory->nbBovins);
}
private function makeSoapResponse(): object
{
$response = new stdClass();