fix: reduce snapshot payloads via serializer group and hydration
This commit is contained in:
@@ -313,13 +313,20 @@ class TravelDataServiceTest extends TestCase
|
||||
$this->assertSame($travel, $result);
|
||||
}
|
||||
|
||||
public function testGetTravelDataFromLocalRehydratesInsurancePackagesFromSnapshot(): void
|
||||
public function testGetTravelDataFromLocalHydratesInsurancePackagesFromLoaderAfterSnapshotLoad(): void
|
||||
{
|
||||
$dateId = 12345;
|
||||
$hotelId = 67890;
|
||||
|
||||
// Simulate a deserialized snapshot state: containedInsuranceIds are present but
|
||||
// containedInsurances is empty (circular-reference prevention strips it during serialization).
|
||||
$travel = new Travel();
|
||||
$travel->id = $dateId;
|
||||
$travel->hotelId = $hotelId;
|
||||
|
||||
// Snapshot-provided insurances are intentionally replaced by InsuranceLoader data.
|
||||
$staleSnapshotInsurance = new Insurance();
|
||||
$staleSnapshotInsurance->id = 'stale';
|
||||
$travel->insurances = [$staleSnapshotInsurance];
|
||||
|
||||
$individual = new Insurance();
|
||||
$individual->id = '10';
|
||||
$individual->package = false;
|
||||
@@ -328,12 +335,7 @@ class TravelDataServiceTest extends TestCase
|
||||
$package->id = '20';
|
||||
$package->package = true;
|
||||
$package->containedInsuranceIds = ['10'];
|
||||
$package->containedInsurances = []; // as it arrives after deserialization
|
||||
|
||||
$travel = new Travel();
|
||||
$travel->id = $dateId;
|
||||
$travel->hotelId = $hotelId;
|
||||
$travel->insurances = [$individual, $package];
|
||||
$package->containedInsurances = [];
|
||||
|
||||
$this->travelSnapshotService
|
||||
->expects($this->once())
|
||||
@@ -341,9 +343,15 @@ class TravelDataServiceTest extends TestCase
|
||||
->with($dateId, $hotelId)
|
||||
->willReturn($travel);
|
||||
|
||||
$this->insuranceLoader
|
||||
->expects($this->once())
|
||||
->method('loadAll')
|
||||
->willReturn([$individual, $package]);
|
||||
|
||||
$result = $this->service->getTravelDataFromLocal($dateId, $hotelId);
|
||||
|
||||
$this->assertSame($travel, $result);
|
||||
$this->assertSame([$individual, $package], array_values($travel->insurances));
|
||||
$this->assertCount(1, $package->containedInsurances);
|
||||
$this->assertSame($individual, $package->containedInsurances[0]);
|
||||
}
|
||||
@@ -393,8 +401,8 @@ class TravelDataServiceTest extends TestCase
|
||||
$dateId = 12345;
|
||||
$hotelId = 67890;
|
||||
|
||||
// insuranceLoader->loadAll() returns these during enrichTravelData(); the package's
|
||||
// containedInsurances starts empty (as it would from a fresh XML load before hydration).
|
||||
// InsuranceLoader supplies the canonical insurance list for local reads; the package's
|
||||
// containedInsurances starts empty and is rebuilt after hydration.
|
||||
$individual = new Insurance();
|
||||
$individual->id = '10';
|
||||
$individual->package = false;
|
||||
|
||||
Reference in New Issue
Block a user