feat: split booking between participants and applicant

addresses #869f2q1vu
This commit is contained in:
fromme committed 2026-10-19 09:18:22 +02:00
1 parent 2d49212b08
commit 1ff293f41f
44 files changed
+2024 -316

No files matched your search

@@ -74,57 +74,55 @@ class CreateFieldStateProviderTest extends TestCase
);
}
public function testEmailIsNotRequiredForNonApplicantChild(): void
public function testEmailIsRequiredForEveryParticipantIncludingChildren(): void
{
$bookingDto = $this->createBookingDtoWithApplicantAndDependent(new \DateTimeImmutable('2015-01-01'));
$this->assertFalse(
$this->provider->getFieldState('email', $bookingDto, 1)['required'],
'A child travelling with an applicant does not need an email address of their own'
$this->assertArrayNotHasKey(
'required',
$this->provider->getFieldState('email', $bookingDto, 1),
'Requiredness is the form type base option now that it is unconditional'
);
}
public function testEmailIsRequiredForNonApplicantAdult(): void
public function testMobileIsRequiredForTheApplicantOnly(): void
{
$bookingDto = $this->createBookingDtoWithApplicantAndDependent(new \DateTimeImmutable('1990-01-01'));
$this->assertTrue($this->provider->getFieldState('email', $bookingDto, 1)['required']);
$this->assertTrue($this->provider->getFieldState('mobile', $bookingDto, 0)['required']);
$this->assertFalse($this->provider->getFieldState('mobile', $bookingDto, 1)['required']);
}
public function testEmailIsRequiredForTheApplicantEvenAsAChild(): void
public function testMobileAndAddressAreNotRequiredOfParticipantZeroWhenTheApplicantDoesNotTravel(): void
{
$bookingDto = $this->createBookingDtoWithApplicantAndDependent(new \DateTimeImmutable('2015-01-01'));
$bookingDto->participants[0]->dateOfBirth = new \DateTimeImmutable('2015-01-01');
$bookingDto->applicantTravels = false;
$this->assertTrue(
$this->provider->getFieldState('email', $bookingDto, 0)['required'],
'The applicant is the booking contact and always has to be reachable'
$this->assertFalse(
$this->provider->getFieldState('mobile', $bookingDto, 0)['required'],
'BusPro does not ask a telefonmobil of an ordinary participant'
);
$this->assertFalse(
$this->provider->getFieldState('address', $bookingDto, 0)['required'],
'BusPro accepts an empty anschrift for an ordinary participant'
);
}
public function testEmailIsRequiredWhenDateOfBirthIsUnknown(): void
public function testParticipantZeroIsEditableWhenTheApplicantDoesNotTravel(): void
{
$bookingDto = $this->createBookingDtoWithApplicantAndDependent(new \DateTimeImmutable('2015-01-01'));
$bookingDto->participants[1]->dateOfBirth = null;
$bookingDto->participants[0]->personId = 4711;
$this->assertTrue(
$this->provider->getFieldState('email', $bookingDto, 1)['required'],
'An unknown age counts as an adult'
$this->provider->shouldRenderAsStaticText('firstName', $bookingDto, 0),
'A logged-in applicant who travels keeps their prefilled data locked'
);
}
public function testEmailRequirementFlipsWhenDateOfBirthChanges(): void
{
$bookingDto = $this->createBookingDtoWithApplicantAndDependent(new \DateTimeImmutable('2015-01-01'));
$dependent = $bookingDto->participants[1];
$bookingDto->applicantTravels = false;
$this->assertFalse($this->provider->getFieldState('email', $bookingDto, 1)['required']);
$dependent->dateOfBirth = new \DateTimeImmutable('1990-01-01');
$this->assertTrue(
$this->provider->getFieldState('email', $bookingDto, 1)['required'],
'Correcting a child date of birth to an adult one must reinstate the requirement'
$this->assertFalse(
$this->provider->shouldRenderAsStaticText('firstName', $bookingDto, 0),
'Once the applicant does not travel, participant[0] is an ordinary traveller'
);
}