Completed
Push — master ( aa3b55...27d657 )
by Dennis
04:45
created

testFindByIdentificationNumberWithLeadingZeros()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 5
rs 9.4285
cc 1
eloc 3
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
        $this->assertSame('Dennis Fridrich', $record->getCompanyName());
24
        $this->assertSame('CZ8508095453', $record->getTaxId());
25
        $this->assertSame(73263753, $record->getCompanyId());
26
        $this->assertEmpty($record->getStreet());
27
        $this->assertSame('15', $record->getStreetHouseNumber());
28
        $this->assertEmpty($record->getStreetOrientationNumber());
29
        $this->assertSame('Petrovice - Obděnice', $record->getTown());
30
        $this->assertSame('26255', $record->getZip());
31
    }
32
33
    public function testFindByIdentificationNumberWithLeadingZeros()
34
    {
35
        $record = $this->ares->findByIdentificationNumber('00006947');
36
        $this->assertSame('00006947', $record->getCompanyId());
37
    }
38
39
    /**
40
     * @expectedException \Defr\Ares\AresException
41
     */
42
    public function testFindByIdentificationNumberException()
43
    {
44
        $this->ares->findByIdentificationNumber('A1234');
45
    }
46
47
    public function testGetCompanyPeople()
48
    {
49
        if ($this->isTravis()) {
50
            $this->markTestSkipped('Travis cannot connect to Justice.cz');
51
        }
52
53
        $record = $this->ares->findByIdentificationNumber(27791394);
54
        $companyPeople
55
            = $record->getCompanyPeople();
56
        $this->assertCount(2, $companyPeople);
57
    }
58
59
    public function testBalancer()
60
    {
61
        $ares = new Ares();
62
        $ares->setBalancer('http://some.loadbalancer.domain');
63
        try {
64
            $ares->findByIdentificationNumber(26168685);
65
        } 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...
66
        }
67
        $this->assertEquals('http://some.loadbalancer.domain?url=http%3A%2F%2Fwwwinfo.mfcr.cz%2Fcgi-bin%2Fares%2Fdarv_bas.cgi%3Fico%3D26168685', $ares->getLastUrl());
68
    }
69
70
    /**
71
     * @return bool
72
     */
73
    private function isTravis()
74
    {
75
        if (getenv('TRAVIS_PHP_VERSION')) {
76
            return true;
77
        }
78
79
        return false;
80
    }
81
}
82