Skip to content

Commit 6a986d1

Browse files
committed
test timeout & guzzle overrides.
1 parent 316de0b commit 6a986d1

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

tests/IPinfoTest.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,4 +113,34 @@ public function testLookup()
113113
$this->assertEquals($res->abuse['phone'], '+1-650-253-0000');
114114
$this->assertEquals($res->domains['ip'], '8.8.8.8');
115115
}
116+
117+
public function testTimeoutOverride()
118+
{
119+
$tok = getenv('IPINFO_TOKEN');
120+
if (!$tok) {
121+
$this->markTestSkipped('IPINFO_TOKEN env var required');
122+
}
123+
124+
$h = new IPinfo($tok, ['timeout' => 0.1]);
125+
$ip = "8.8.8.8";
126+
127+
$this->expectException(IPinfoException::class);
128+
$res = $h->getDetails($ip);
129+
}
130+
131+
public function testGuzzleOverride()
132+
{
133+
$tok = getenv('IPINFO_TOKEN');
134+
if (!$tok) {
135+
$this->markTestSkipped('IPINFO_TOKEN env var required');
136+
}
137+
138+
$h = new IPinfo($tok, ['guzzle_opts' => [
139+
'timeout' => 0.1
140+
]]);
141+
$ip = "8.8.8.8";
142+
143+
$this->expectException(IPinfoException::class);
144+
$res = $h->getDetails($ip);
145+
}
116146
}

0 commit comments

Comments
 (0)