feat: body dimensions optional
This commit is contained in:
@@ -17,20 +17,7 @@ class ParticipantValidatorTest extends ConstraintValidatorTestCase
|
||||
return new ParticipantValidator();
|
||||
}
|
||||
|
||||
public function testParticipantWithoutRentalsPassesBodyMeasurementValidation(): void
|
||||
{
|
||||
$participant = $this->createValidParticipant();
|
||||
$participant->rentals = []; // No rentals, so body measurements not required
|
||||
$participant->height = null;
|
||||
$participant->weight = null;
|
||||
$participant->shoeSize = null;
|
||||
|
||||
$this->validator->validate($participant, new Participant());
|
||||
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
public function testParticipantWithRentalsButNoBodyMeasurementsFailsValidation(): void
|
||||
public function testParticipantWithRentalsButNoBodyMeasurementsPassesValidation(): void
|
||||
{
|
||||
$participant = $this->createValidParticipant();
|
||||
$participant->rentals = [$this->createMockService()];
|
||||
@@ -40,40 +27,7 @@ class ParticipantValidatorTest extends ConstraintValidatorTestCase
|
||||
|
||||
$this->validator->validate($participant, new Participant());
|
||||
|
||||
$this->buildViolation('Bitte angeben wegen Leihmaterial')
|
||||
->atPath('property.path.height')
|
||||
->buildNextViolation('Bitte angeben wegen Leihmaterial')
|
||||
->atPath('property.path.shoeSize')
|
||||
->buildNextViolation('Bitte angeben wegen Leihmaterial')
|
||||
->atPath('property.path.weight')
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
public function testParticipantWithRentalsAndPartialBodyMeasurementsFailsValidation(): void
|
||||
{
|
||||
$participant = $this->createValidParticipant();
|
||||
$participant->rentals = [$this->createMockService()];
|
||||
$participant->height = '175';
|
||||
$participant->weight = null; // Missing
|
||||
$participant->shoeSize = '42';
|
||||
|
||||
$this->validator->validate($participant, new Participant());
|
||||
|
||||
$this->buildViolation('Bitte angeben wegen Leihmaterial')
|
||||
->atPath('property.path.weight')
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
public function testParticipantWithRentalsAndCompleteBodyMeasurementsPassesValidation(): void
|
||||
{
|
||||
$participant = $this->createValidParticipant();
|
||||
$participant->rentals = [$this->createMockService()];
|
||||
$participant->height = '175';
|
||||
$participant->weight = '70';
|
||||
$participant->shoeSize = '42';
|
||||
|
||||
$this->validator->validate($participant, new Participant());
|
||||
|
||||
// Body measurements are optional and can be provided later
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user