index = 0; // Applicant $participant->email = 'test@example.com'; $this->validator->validate($participant, new ApplicantEmail()); $this->assertNoViolation(); } public function testApplicantWithoutEmailFailsValidation(): void { $participant = new ParticipantDto(); $participant->index = 0; // Applicant $participant->email = null; $this->validator->validate($participant, new ApplicantEmail()); $this->buildViolation('Bitte angeben') ->atPath('property.path.email') ->assertRaised(); } public function testApplicantWithEmptyEmailFailsValidation(): void { $participant = new ParticipantDto(); $participant->index = 0; // Applicant $participant->email = ''; $this->validator->validate($participant, new ApplicantEmail()); $this->buildViolation('Bitte angeben') ->atPath('property.path.email') ->assertRaised(); } public function testApplicantWithInvalidEmailFailsValidation(): void { $participant = new ParticipantDto(); $participant->index = 0; // Applicant $participant->email = 'invalid-email'; $this->validator->validate($participant, new ApplicantEmail()); $this->buildViolation('Bitte eine gültige E-Mail Adresse angeben') ->atPath('property.path.email') ->assertRaised(); } public function testNonApplicantWithoutEmailPassesValidation(): void { $participant = new ParticipantDto(); $participant->index = 1; // Not applicant $participant->email = null; $this->validator->validate($participant, new ApplicantEmail()); $this->assertNoViolation(); } public function testNonApplicantWithEmptyEmailPassesValidation(): void { $participant = new ParticipantDto(); $participant->index = 2; // Not applicant $participant->email = ''; $this->validator->validate($participant, new ApplicantEmail()); $this->assertNoViolation(); } public function testNonApplicantWithValidEmailPassesValidation(): void { $participant = new ParticipantDto(); $participant->index = 1; // Not applicant $participant->email = 'participant@example.com'; $this->validator->validate($participant, new ApplicantEmail()); $this->assertNoViolation(); } public function testNonApplicantWithInvalidEmailStillValidatesFormat(): void { $participant = new ParticipantDto(); $participant->index = 1; // Not applicant $participant->email = 'invalid-email'; $this->validator->validate($participant, new ApplicantEmail()); // Non-applicants don't need email, but if provided it should be valid // However, our validator only checks format for applicants // The Email constraint on the property handles format validation for all participants $this->assertNoViolation(); } }