1
|
|
|
<?php declare(strict_types = 1); |
2
|
|
|
|
3
|
|
|
namespace SlevomatEET; |
4
|
|
|
|
5
|
|
|
use SlevomatEET\Cryptography\CryptographyService; |
6
|
|
|
|
7
|
|
|
class EvidenceRequestTest extends \PHPUnit\Framework\TestCase |
8
|
|
|
{ |
9
|
|
|
|
10
|
|
|
/** @var \PHPUnit_Framework_MockObject_MockObject|\SlevomatEET\Cryptography\CryptographyService */ |
11
|
|
|
private $crypto; |
12
|
|
|
|
13
|
|
|
/** @var \SlevomatEET\Configuration */ |
14
|
|
|
private $configuration; |
15
|
|
|
|
16
|
|
|
public function setUp() |
17
|
|
|
{ |
18
|
|
|
$this->crypto = $this->createMock(CryptographyService::class); |
19
|
|
|
|
20
|
|
|
$this->configuration = new Configuration('CZ00000019', '273', '/5546/RO24', new EvidenceEnvironment(EvidenceEnvironment::PLAYGROUND), true); |
21
|
|
|
} |
22
|
|
|
|
23
|
|
|
public function testRequestFormatting() |
24
|
|
|
{ |
25
|
|
|
$receipt = new Receipt( |
26
|
|
|
true, |
27
|
|
|
'CZ683555118', |
28
|
|
|
'0/6460/ZQ42', |
29
|
|
|
new \DateTimeImmutable('2016-11-01 00:30:12', new \DateTimeZone('Europe/Prague')), |
30
|
|
|
3411300 |
31
|
|
|
); |
32
|
|
|
|
33
|
|
|
$this->crypto->method('getPkpCode') |
34
|
|
|
->willReturn('123'); |
35
|
|
|
|
36
|
|
|
$this->crypto->method('getBkpCode') |
37
|
|
|
->willReturn('456'); |
38
|
|
|
|
39
|
|
|
$request = new EvidenceRequest($receipt, $this->configuration, $this->crypto); |
40
|
|
|
|
41
|
|
|
$requestData = $request->getRequestData(); |
42
|
|
|
|
43
|
|
|
$this->assertArrayHasKey('Hlavicka', $requestData); |
44
|
|
|
$this->assertArrayHasKey('Data', $requestData); |
45
|
|
|
$this->assertArrayHasKey('KontrolniKody', $requestData); |
46
|
|
|
$this->assertArrayHasKey('uuid_zpravy', $requestData['Hlavicka']); |
47
|
|
|
$this->assertArrayHasKey('dat_odesl', $requestData['Hlavicka']); |
48
|
|
|
|
49
|
|
|
unset($requestData['Hlavicka']['uuid_zpravy']); |
50
|
|
|
unset($requestData['Hlavicka']['dat_odesl']); |
51
|
|
|
|
52
|
|
|
$this->assertSame([ |
53
|
|
|
'prvni_zaslani' => true, |
54
|
|
|
'overeni' => true, |
55
|
|
|
], $requestData['Hlavicka']); |
56
|
|
|
|
57
|
|
|
$this->assertSame([ |
58
|
|
|
'dic_popl' => 'CZ00000019', |
59
|
|
|
'dic_poverujiciho' => 'CZ683555118', |
60
|
|
|
'id_provoz' => '273', |
61
|
|
|
'id_pokl' => '/5546/RO24', |
62
|
|
|
'porad_cis' => '0/6460/ZQ42', |
63
|
|
|
'dat_trzby' => '2016-11-01T00:30:12+01:00', |
64
|
|
|
'celk_trzba' => '34113.00', |
65
|
|
|
'rezim' => 0, |
66
|
|
|
], $requestData['Data']); |
67
|
|
|
|
68
|
|
|
$this->assertSame([ |
69
|
|
|
'pkp' => [ |
70
|
|
|
'_' => '123', |
71
|
|
|
'digest' => 'SHA256', |
72
|
|
|
'cipher' => 'RSA2048', |
73
|
|
|
'encoding' => 'base64', |
74
|
|
|
], |
75
|
|
|
'bkp' => [ |
76
|
|
|
'_' => '456', |
77
|
|
|
'digest' => 'SHA1', |
78
|
|
|
'encoding' => 'base16', |
79
|
|
|
], |
80
|
|
|
], $requestData['KontrolniKody']); |
81
|
|
|
|
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
} |
85
|
|
|
|