Skip to content

Commit a1b3994

Browse files
committed
test: add ipstack test
1 parent ae4846c commit a1b3994

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

tests/Drivers/IpStackDriverTest.php

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,44 @@
5454
);
5555
});
5656

57+
test('ipstack should return default when response is empty', function () {
58+
$config = [
59+
'driver' => 'ipstack',
60+
'ipstack' => [
61+
'key' => 'test',
62+
],
63+
];
64+
65+
$client = Mockery::mock(Client::class);
66+
67+
$client->shouldReceive('get')
68+
->times(1)
69+
->andReturn(
70+
new Response(
71+
200,
72+
[],
73+
json_encode([])
74+
)
75+
);
76+
77+
$geoip = new GeoIP($config, $client);
78+
$geoip = $geoip->setIp($this->validIp);
79+
80+
expect($geoip->get())->toEqual(
81+
[
82+
'city' => null,
83+
'country' => null,
84+
'countryCode' => null,
85+
'latitude' => null,
86+
'longitude' => null,
87+
'region' => null,
88+
'regionCode' => null,
89+
'timezone' => null,
90+
'postalCode' => null,
91+
]
92+
);
93+
});
94+
5795
test('ipstack throws exception getraw', function () {
5896
$config = [
5997
'driver' => 'ipstack',
@@ -108,6 +146,7 @@
108146

109147
$geoip->get();
110148
});
149+
111150
test('ipstack respects false secure config value', function () {
112151
$config = [
113152
'driver' => 'ipstack',
@@ -135,6 +174,7 @@
135174

136175
$geoip->get();
137176
});
177+
138178
test("ipstack respects true secure config value", function () {
139179
$config = [
140180
'driver' => 'ipstack',

0 commit comments

Comments
 (0)