Skip to content

Commit dbcd76f

Browse files
authored
Merge pull request #525 from Philipp91/gh521
Fix serializer bug regarding capped repeated fields that aren't at the end
2 parents 10e3721 + 0178f12 commit dbcd76f

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

lib/Fhp/Syntax/Serializer.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ private static function serializeElements($obj, BaseDescriptor $descriptor): arr
130130
$value === null || $repetition >= count($value) ? null : $value[$repetition],
131131
$elementDescriptor->type, $isSegment);
132132
}
133+
$index += $numOutputElements - 1; // The outer loop will increment by 1 as well.
133134
}
134135
}
135136
return $serializedElements;
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
namespace Fhp\Segment;
4+
5+
use Fhp\Segment\HIUPD\HIUPDv6;
6+
use Fhp\Syntax\Parser;
7+
use Fhp\Syntax\Serializer;
8+
use PHPUnit\Framework\TestCase;
9+
10+
class UpdSerializationTest extends TestCase
11+
{
12+
private const HIUPD = "HIUPD:7:6:4+PRIVAT::280:11223344+DE00112233440000000000+PRIVATE_______+1+EUR+PRIVATE__________________++Kontokorrent++HKSAK:1+HKISA:1+HKSSP:1+HKCAZ:1+HKEKA:1+HKKAU:1+HKCDB:1+HKPSP:1+HKCSL:1+HKCDL:1+HKPAE:1+HKDVK:1+HKPPD:1+HKCSA:1+HKCDN:1+HKBMB:1+HKBBS:1+HKDMB:1+HKDBS:1+HKCSB:1+HKCUB:1+HKKAA:1+HKPOF:1+HKQTG:1+HKSPA:1+HKDSB:1+HKIPZ:1+HKIPS:1+HKCUM:1+HKCCS:1+HKCDE:1+HKCSE:1+HKDSW:1+HKSAL:1+HKKIF:1+HKKAZ:1+HKAUB:1+GKVPU:1+GKVPD:1+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++{\"umsltzt\"?:\"2025-10-10-10.32.13.000636\"}'";
13+
14+
public function testParserPlusSerializer(): void
15+
{
16+
/** @var HIUPDv6 $hiupd */
17+
$hiupd = Parser::parseSegment(static::HIUPD, HIUPDv6::class);
18+
$this->assertEquals(static::HIUPD, Serializer::serializeSegment($hiupd));
19+
}
20+
21+
public function testNativePhpSerialization(): void
22+
{
23+
/** @var HIUPDv6 $hiupd */
24+
$hiupd = Parser::parseSegment(static::HIUPD, HIUPDv6::class);
25+
$before = $hiupd->getErlaubteGeschaeftsvorfaelle();
26+
27+
/** @var HIUPDv6 $hiupd */
28+
$hiupd = unserialize(serialize($hiupd));
29+
$after = $hiupd->getErlaubteGeschaeftsvorfaelle();
30+
31+
$this->assertEquals($before, $after);
32+
}
33+
}

0 commit comments

Comments
 (0)