createMock(BovinApiInterface::class); $api->expects(self::never())->method('getAnimalFile'); $provider = new BovinIdentificationProvider($api); $result = $provider->provide($this->createStub(Operation::class), []); self::assertNull($result); } public function testMapsIdentificationAndPresencePeriods(): void { $api = $this->createMock(BovinApiInterface::class); $identification = new BovinIdentificationDto( bovin: new BovinRef('FR', 'IGNORED'), sex: 'F', breedType: 'LIM', birthDate: new DateValueDto(new DateTimeImmutable('2024-01-02'), 'Y'), workNumber: 'W123', isFilie: true, motherCarrier: new ParentInfoDto(new BovinRef('FR', 'MOM1'), 'CHA'), fatherIpg: new ParentInfoDto(new BovinRef('FR', 'DAD1'), 'BBB'), birthExploitation: new ExploitationRef('FR', 'EXP1'), ); $presencePeriods = [ new PresencePeriodDto( new MovementDto(new DateTimeImmutable('2024-03-01'), 'ENTRY', null), new MovementDto(new DateTimeImmutable('2024-03-10'), 'EXIT', null), ), ]; $animalFile = new AnimalFileDto( new StandardResponseDto(true, null), $identification, $presencePeriods, null ); $api->expects(self::once()) ->method('getAnimalFile') ->with('FR123', 'FR') ->willReturn($animalFile) ; $provider = new BovinIdentificationProvider($api); $result = $provider->provide( $this->createStub(Operation::class), ['numeroNational' => 'FR123'] ); self::assertNotNull($result); self::assertSame('FR123', $result->numeroNational); self::assertSame('F', $result->sex); self::assertSame('LIM', $result->breedType); self::assertSame('W123', $result->workNumber); self::assertSame('2024-01-02', $result->birthDate); self::assertSame('Y', $result->birthDateCompletenessFlag); self::assertTrue($result->isFilie); self::assertSame('MOM1', $result->motherNationalNumber); self::assertSame('CHA', $result->motherBreedType); self::assertSame('DAD1', $result->fatherNationalNumber); self::assertSame('BBB', $result->fatherBreedType); self::assertSame('EXP1', $result->birthExploitationNumber); self::assertCount(1, $result->presencePeriods); self::assertSame('2024-03-01', $result->presencePeriods[0]->entryDate); self::assertSame('ENTRY', $result->presencePeriods[0]->entryCause); self::assertSame('2024-03-10', $result->presencePeriods[0]->exitDate); self::assertSame('EXIT', $result->presencePeriods[0]->exitCause); } }