Completed
Push — master ( e9933e...972910 )
by Jan
04:27
created

CryptographyServiceTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 3
dl 0
loc 25
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A testGetCodes() 0 17 1
1
<?php declare(strict_types = 1);
2
3
namespace SlevomatEET;
4
5
use SlevomatEET\Cryptography\CryptographyService;
6
7
class CryptographyServiceTest extends \PHPUnit\Framework\TestCase
8
{
9
10
	const EXPECTED_PKP = 'a0asEiJhFCBlVtptSspKvEZhcrvnzF7SQ55C4DhnStnSu1b37GUI2+Dlme9P94UCPZ1oCUPJdsYOBZ3IX6aEgEe0FJKXYX0kXraYCJKIo3g64wRchE7iblIOBCK1uHh8qqHA66Isnhb6hqBOOdlt2aWO/0jCzlfeQr0axpPF1mohMnP3h3ICaxZh0dnMdju5OmMrq+91PL5T9KkR7bfGHqAoWJ0kmxY/mZumtRfGil2/xf7I5pdVeYXPgDO/Tojzm6J95n68fPDOXTDrTzKYmqDjpg3kmWepLNQKFXRmkQrkBLToJWG1LDUDm3UTTmPWzq4c0XnGcXJDZglxfolGpA==';
11
	const EXPECTED_BKP = '9356D566-A3E48838-FB403790-D201244E-95DCBD92';
12
13
	public function testGetCodes()
14
	{
15
		$data = [
16
			'dic_popl' => 'CZ00000019',
17
			'id_provoz' => '273',
18
			'id_pokl' => '/5546/RO24',
19
			'porad_cis' => '0/6460/ZQ42',
20
			'dat_trzby' => Formatter::formatDateTime(new \DateTimeImmutable('2016-08-05 00:30:12', new \DateTimeZone('Europe/Prague'))),
21
			'celk_trzba' => Formatter::formatAmount(3411300),
22
		];
23
		$crypto = new CryptographyService(__DIR__ . '/../../cert/EET_CA1_Playground-CZ00000019.key', __DIR__ . '/../../cert/EET_CA1_Playground-CZ00000019.pub');
24
25
		$expectedPkp = base64_decode(self::EXPECTED_PKP);
26
		$pkpCode = $crypto->getPkpCode($data);
27
		self::assertSame($expectedPkp, $pkpCode);
28
		self::assertSame(self::EXPECTED_BKP, $crypto->getBkpCode($pkpCode));
29
	}
30
31
}
32