Files
ednotif-bundle/tests/Unit/Bovin/Mapper/CreateSortieResponseMapperTest.php
2026-04-22 14:56:36 +02:00

78 lines
3.3 KiB
PHP

<?php
declare(strict_types=1);
namespace Malio\EdnotifBundle\Tests\Unit\Bovin\Mapper;
use DateTimeImmutable;
use Malio\EdnotifBundle\Bovin\Dto\CreateSortieResponseDto;
use Malio\EdnotifBundle\Bovin\Mapper\CreateSortieResponseMapper;
use Malio\EdnotifBundle\Shared\Mapper\StandardResponseMapper;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;
use stdClass;
/**
* @internal
*/
#[CoversClass(CreateSortieResponseMapper::class)]
final class CreateSortieResponseMapperTest extends TestCase
{
public function testMapPendingBdniValidation(): void
{
$soapResponse = new stdClass();
$soapResponse->ReponseStandard = new stdClass();
$soapResponse->ReponseStandard->Resultat = true;
$soapResponse->ReponseSpecifique = new stdClass();
$soapResponse->ReponseSpecifique->AttenteValidationBDNi = true;
$dto = new CreateSortieResponseMapper(new StandardResponseMapper())->map($soapResponse);
self::assertInstanceOf(CreateSortieResponseDto::class, $dto);
self::assertTrue($dto->pendingBdniValidation);
self::assertNull($dto->identification);
self::assertNull($dto->entryMovement);
self::assertNull($dto->exitMovement);
}
public function testMapValidatedExit(): void
{
$soapResponse = new stdClass();
$soapResponse->ReponseStandard = new stdClass();
$soapResponse->ReponseStandard->Resultat = true;
$soapResponse->ReponseSpecifique = new stdClass();
$validee = new stdClass();
$validee->IdentiteBovin = new stdClass();
$validee->IdentiteBovin->Sexe = 'M';
$validee->IdentiteBovin->Bovin = new stdClass();
$validee->IdentiteBovin->Bovin->NumeroNational = 'FR9999999999';
$mouvement = new stdClass();
$mouvement->MouvementEntreeBovin = new stdClass();
$mouvement->MouvementEntreeBovin->DateEntree = '2024-01-10';
$mouvement->MouvementEntreeBovin->CauseEntree = 'A';
$mouvement->MouvementSortieBovin = new stdClass();
$mouvement->MouvementSortieBovin->DateSortie = '2026-04-22';
$mouvement->MouvementSortieBovin->CauseSortie = 'B';
$validee->MouvementBovin = $mouvement;
$soapResponse->ReponseSpecifique->SortieValidee = $validee;
$dto = new CreateSortieResponseMapper(new StandardResponseMapper())->map($soapResponse);
self::assertFalse($dto->pendingBdniValidation);
self::assertNotNull($dto->identification);
self::assertSame('M', $dto->identification->sex);
self::assertSame('FR9999999999', $dto->identification->bovin?->nationalNumber);
self::assertNotNull($dto->entryMovement);
self::assertEquals(new DateTimeImmutable('2024-01-10'), $dto->entryMovement->date);
self::assertSame('A', $dto->entryMovement->cause);
self::assertNotNull($dto->exitMovement);
self::assertEquals(new DateTimeImmutable('2026-04-22'), $dto->exitMovement->date);
self::assertSame('B', $dto->exitMovement->cause);
}
}