IpinfoApiTest::testResponseIpinfoFullDetails()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 14
rs 9.4285
cc 1
eloc 11
nc 1
nop 0
1
<?php
2
3
namespace IpInfo\Test;
4
5
use IpInfo\Lib\IpinfoApi;
6
7
class IpinfoApiTest extends \PHPUnit_Framework_TestCase
8
{
9
    const IP_FOR_TEST = '8.8.8.8';
10
11
    public function testResponseIpinfoFullDetails()
12
    {
13
        $ipInfo = new IpinfoApi();
14
        $response = $ipInfo->getFullIpDetails(static::IP_FOR_TEST);
15
16
        static::assertInstanceOf('IpInfo\Lib\IpinfoResponse', $response);
17
        static::assertEquals(200, $response->getStatusCode());
18
        static::assertEquals(static::IP_FOR_TEST, $response->getIp());
19
        static::assertEquals('Mountain View', $response->getCity());
20
        static::assertEquals('California', $response->getRegion());
21
        static::assertEquals('US', $response->getCountry());
22
        static::assertEquals('37.3860,-122.0840', $response->getLoc());
23
        static::assertEquals(94035, $response->getPostal());
24
    }
25
26
27
    public function testResponseIpinfoGeoDetails()
28
    {
29
        $ipInfo = new IpinfoApi();
30
        $response = $ipInfo->getIpGeoDetails(static::IP_FOR_TEST);
31
32
        static::assertInstanceOf('IpInfo\Lib\IpinfoResponse', $response);
33
        static::assertEquals(200, $response->getStatusCode());
34
        static::assertEquals(static::IP_FOR_TEST, $response->getIp());
35
        static::assertEquals('Mountain View', $response->getCity());
36
        static::assertEquals('California', $response->getRegion());
37
        static::assertEquals('US', $response->getCountry());
38
        static::assertEquals('37.3860,-122.0840', $response->getLoc());
39
        static::assertEquals(94035, $response->getPostal());
40
41
        static::assertEmpty($response->getHostname());
42
        static::assertEmpty($response->getOrg());
43
    }
44
}
45