feat: make email optional for under-16 participants except applicant
This commit is contained in:
1 parent
55a9189284
commit
1ec9c972cd
18 files changed
+435
-336
No files matched your search
@@ -909,7 +909,7 @@ class ParticipantEditDtoTest extends TestCase
|
||||
* available ski pass. Ski pass validation depends on the travel actually offering
|
||||
* passes, so a travel without them is a distinct fixture, not the default.
|
||||
*/
|
||||
public function testChildWithoutEmailFailsStrictValidation(): void
|
||||
public function testChildWithoutEmailPassesStrictValidation(): void
|
||||
{
|
||||
$bookingDto = $this->createBookingDtoWithParticipants([
|
||||
$this->createAdultParticipant('[email protected]'),
|
||||
@@ -918,14 +918,10 @@ class ParticipantEditDtoTest extends TestCase
|
||||
|
||||
$violations = $this->validateStrict($bookingDto, 1);
|
||||
|
||||
$this->assertSame(
|
||||
['Bitte angeben'],
|
||||
$this->emailRequiredMessages($violations),
|
||||
'BusPro requires a Mail-Adresse for every participant, children included'
|
||||
);
|
||||
$this->assertSame([], $this->emailRequiredMessages($violations));
|
||||
}
|
||||
|
||||
public function testChildWithNullEmailFailsStrictValidation(): void
|
||||
public function testChildWithNullEmailPassesStrictValidation(): void
|
||||
{
|
||||
$child = $this->createChildParticipant('');
|
||||
$child->email = null;
|
||||
@@ -937,7 +933,7 @@ class ParticipantEditDtoTest extends TestCase
|
||||
|
||||
$violations = $this->validateStrict($bookingDto, 1);
|
||||
|
||||
$this->assertSame(['Bitte angeben'], $this->emailRequiredMessages($violations));
|
||||
$this->assertSame([], $this->emailRequiredMessages($violations));
|
||||
}
|
||||
|
||||
public function testChildSharingTheApplicantsEmailPassesStrictValidation(): void
|
||||
@@ -952,7 +948,7 @@ class ParticipantEditDtoTest extends TestCase
|
||||
$this->assertSame(
|
||||
[],
|
||||
$this->emailRequiredMessages($violations),
|
||||
'A child inherits the applicant address, which BusPro accepts'
|
||||
'A child may use the applicant\'s address instead of leaving it blank'
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1021,6 +1017,99 @@ class ParticipantEditDtoTest extends TestCase
|
||||
$this->assertSame(['Bitte angeben'], $this->emailRequiredMessages($violations));
|
||||
}
|
||||
|
||||
public function testChildAtIndexZeroOfASplitBookingMayLeaveTheEmailBlank(): void
|
||||
{
|
||||
$bookingDto = $this->createBookingDtoWithParticipants([
|
||||
$this->createChildParticipant(''),
|
||||
]);
|
||||
$bookingDto->applicantTravels = false;
|
||||
|
||||
$violations = $this->validateStrict($bookingDto, 0);
|
||||
|
||||
$this->assertSame(
|
||||
[],
|
||||
$this->emailRequiredMessages($violations),
|
||||
'Where the applicant does not travel, participant[0] is an ordinary traveller'
|
||||
);
|
||||
}
|
||||
|
||||
public function testAdultAtIndexZeroOfASplitBookingStillNeedsAnEmail(): void
|
||||
{
|
||||
$bookingDto = $this->createBookingDtoWithParticipants([
|
||||
$this->createAdultParticipant(''),
|
||||
]);
|
||||
$bookingDto->applicantTravels = false;
|
||||
|
||||
$violations = $this->validateStrict($bookingDto, 0);
|
||||
|
||||
$this->assertSame(['Bitte angeben'], $this->emailRequiredMessages($violations));
|
||||
}
|
||||
|
||||
public function testAdultTravellerMayNotReuseTheNonTravellingApplicantsEmail(): void
|
||||
{
|
||||
$bookingDto = $this->createBookingDtoWithParticipants([
|
||||
$this->createAdultParticipant('[email protected]'),
|
||||
]);
|
||||
$bookingDto->applicantTravels = false;
|
||||
$bookingDto->applicant = $this->createValidParticipant(new \DateTimeImmutable('1980-01-01'), '[email protected]');
|
||||
|
||||
$violations = $this->validator->validate(
|
||||
new ParticipantEditDto(participant: $bookingDto->participants[0], bookingContext: $bookingDto),
|
||||
null,
|
||||
['booking_create']
|
||||
);
|
||||
|
||||
$this->assertCount(1, $violations);
|
||||
$this->assertSame('participant.email', $violations->get(0)->getPropertyPath());
|
||||
$this->assertSame(
|
||||
'Diese E-Mail Adresse wird bereits von der anmeldenden Person verwendet',
|
||||
$violations->get(0)->getMessage()
|
||||
);
|
||||
}
|
||||
|
||||
public function testChildTravellerMayReuseTheNonTravellingApplicantsEmail(): void
|
||||
{
|
||||
$bookingDto = $this->createBookingDtoWithParticipants([
|
||||
$this->createChildParticipant('[email protected]'),
|
||||
]);
|
||||
$bookingDto->applicantTravels = false;
|
||||
$bookingDto->applicant = $this->createValidParticipant(new \DateTimeImmutable('1980-01-01'), '[email protected]');
|
||||
|
||||
$violations = $this->validator->validate(
|
||||
new ParticipantEditDto(participant: $bookingDto->participants[0], bookingContext: $bookingDto),
|
||||
null,
|
||||
['booking_create']
|
||||
);
|
||||
|
||||
$this->assertCount(0, $violations);
|
||||
}
|
||||
|
||||
public function testAdultTravellerMayNotReuseTheAnmelderEmailOfASplitBookingInEditMode(): void
|
||||
{
|
||||
$applicant = new PersonalData();
|
||||
$applicant->personId = 100;
|
||||
$applicant->communication->email = '[email protected]';
|
||||
|
||||
$bookingDto = $this->createBookingDtoWithParticipants([
|
||||
$this->createAdultParticipant('[email protected]'),
|
||||
]);
|
||||
$bookingDto->booking = new Booking();
|
||||
$bookingDto->booking->applicant = $applicant;
|
||||
$bookingDto->participants[0]->personId = 200;
|
||||
|
||||
$violations = $this->validator->validate(
|
||||
new ParticipantEditDto(participant: $bookingDto->participants[0], bookingContext: $bookingDto),
|
||||
null,
|
||||
['booking_edit']
|
||||
);
|
||||
|
||||
$this->assertCount(1, $violations);
|
||||
$this->assertSame(
|
||||
'Diese E-Mail Adresse wird bereits von der anmeldenden Person verwendet',
|
||||
$violations->get(0)->getMessage()
|
||||
);
|
||||
}
|
||||
|
||||
public function testDependentTurningExactlySixteenRequiresEmail(): void
|
||||
{
|
||||
$participant = $this->createAdultParticipant('');
|
||||
@@ -1036,7 +1125,7 @@ class ParticipantEditDtoTest extends TestCase
|
||||
$this->assertSame(['Bitte angeben'], $this->emailRequiredMessages($violations));
|
||||
}
|
||||
|
||||
public function testDependentOneDayShortOfSixteenStillRequiresEmail(): void
|
||||
public function testDependentOneDayShortOfSixteenDoesNotRequireEmail(): void
|
||||
{
|
||||
$participant = $this->createAdultParticipant('');
|
||||
$participant->dateOfBirth = (new \DateTimeImmutable('today'))->modify('-16 years')->modify('+1 day');
|
||||
@@ -1048,7 +1137,7 @@ class ParticipantEditDtoTest extends TestCase
|
||||
|
||||
$violations = $this->validateStrict($bookingDto, 1);
|
||||
|
||||
$this->assertSame(['Bitte angeben'], $this->emailRequiredMessages($violations));
|
||||
$this->assertSame([], $this->emailRequiredMessages($violations));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user