chore: add test
This commit is contained in:
@@ -290,6 +290,40 @@ class TravelDataServiceTest extends TestCase
|
|||||||
], $result);
|
], $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testGenerateFilesMapIsMemoizedWithinRequest(): void
|
||||||
|
{
|
||||||
|
$dateId = 12345;
|
||||||
|
$hotelId = 67890;
|
||||||
|
$mapping = [
|
||||||
|
$dateId => [
|
||||||
|
'id' => $dateId,
|
||||||
|
'hotels' => [
|
||||||
|
$hotelId => ['id' => $hotelId, 'name' => 'Test Hotel'],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
// Both existsLocally() calls go through generateFilesMap(); the underlying
|
||||||
|
// loader and snapshot service must each be invoked only once.
|
||||||
|
$this->travelSnapshotService
|
||||||
|
->expects($this->exactly(2))
|
||||||
|
->method('exists')
|
||||||
|
->willReturn(false);
|
||||||
|
|
||||||
|
$this->travelLoader
|
||||||
|
->expects($this->once())
|
||||||
|
->method('generateFilesMap')
|
||||||
|
->willReturn($mapping);
|
||||||
|
|
||||||
|
$this->travelSnapshotService
|
||||||
|
->expects($this->once())
|
||||||
|
->method('generateMapping')
|
||||||
|
->willReturn([]);
|
||||||
|
|
||||||
|
$this->service->existsLocally($dateId, $hotelId);
|
||||||
|
$this->service->existsLocally($dateId, $hotelId);
|
||||||
|
}
|
||||||
|
|
||||||
public function testGetTravelDataFromLocalPrefersSnapshot(): void
|
public function testGetTravelDataFromLocalPrefersSnapshot(): void
|
||||||
{
|
{
|
||||||
$dateId = 12345;
|
$dateId = 12345;
|
||||||
|
|||||||
Reference in New Issue
Block a user