feat: move prepopulation guards into participant service

This commit is contained in:
Björn Fromme
2026-04-11 18:28:32 +02:00
parent dbc0b4acee
commit 63e8a068b3
9 changed files with 114 additions and 289 deletions
@@ -12,7 +12,6 @@ use App\Form\Model\ParticipantDto;
use App\Form\Model\RoomSelectionDto;
use App\Service\BookingParticipantCountService;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Security\Core\User\UserInterface;
class BookingParticipantCountServiceTest extends TestCase
{
@@ -44,31 +43,6 @@ class BookingParticipantCountServiceTest extends TestCase
$this->assertSame(7, $bookingDto->participants[7]->index);
}
public function testEnsureCorrectNumberOfParticipantsPrepopulatesFreshApplicant(): void
{
$travel = $this->createTravel([1 => 2]);
$bookingDto = new BookingDto($travel, 123);
$bookingDto->roomSelections = [$this->createRoomSelection(1, 1)];
$bookingDto->participants = [new ParticipantDto()];
$user = $this->createMock(UserInterface::class);
$callbackCalled = false;
$this->service->ensureCorrectNumberOfParticipants(
$bookingDto,
$user,
function (UserInterface $userArg, ParticipantDto $participant) use (&$callbackCalled): ParticipantDto {
$callbackCalled = true;
$participant->firstName = 'Alex';
return $participant;
}
);
$this->assertTrue($callbackCalled);
$this->assertSame('Alex', $bookingDto->participants[0]->firstName);
}
private function createTravel(array $roomCapacities): Travel
{
$travel = new Travel();