fix: applicant split in edit mode, drop create-mode agency checks
This commit is contained in:
1 parent
ad6e42ab0c
commit
38f0f23ea3
12 files changed
+167
-68
No files matched your search
@@ -148,14 +148,25 @@ class BookingDtoTest extends TestCase
|
||||
$this->assertFalse($dto->isFirstParticipantApplicant());
|
||||
}
|
||||
|
||||
public function testInternalAgencyBookingNeverHasTheFirstParticipantAsApplicant(): void
|
||||
public function testInternalAgencyBookingNeverHasTheFirstParticipantAsApplicantInEditMode(): void
|
||||
{
|
||||
$dto = $this->createCreateModeDto();
|
||||
$dto = $this->createEditModeDto(100, 100);
|
||||
$dto->agencyCode = AgencyLoader::INTERNAL_AGENCY_CODE;
|
||||
|
||||
$this->assertFalse(
|
||||
$dto->isFirstParticipantApplicant(),
|
||||
'Their applicant is a staff member who never travels'
|
||||
'Their applicant is a customer who is not the first traveller, whatever the ids say'
|
||||
);
|
||||
}
|
||||
|
||||
public function testAgencyCodeDoesNotDecideAnythingInCreateMode(): void
|
||||
{
|
||||
$dto = $this->createCreateModeDto();
|
||||
$dto->agencyCode = AgencyLoader::INTERNAL_AGENCY_CODE;
|
||||
|
||||
$this->assertTrue(
|
||||
$dto->isFirstParticipantApplicant(),
|
||||
'Internal agency bookings are never created here, so the code is only passed on'
|
||||
);
|
||||
}
|
||||
|
||||
@@ -358,6 +369,42 @@ class BookingDtoTest extends TestCase
|
||||
$this->assertContains('Die anmeldende Person muss volljährig sein.', $messages);
|
||||
}
|
||||
|
||||
public function testEditModeDoesNotAskASplitBookingsFirstParticipantForAnAddress(): void
|
||||
{
|
||||
$dto = $this->createEditModeDto(100, 200);
|
||||
$dto->participants[0]->index = 0;
|
||||
$dto->participants[0]->address = null;
|
||||
|
||||
$this->assertSame([], $this->collectFirstParticipantAddressPaths($dto));
|
||||
}
|
||||
|
||||
public function testEditModeStillAsksTheApplicantForAnAddress(): void
|
||||
{
|
||||
$dto = $this->createEditModeDto(100, 100);
|
||||
$dto->participants[0]->index = 0;
|
||||
$dto->participants[0]->address = null;
|
||||
|
||||
$this->assertSame(['participants[0].address'], $this->collectFirstParticipantAddressPaths($dto));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<string>
|
||||
*/
|
||||
private function collectFirstParticipantAddressPaths(BookingDto $dto): array
|
||||
{
|
||||
$validator = Validation::createValidatorBuilder()->enableAttributeMapping()->getValidator();
|
||||
$violations = $validator->validate($dto, null, ['booking_edit', 'strict_required']);
|
||||
|
||||
$paths = [];
|
||||
foreach ($violations as $violation) {
|
||||
if (str_starts_with($violation->getPropertyPath(), 'participants[0].address')) {
|
||||
$paths[] = $violation->getPropertyPath();
|
||||
}
|
||||
}
|
||||
|
||||
return $paths;
|
||||
}
|
||||
|
||||
private function createAddress(): Address
|
||||
{
|
||||
$address = new Address();
|
||||
|
||||
Reference in new issue
Block a user