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

ResponseTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

5 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 4 1
A testShouldBeInstantiated() 0 4 1
A testShouldReturnData() 0 10 1
A responses() 0 8 1
A testShouldRaiseException() 0 4 1
1
<?php
2
3
namespace Ip2c\Test\Unit;
4
5
use Ip2c\Http\Response;
6
use Prophecy\Argument;
7
8
class ResponseTest extends \PHPUnit_Framework_TestCase
9
{
10
11
    /** @var Response */
12
    private $sut;
13
14
    public function setUp()
15
    {
16
        $this->sut = new Response();
17
    }
18
19
    public function testShouldBeInstantiated()
20
    {
21
        $this->assertInstanceOf('Ip2c\Http\Response', $this->sut);
22
    }
23
24
    /** @dataProvider responses */
25
    public function testShouldReturnData($response, $status, $iso2, $iso3, $name)
26
    {
27
28
        $response = $this->sut->parseResult($response);
29
30
        $this->assertEquals($response->status(), $status);
31
        $this->assertEquals($response->iso2(), $iso2);
32
        $this->assertEquals($response->iso3(), $iso3);
33
        $this->assertEquals($response->name(), $name);
34
    }
35
36
    public function responses()
37
    {
38
        return array(
39
            array('1;ES;ESP;Spain', 1, 'ES', 'ESP', 'Spain'),
40
            array('2;AA;AAA;A Letter', 2, 'AA', 'AAA', 'A Letter'),
41
            array('3;BB;BBB;B Letter', 3, 'BB', 'BBB', 'B Letter')
42
        );
43
    }
44
45
    /**
46
     * @expectedException \Exception
47
     * @expectedExceptionCode 1
48
     * @expectedExceptionMessage Inconsistent response from Ip2c
49
     */
50
    public function testShouldRaiseException()
51
    {
52
        $this->sut->parseResult('1;ES;ESP');
53
    }
54
55
56
}
57