Ip2cTest   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 4
dl 0
loc 43
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 10 1
A testShouldBeInstantiated() 0 4 1
A testShouldReturnAResponseSelf() 0 6 1
A testShouldReturnAResponseIp() 0 6 1
A testShouldReturnAResponseDec() 0 6 1
1
<?php
2
3
namespace Ip2c\Test\Unit;
4
5
use Ip2c\Ip2c;
6
use Prophecy\Argument;
7
8
class Ip2cTest extends \PHPUnit_Framework_TestCase
9
{
10
11
    /** @var Ip2c */
12
    private $sut;
13
14
    public function setUp()
15
    {
16
        $request = $this->prophesize('Ip2c\Http\Request');
17
        $ipUtil = $this->prophesize('Ip2c\Ip\IpUtil');
18
19
        $stringResult = '1;ES;ESP;Spain';
20
        $request->doRequest(Argument::any(), Argument::any())->willReturn($stringResult);
21
22
        $this->sut = new Ip2c($request->reveal(), $ipUtil->reveal());
23
    }
24
25
    public function testShouldBeInstantiated()
26
    {
27
        $this->assertInstanceOf('Ip2c\Ip2c', $this->sut);
28
    }
29
30
    public function testShouldReturnAResponseSelf()
31
    {
32
        $response = $this->sut->self();
33
34
        $this->assertInstanceOf('Ip2c\Http\Response', $response);
35
    }
36
37
    public function testShouldReturnAResponseIp()
38
    {
39
        $response = $this->sut->ip('127.0.0.1');
40
41
        $this->assertInstanceOf('Ip2c\Http\Response', $response);
42
    }
43
44
    public function testShouldReturnAResponseDec()
45
    {
46
        $response = $this->sut->dec(123456789);
47
48
        $this->assertInstanceOf('Ip2c\Http\Response', $response);
49
    }
50
}
51