setLabel('Vorausteam') ->setLines([['label' => 'Übernachtung', 'amount' => 25000]]); $dto = AccommodationBookingPeriodDto::fromPeriod($period); self::assertSame('Vorausteam', $dto->label); self::assertSame(2, $dto->nights); self::assertSame([['label' => 'Übernachtung', 'amount' => 25000]], $dto->linesSnapshot()); } public function testTheLinesAreStoredAsAListWhateverKeysTheFormSubmitted(): void { // A collection form keeps the indexes of the rows it was sent, so after a removed row // the keys have gaps — the JSON column must still get a list, not an object. $dto = new AccommodationBookingPeriodDto(1, [ 2 => new AccommodationBookingPeriodLineDto('Übernachtung', 25000), 5 => new AccommodationBookingPeriodLineDto('Verpflegung', 6000), ]); self::assertSame([ ['label' => 'Übernachtung', 'amount' => 25000], ['label' => 'Verpflegung', 'amount' => 6000], ], $dto->linesSnapshot()); } }