JusticeTest   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 5
Bugs 0 Features 1
Metric Value
wmc 6
c 5
b 0
f 1
lcom 1
cbo 3
dl 0
loc 48
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 8 2
A testNotFoundFindId() 0 5 1
A isTravis() 0 8 2
A testFindById() 0 13 1
1
<?php
2
3
namespace Defr\Tests;
4
5
use Defr\Justice;
6
use Goutte\Client;
7
use PHPUnit_Framework_TestCase;
8
9
final class JusticeTest extends PHPUnit_Framework_TestCase
10
{
11
    /**
12
     * @var Justice
13
     */
14
    private $justice;
15
16
    protected function setUp()
17
    {
18
        if ($this->isTravis()) {
19
            $this->markTestSkipped('Travis cannot connect to Justice.cz');
20
        }
21
22
        $this->justice = new Justice(new Client());
23
    }
24
25
    public function testFindById()
26
    {
27
        $justiceRecord = $this->justice->findById(27791394);
28
        $this->assertInstanceOf('Defr\Justice\JusticeRecord', $justiceRecord);
29
30
        $people = $justiceRecord->getPeople();
31
        $this->assertCount(2, $people);
32
33
        $this->assertArrayHasKey('Mgr. ROBERT RUNTÁK', $people);
34
        $person = $people['Mgr. ROBERT RUNTÁK'];
35
        $this->assertInstanceOf('DateTime', $person->getBirthday());
36
        $this->assertInternalType('string', $person->getAddress());
37
    }
38
39
    public function testNotFoundFindId()
40
    {
41
        $justiceRecord = $this->justice->findById(123456);
42
        $this->assertFalse($justiceRecord);
43
    }
44
45
    /**
46
     * @return bool
47
     */
48
    private function isTravis()
49
    {
50
        if (getenv('TRAVIS_PHP_VERSION')) {
51
            return true;
52
        }
53
54
        return false;
55
    }
56
}
57