|
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
|
|
|
/** |
|
48
|
|
|
* @expectedException \Defr\Ares\AresException |
|
49
|
|
|
*/ |
|
50
|
|
|
public function testFindByEmptyStringException() |
|
51
|
|
|
{ |
|
52
|
|
|
$this->ares->findByIdentificationNumber(''); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
public function testGetCompanyPeople() |
|
56
|
|
|
{ |
|
57
|
|
|
if ($this->isTravis()) { |
|
58
|
|
|
$this->markTestSkipped('Travis cannot connect to Justice.cz'); |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
$record = $this->ares->findByIdentificationNumber(27791394); |
|
62
|
|
|
$companyPeople |
|
63
|
|
|
= $record->getCompanyPeople(); |
|
64
|
|
|
$this->assertCount(2, $companyPeople); |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
public function testBalancer() |
|
68
|
|
|
{ |
|
69
|
|
|
$ares = new Ares(); |
|
70
|
|
|
$ares->setBalancer('http://some.loadbalancer.domain'); |
|
71
|
|
|
try { |
|
72
|
|
|
$ares->findByIdentificationNumber(26168685); |
|
73
|
|
|
} catch (Ares\AresException $e) { |
|
|
|
|
|
|
74
|
|
|
} |
|
75
|
|
|
$this->assertEquals('http://some.loadbalancer.domain?url=http%3A%2F%2Fwwwinfo.mfcr.cz%2Fcgi-bin%2Fares%2Fdarv_bas.cgi%3Fico%3D26168685', $ares->getLastUrl()); |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
/** |
|
79
|
|
|
* @return bool |
|
80
|
|
|
*/ |
|
81
|
|
|
private function isTravis() |
|
82
|
|
|
{ |
|
83
|
|
|
if (getenv('TRAVIS_PHP_VERSION')) { |
|
84
|
|
|
return true; |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
return false; |
|
88
|
|
|
} |
|
89
|
|
|
} |
|
90
|
|
|
|