Completed
Push — master ( 48f38e...d2527e )
by Jordi
09:04 queued 02:09
created

Ip2cTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 5
c 2
b 0
f 0
lcom 1
cbo 4
dl 0
loc 45
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 12 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
        $response = $this->prophesize('Ip2c\Http\Response');
18
        $ipUtil = $this->prophesize('Ip2c\Ip\IpUtil');
19
20
        $stringResult = '1;ES;ESP;Spain';
21
        $request->doRequest(Argument::any(), Argument::any())->willReturn($stringResult);
22
        $response->parseResult($stringResult)->willReturn($response->reveal());
23
24
        $this->sut = new Ip2c($request->reveal(), $response->reveal(), $ipUtil->reveal());
25
    }
26
27
    public function testShouldBeInstantiated()
28
    {
29
        $this->assertInstanceOf('Ip2c\Ip2c', $this->sut);
30
    }
31
32
    public function testShouldReturnAResponseSelf()
33
    {
34
        $response = $this->sut->self();
35
36
        $this->assertInstanceOf('Ip2c\Http\Response', $response);
37
    }
38
39
    public function testShouldReturnAResponseIp()
40
    {
41
        $response = $this->sut->ip('127.0.0.1');
42
43
        $this->assertInstanceOf('Ip2c\Http\Response', $response);
44
    }
45
46
    public function testShouldReturnAResponseDec()
47
    {
48
        $response = $this->sut->dec(123456789);
49
50
        $this->assertInstanceOf('Ip2c\Http\Response', $response);
51
    }
52
}
53