Completed
Push — master ( cd7319...abba19 )
by Dennis
09:18
created

testFindByIdentificationNumberException()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace Defr\Ares\Tests;
4
5
use Defr\Ares;
6
use PHPUnit_Framework_TestCase;
7
8
final class AresTest extends PHPUnit_Framework_TestCase
9
{
10
    /**
11
     * @var Ares
12
     */
13
    private $ares;
14
15
    protected function setUp()
16
    {
17
        $this->ares = new Ares();
18
    }
19
20
    public function testFindByIdentificationNumber()
21
    {
22
        $record = $this->ares->findByIdentificationNumber(73263753);
23
24
        $this->assertSame('Dennis Fridrich', $record->getCompanyName());
25
        $this->assertSame('CZ8508095453', $record->getTaxId());
26
        $this->assertSame(73263753, $record->getCompanyId());
27
        $this->assertSame('Herodova', $record->getStreet());
28
        $this->assertSame('1871', $record->getStreetHouseNumber());
29
        $this->assertSame('4', $record->getStreetOrientationNumber());
30
        $this->assertSame('Ostrava - Moravská Ostrava', $record->getTown());
31
        $this->assertSame('70200', $record->getZip());
32
    }
33
34
    /**
35
     * @expectedException \Defr\Ares\AresException
36
     */
37
    public function testFindByIdentificationNumberException()
38
    {
39
        $this->ares->findByIdentificationNumber('A1234');
40
    }
41
42
    public function testGetCompanyPeople()
43
    {
44
        if ($this->isTravis()) {
45
            $this->markTestSkipped('Travis cannot connect to Justice.cz');
46
        }
47
48
        $record = $this->ares->findByIdentificationNumber(27791394);
49
50
        $companyPeople = $record->getCompanyPeople();
51
        $this->assertCount(2, $companyPeople);
52
    }
53
54
    public function testBalancer()
55
    {
56
        $ares = new Ares();
57
        $ares->setBalancer('http://some.loadbalancer.domain');
58
        try {
59
            $ares->findByIdentificationNumber(26168685);
60
        } catch (Ares\AresException $e) {
0 ignored issues
show
Coding Style Comprehensibility introduced by
Consider adding a comment why this CATCH block is empty.
Loading history...
61
        }
62
        $this->assertEquals('http://some.loadbalancer.domain?url=http%3A%2F%2Fwwwinfo.mfcr.cz%2Fcgi-bin%2Fares%2Fdarv_bas.cgi%3Fico%3D26168685', $ares->getLastUrl());
63
    }
64
65
    /**
66
     * @return bool
67
     */
68
    private function isTravis()
69
    {
70
        if (getenv('TRAVIS_PHP_VERSION')) {
71
            return true;
72
        }
73
74
        return false;
75
    }
76
}
77