Skip to content

Commit 5f18a4a

Browse files
horghclaude
andcommitted
Add test for empty subdivisions array
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
1 parent 6555570 commit 5f18a4a

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

tests/GeoIp2/Test/Model/InsightsTest.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -497,4 +497,24 @@ public function testMostSpecificSubdivisionWithNoSubdivisions(): void
497497
'mostSpecificSubdivision is set even on an empty response'
498498
);
499499
}
500+
501+
// We do not expect well-formed databases from MaxMind to have empty
502+
// subdivisions arrays, but we support it due to encountering a third-party
503+
// database that had them.
504+
public function testEmptySubdivisionsArray(): void
505+
{
506+
$raw = [
507+
'subdivisions' => [],
508+
'traits' => ['ip_address' => '1.1.1.1'],
509+
];
510+
511+
$model = new Insights($raw, ['en']);
512+
513+
$this->assertCount(0, $model->subdivisions);
514+
515+
$this->assertInstanceOf(
516+
'GeoIp2\Record\Subdivision',
517+
$model->mostSpecificSubdivision
518+
);
519+
}
500520
}

0 commit comments

Comments
 (0)