ResponseTest::testShouldReturnData()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 6
nc 1
nop 5
1
<?php
2
3
namespace Ip2c\Test\Unit;
4
5
use Ip2c\Http\Response;
6
7
class ResponseTest extends \PHPUnit_Framework_TestCase
8
{
9
10
    /** @var Response */
11
    private $sut;
12
13
    public function setUp()
14
    {
15
        $this->sut = new Response('1;ES;ESP;Spain');
16
    }
17
18
    public function testShouldBeInstantiated()
19
    {
20
        $this->assertInstanceOf('Ip2c\Http\Response', $this->sut);
21
    }
22
23
    /** @dataProvider responses */
24
    public function testShouldReturnData($response, $status, $iso2, $iso3, $name)
25
    {
26
27
        $responseObj = new Response($response);
28
29
        $this->assertEquals($responseObj->status(), $status);
30
        $this->assertEquals($responseObj->iso2(), $iso2);
31
        $this->assertEquals($responseObj->iso3(), $iso3);
32
        $this->assertEquals($responseObj->name(), $name);
33
    }
34
35
    public function responses()
36
    {
37
        return array(
38
            array('1;ES;ESP;Spain', 1, 'ES', 'ESP', 'Spain'),
39
            array('2;AA;AAA;A Letter', 2, 'AA', 'AAA', 'A Letter'),
40
            array('3;BB;BBB;B Letter', 3, 'BB', 'BBB', 'B Letter')
41
        );
42
    }
43
44
    /**
45
     * @expectedException \Exception
46
     * @expectedExceptionCode 1
47
     * @expectedExceptionMessage Inconsistent response from Ip2c
48
     */
49
    public function testShouldRaiseException()
50
    {
51
        $responseObj = new Response('1;ES;ESP');
0 ignored issues
show
Unused Code introduced by
$responseObj is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
52
    }
53
54
55
}
56