feat: split nights off an accommodation booking as separate periods
addresses #869f6z36v
This commit is contained in:
1 parent
972839286c
commit
7001bc0cf2
35 files changed
+2221
-25
No files matched your search
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Tests\Form\Model;
|
||||
|
||||
use App\Entity\Groups\AccommodationBookingPeriod;
|
||||
use App\Enum\Groups\AccommodationBookingPeriodPosition;
|
||||
use App\Form\Model\AccommodationBookingPeriodDto;
|
||||
use App\Form\Model\AccommodationBookingPeriodLineDto;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class AccommodationBookingPeriodDtoTest extends TestCase
|
||||
{
|
||||
public function testTheEditModalStartsFromWhatThePeriodHolds(): void
|
||||
{
|
||||
$period = (new AccommodationBookingPeriod(
|
||||
AccommodationBookingPeriodPosition::Leading,
|
||||
new \DateTimeImmutable('2026-07-01'),
|
||||
new \DateTimeImmutable('2026-07-03'),
|
||||
))
|
||||
->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());
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user