fix: normalize non-numeric body dimension values of existing drafts
This commit is contained in:
@@ -422,6 +422,66 @@ class BookingEditDraftManagerMutabilityTest extends TestCase
|
||||
$this->assertSame('Updated', $mutableParticipant->firstName);
|
||||
}
|
||||
|
||||
public function testDraftNormalizesLegacyBodyDimensionsToNull(): void
|
||||
{
|
||||
$participant = new ParticipantDto();
|
||||
$participant->height = null;
|
||||
$participant->weight = null;
|
||||
$participant->shoeSize = null;
|
||||
|
||||
$travel = $this->createTravel();
|
||||
$dto = $this->createBookingDto($travel, [$participant]);
|
||||
|
||||
$draft = $this->createDraft([
|
||||
'participants' => [
|
||||
0 => [
|
||||
'bodyDimensions' => [
|
||||
'height' => '149-157',
|
||||
'weight' => '195+',
|
||||
'shoeSize' => 'abc',
|
||||
],
|
||||
],
|
||||
],
|
||||
]);
|
||||
|
||||
$applied = $this->service->applyDraftToDto($draft, $dto, $travel);
|
||||
|
||||
$this->assertTrue($applied);
|
||||
$this->assertNull($participant->height);
|
||||
$this->assertNull($participant->weight);
|
||||
$this->assertNull($participant->shoeSize);
|
||||
}
|
||||
|
||||
public function testDraftNormalizesNumericBodyDimensionsToCanonicalStrings(): void
|
||||
{
|
||||
$participant = new ParticipantDto();
|
||||
$participant->height = null;
|
||||
$participant->weight = null;
|
||||
$participant->shoeSize = null;
|
||||
|
||||
$travel = $this->createTravel();
|
||||
$dto = $this->createBookingDto($travel, [$participant]);
|
||||
|
||||
$draft = $this->createDraft([
|
||||
'participants' => [
|
||||
0 => [
|
||||
'bodyDimensions' => [
|
||||
'height' => '180',
|
||||
'weight' => '75',
|
||||
'shoeSize' => '043',
|
||||
],
|
||||
],
|
||||
],
|
||||
]);
|
||||
|
||||
$applied = $this->service->applyDraftToDto($draft, $dto, $travel);
|
||||
|
||||
$this->assertTrue($applied);
|
||||
$this->assertSame('180', $participant->height);
|
||||
$this->assertSame('75', $participant->weight);
|
||||
$this->assertSame('43', $participant->shoeSize);
|
||||
}
|
||||
|
||||
// --- Helpers ---
|
||||
|
||||
private function createService(int $id, string $label = 'Test', bool $isTransportation = false): Service
|
||||
|
||||
Reference in New Issue
Block a user