1
|
|
|
<?php declare(strict_types = 1); |
2
|
|
|
|
3
|
|
|
namespace SlevomatEET; |
4
|
|
|
|
5
|
|
|
use DateTimeImmutable; |
6
|
|
|
use DateTimeZone; |
7
|
|
|
use PHPUnit\Framework\TestCase; |
8
|
|
|
use SlevomatEET\Cryptography\CryptographyService; |
9
|
|
|
|
10
|
|
|
class EvidenceRequestTest extends TestCase |
11
|
|
|
{ |
12
|
|
|
|
13
|
|
|
/** @var Configuration */ |
14
|
|
|
private $configuration; |
15
|
|
|
|
16
|
|
|
public function setUp(): void |
17
|
|
|
{ |
18
|
|
|
$this->configuration = new Configuration('CZ00000019', '273', '/5546/RO24', EvidenceEnvironment::get(EvidenceEnvironment::PLAYGROUND), true); |
19
|
|
|
} |
20
|
|
|
|
21
|
|
|
public function testRequestFormatting(): void |
22
|
|
|
{ |
23
|
|
|
$receipt = new Receipt( |
24
|
|
|
true, |
25
|
|
|
'CZ683555118', |
26
|
|
|
'0/6460/ZQ42', |
27
|
|
|
new DateTimeImmutable('2016-11-01 00:30:12', new DateTimeZone('Europe/Prague')), |
28
|
|
|
3411300 |
29
|
|
|
); |
30
|
|
|
|
31
|
|
|
$crypto = $this->createMock(CryptographyService::class); |
32
|
|
|
$crypto->method('getPkpCode') |
|
|
|
|
33
|
|
|
->willReturn('123'); |
34
|
|
|
|
35
|
|
|
$crypto->method('getBkpCode') |
|
|
|
|
36
|
|
|
->willReturn('456'); |
37
|
|
|
|
38
|
|
|
$request = new EvidenceRequest($receipt, $this->configuration, $crypto); |
|
|
|
|
39
|
|
|
|
40
|
|
|
$requestData = $request->getRequestData(); |
41
|
|
|
|
42
|
|
|
$this->assertArrayHasKey('Hlavicka', $requestData); |
43
|
|
|
$this->assertArrayHasKey('Data', $requestData); |
44
|
|
|
$this->assertArrayHasKey('KontrolniKody', $requestData); |
45
|
|
|
$headerData = $requestData['Hlavicka']; |
46
|
|
|
$this->assertArrayHasKey('uuid_zpravy', $headerData); |
47
|
|
|
$this->assertArrayHasKey('dat_odesl', $headerData); |
48
|
|
|
|
49
|
|
|
$this->assertSame($headerData, $request->getHeader()); |
50
|
|
|
unset($headerData['uuid_zpravy']); |
51
|
|
|
unset($headerData['dat_odesl']); |
52
|
|
|
|
53
|
|
|
$this->assertSame([ |
54
|
|
|
'prvni_zaslani' => true, |
55
|
|
|
'overeni' => true, |
56
|
|
|
], $headerData); |
57
|
|
|
|
58
|
|
|
$this->assertSame([ |
59
|
|
|
'dic_popl' => 'CZ00000019', |
60
|
|
|
'dic_poverujiciho' => 'CZ683555118', |
61
|
|
|
'id_provoz' => '273', |
62
|
|
|
'id_pokl' => '/5546/RO24', |
63
|
|
|
'porad_cis' => '0/6460/ZQ42', |
64
|
|
|
'dat_trzby' => '2016-11-01T00:30:12+01:00', |
65
|
|
|
'celk_trzba' => '34113.00', |
66
|
|
|
'rezim' => 0, |
67
|
|
|
], $requestData['Data']); |
68
|
|
|
|
69
|
|
|
$this->assertSame($requestData['Data'], $request->getBody()); |
70
|
|
|
|
71
|
|
|
$this->assertSame([ |
72
|
|
|
'pkp' => [ |
73
|
|
|
'_' => '123', |
74
|
|
|
'digest' => 'SHA256', |
75
|
|
|
'cipher' => 'RSA2048', |
76
|
|
|
'encoding' => 'base64', |
77
|
|
|
], |
78
|
|
|
'bkp' => [ |
79
|
|
|
'_' => '456', |
80
|
|
|
'digest' => 'SHA1', |
81
|
|
|
'encoding' => 'base16', |
82
|
|
|
], |
83
|
|
|
], $requestData['KontrolniKody']); |
84
|
|
|
|
85
|
|
|
$this->assertSame('123', $request->getPkpCode()); |
86
|
|
|
$this->assertSame('456', $request->getBkpCode()); |
87
|
|
|
|
88
|
|
|
$this->assertInstanceOf(DateTimeImmutable::class, $request->getSendDate()); |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
} |
92
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.