feat : parser SerieBoucles dans EarTagSeriesDto typé (#4)
| 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: #4 Co-authored-by: tristan <tristan@yuno.malio.fr> Co-committed-by: tristan <tristan@yuno.malio.fr>
This commit was merged in pull request #4.
This commit is contained in:
49
tests/Unit/Bovin/Dto/EarTagSeriesDtoTest.php
Normal file
49
tests/Unit/Bovin/Dto/EarTagSeriesDtoTest.php
Normal 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());
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user